mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-26 21:01:32 +00:00
Fixed service stopping on Activity exit.
This commit is contained in:
parent
745de67005
commit
11f3c46fa0
2 changed files with 8 additions and 0 deletions
|
@ -28,6 +28,11 @@ public class SyncthingService extends Service {
|
|||
|
||||
private final SyncthingServiceBinder mBinder = new SyncthingServiceBinder(this);
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates notification, starts native binary.
|
||||
*/
|
||||
|
@ -41,6 +46,7 @@ public class SyncthingService extends Service {
|
|||
.setSmallIcon(R.drawable.ic_launcher)
|
||||
.setContentIntent(pi)
|
||||
.build();
|
||||
n.flags |= Notification.FLAG_ONGOING_EVENT;
|
||||
startForeground(NOTIFICATION_ID, n);
|
||||
|
||||
new Thread(new Runnable() {
|
||||
|
|
|
@ -94,6 +94,8 @@ public class WebGuiActivity extends Activity {
|
|||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getApplicationContext().startService(
|
||||
new Intent(this, SyncthingService.class));
|
||||
getApplicationContext().bindService(
|
||||
new Intent(this, SyncthingService.class),
|
||||
mSyncthingServiceConnection, Context.BIND_AUTO_CREATE);
|
||||
|
|
Loading…
Reference in a new issue