Make transport service start in foreground to resolve #13
This commit is contained in:
parent
98297537df
commit
7c3bff31f0
2 changed files with 15 additions and 9 deletions
|
@ -11,11 +11,8 @@ public class Backup extends Application {
|
|||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
startService(new Intent(this, ConfigurableBackupTransportService.class));
|
||||
}
|
||||
super.onCreate();
|
||||
|
||||
@Override
|
||||
public void onTerminate() {
|
||||
stopService(new Intent(this, ConfigurableBackupTransportService.class));
|
||||
startForegroundService(new Intent(this, ConfigurableBackupTransportService.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.stevesoltys.backup.transport;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
|
@ -9,20 +10,28 @@ import android.os.IBinder;
|
|||
*/
|
||||
public class ConfigurableBackupTransportService extends Service {
|
||||
|
||||
private static final int FOREGROUND_ID = 43594;
|
||||
|
||||
private static ConfigurableBackupTransport backupTransport = null;
|
||||
|
||||
public static ConfigurableBackupTransport getBackupTransport() {
|
||||
return backupTransport;
|
||||
}
|
||||
|
||||
public void onCreate() {
|
||||
if (backupTransport == null) {
|
||||
backupTransport = new ConfigurableBackupTransport();
|
||||
}
|
||||
|
||||
return backupTransport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
startForeground(FOREGROUND_ID, new Notification.Builder(this).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return backupTransport.getBinder();
|
||||
return getBackupTransport().getBinder();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue