DummyService has nonNull notification

This commit is contained in:
AdrianLxM 2019-06-30 14:12:40 +02:00 committed by GitHub
parent b2c46b67b6
commit 3dc5c61984
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,6 +31,7 @@ public class DummyService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
startForeground(PersistentNotificationPlugin.ONGOING_NOTIFICATION_ID, PersistentNotificationPlugin.getPlugin().updateNotification());
return START_STICKY;
}
@ -45,11 +46,9 @@ public class DummyService extends Service {
@Override
public void onCreate() {
super.onCreate();
// TODO: I guess this was moved here in order to adhere to the 5 seconds rule to call "startForeground" after a Service was called as Foreground service?
// As onCreate() is not called every time a service is started, copied to onStartCommand().
Notification notification = PersistentNotificationPlugin.getPlugin().updateNotification();
if (notification == null) {
log.debug("notification==null");
notification = new Notification();
}
startForeground(PersistentNotificationPlugin.ONGOING_NOTIFICATION_ID, notification);
MainApp.bus().register(this);
}