aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-10-08 00:52:04 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-10-08 00:52:04 +0200
commite65068d2267246962b9764d86eb3a906e3dde68f (patch)
treecd55839c2ee8f477dc1d2e0828a797b16cf7a78a /src/main
parentf81e44d3393be26e622e169d3aff8a38722382e3 (diff)
catch exception when unregistering receivers that have not been registered before
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 18094cfb..ddc40d34 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -662,7 +662,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
@Override
public void onDestroy() {
- unregisterReceiver(this.mEventReceiver);
+ try {
+ unregisterReceiver(this.mEventReceiver);
+ } catch (IllegalArgumentException e) {
+ //ignored
+ }
super.onDestroy();
}
@@ -672,12 +676,16 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
filter.addAction(Intent.ACTION_SCREEN_OFF);
registerReceiver(this.mEventReceiver, filter);
} else {
- unregisterReceiver(this.mEventReceiver);
+ try {
+ unregisterReceiver(this.mEventReceiver);
+ } catch (IllegalArgumentException e) {
+ //ignored
+ }
}
}
public void toggleForegroundService() {
- if (getPreferences().getBoolean("keep_foreground_service",false)) {
+ if (getPreferences().getBoolean("keep_foreground_service", false)) {
startForeground(NotificationService.FOREGROUND_NOTIFICATION_ID, this.mNotificationService.createForegroundNotification());
} else {
stopForeground(true);