|
|
@ -19,21 +19,22 @@ public abstract class InjectingService extends Service {
|
|
|
|
public void onCreate() {
|
|
|
|
public void onCreate() {
|
|
|
|
super.onCreate();
|
|
|
|
super.onCreate();
|
|
|
|
|
|
|
|
|
|
|
|
startForeground(getNotificationId(), buildNotification());
|
|
|
|
startForeground();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
disposables = new CompositeDisposable();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inject(((InjectingApplication) getApplication()).getComponent().plus(new ServiceModule()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
|
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
|
|
startForeground(getNotificationId(), buildNotification());
|
|
|
|
startForeground();
|
|
|
|
|
|
|
|
|
|
|
|
inject(((InjectingApplication) getApplication()).getComponent().plus(new ServiceModule()));
|
|
|
|
disposables.add(
|
|
|
|
|
|
|
|
|
|
|
|
disposables =
|
|
|
|
|
|
|
|
new CompositeDisposable(
|
|
|
|
|
|
|
|
Completable.fromAction(this::doWork)
|
|
|
|
Completable.fromAction(this::doWork)
|
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
|
.subscribe(this::stopSelf));
|
|
|
|
.subscribe(() -> stopSelf(startId)));
|
|
|
|
|
|
|
|
|
|
|
|
return Service.START_NOT_STICKY;
|
|
|
|
return Service.START_NOT_STICKY;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -47,6 +48,10 @@ public abstract class InjectingService extends Service {
|
|
|
|
disposables.dispose();
|
|
|
|
disposables.dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void startForeground() {
|
|
|
|
|
|
|
|
startForeground(getNotificationId(), buildNotification());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected abstract int getNotificationId();
|
|
|
|
protected abstract int getNotificationId();
|
|
|
|
|
|
|
|
|
|
|
|
protected abstract int getNotificationBody();
|
|
|
|
protected abstract int getNotificationBody();
|
|
|
|