diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/DummyService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/DummyService.java index 1d287ca338..1400185afa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/DummyService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/DummyService.java @@ -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); }