From 1282e3ed9e13ec2ac163c490d494cf09045747e1 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 30 Jun 2019 15:57:04 +0200 Subject: [PATCH] Get Singleton Notification --- .../PersistentNotificationPlugin.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.java index 24ce87bc23..9dcb800033 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.java @@ -52,6 +52,7 @@ import info.nightscout.androidaps.utils.DecimalFormatter; public class PersistentNotificationPlugin extends PluginBase { private static PersistentNotificationPlugin plugin; + private Notification notification; public static PersistentNotificationPlugin getPlugin() { if (plugin == null) plugin = new PersistentNotificationPlugin(MainApp.instance()); @@ -122,7 +123,7 @@ public class PersistentNotificationPlugin extends PluginBase { } @Nonnull - public Notification updateNotification() { + Notification updateNotification() { String line1 = null; String line2 = null; String line3 = null; @@ -250,6 +251,7 @@ public class PersistentNotificationPlugin extends PluginBase { android.app.Notification notification = builder.build(); mNotificationManager.notify(ONGOING_NOTIFICATION_ID, notification); + this.notification = notification; return notification; } @@ -269,6 +271,17 @@ public class PersistentNotificationPlugin extends PluginBase { return deltastring; } + /*** + * returns the current ongoing notification. + * + * If it does not exist, return a dummy notification. This should only happen if onStart() wasn't called. + */ + + public Notification getLastNotification() { + if (notification != null) return notification; + else return new Notification(); + } + @Subscribe public void onStatusEvent(final EventPreferenceChange ev) {