mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 06:11:19 +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);
|
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.
|
* Creates notification, starts native binary.
|
||||||
*/
|
*/
|
||||||
|
@ -41,6 +46,7 @@ public class SyncthingService extends Service {
|
||||||
.setSmallIcon(R.drawable.ic_launcher)
|
.setSmallIcon(R.drawable.ic_launcher)
|
||||||
.setContentIntent(pi)
|
.setContentIntent(pi)
|
||||||
.build();
|
.build();
|
||||||
|
n.flags |= Notification.FLAG_ONGOING_EVENT;
|
||||||
startForeground(NOTIFICATION_ID, n);
|
startForeground(NOTIFICATION_ID, n);
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
|
|
|
@ -94,6 +94,8 @@ public class WebGuiActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
getApplicationContext().startService(
|
||||||
|
new Intent(this, SyncthingService.class));
|
||||||
getApplicationContext().bindService(
|
getApplicationContext().bindService(
|
||||||
new Intent(this, SyncthingService.class),
|
new Intent(this, SyncthingService.class),
|
||||||
mSyncthingServiceConnection, Context.BIND_AUTO_CREATE);
|
mSyncthingServiceConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
|
Loading…
Reference in a new issue