1
0
Fork 0
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:
Felix Ableitner 2014-05-13 17:59:52 +02:00
parent 745de67005
commit 11f3c46fa0
2 changed files with 8 additions and 0 deletions

View file

@ -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() {

View file

@ -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);