From 3dc5c61984a403cccb4221b0a03ae03e0520d553 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 30 Jun 2019 14:12:40 +0200 Subject: [PATCH] DummyService has nonNull notification --- .../general/persistentNotification/DummyService.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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); }