From d202976251dd9d48c4e33cb4defb61bf1e33f5e7 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Fri, 20 Oct 2017 20:15:37 +0200 Subject: [PATCH] PersistentNotification unregister workaround. --- .../PersistentNotificationPlugin.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java index f0745afe94..6c3e45decb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java @@ -191,11 +191,16 @@ public class PersistentNotificationPlugin implements PluginBase { private void checkBusRegistration() { if (fragmentEnabled) { - MainApp.bus().register(this); + try { + MainApp.bus().register(this); + } catch (IllegalArgumentException e) { + // already registered + } } else { try { MainApp.bus().unregister(this); - } catch (Exception e) { + } catch (IllegalArgumentException e) { + // already unregistered } } }