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
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
startService(new Intent(this, ConfigurableBackupTransportService.class));
|
super.onCreate();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
startForegroundService(new Intent(this, ConfigurableBackupTransportService.class));
|
||||||
public void onTerminate() {
|
|
||||||
stopService(new Intent(this, ConfigurableBackupTransportService.class));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.stevesoltys.backup.transport;
|
package com.stevesoltys.backup.transport;
|
||||||
|
|
||||||
|
import android.app.Notification;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
@ -9,20 +10,28 @@ import android.os.IBinder;
|
||||||
*/
|
*/
|
||||||
public class ConfigurableBackupTransportService extends Service {
|
public class ConfigurableBackupTransportService extends Service {
|
||||||
|
|
||||||
|
private static final int FOREGROUND_ID = 43594;
|
||||||
|
|
||||||
private static ConfigurableBackupTransport backupTransport = null;
|
private static ConfigurableBackupTransport backupTransport = null;
|
||||||
|
|
||||||
public static ConfigurableBackupTransport getBackupTransport() {
|
public static ConfigurableBackupTransport getBackupTransport() {
|
||||||
return backupTransport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCreate() {
|
|
||||||
if (backupTransport == null) {
|
if (backupTransport == null) {
|
||||||
backupTransport = new ConfigurableBackupTransport();
|
backupTransport = new ConfigurableBackupTransport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return backupTransport;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
|
||||||
|
startForeground(FOREGROUND_ID, new Notification.Builder(this).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent) {
|
||||||
return backupTransport.getBinder();
|
return getBackupTransport().getBinder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue