diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-11-23 14:58:54 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-11-23 14:58:54 +0100 |
commit | e5f2c9d1e918be11ac91c055ecc07dad9233c6d3 (patch) | |
tree | 191295dfeccb4e25f203f8062e93b0f716cc9db5 /src/standardPush/java/de/pixart/messenger | |
parent | 437d88331d49d628b64909c74febceb3d2c0c372 (diff) |
catch a few run time exceptions related to androids life cycle mgmt
Diffstat (limited to '')
-rw-r--r-- | src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java | 14 | ||||
-rw-r--r-- | src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java | 14 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java b/src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java index 465f974e6..9a3309be4 100644 --- a/src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java +++ b/src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java @@ -15,11 +15,15 @@ public class InstanceIdService extends FirebaseInstanceIdService { public void onTokenRefresh() { final Intent intent = new Intent(this, XmppConnectionService.class); intent.setAction(XmppConnectionService.ACTION_FCM_TOKEN_REFRESH); - if (Compatibility.runsAndTargetsTwentySix(this)) { - intent.putExtra(EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE, true); - ContextCompat.startForegroundService(this, intent); - } else { - startService(intent); + try { + if (Compatibility.runsAndTargetsTwentySix(this)) { + intent.putExtra(EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE, true); + ContextCompat.startForegroundService(this, intent); + } else { + startService(intent); + } + } catch (IllegalStateException e) { + Log.e(Config.LOGTAG, "InstanceIdService is not allowed to start service"); } } }
\ No newline at end of file diff --git a/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java b/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java index 88b60e348..f07167f8d 100644 --- a/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java +++ b/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java @@ -24,11 +24,15 @@ public class PushMessageReceiver extends FirebaseMessagingService { final Intent intent = new Intent(this, XmppConnectionService.class); intent.setAction(XmppConnectionService.ACTION_FCM_MESSAGE_RECEIVED); intent.putExtra("account", data.get("account")); - if (Compatibility.runsAndTargetsTwentySix(this)) { - intent.putExtra(EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE, true); - ContextCompat.startForegroundService(this, intent); - } else { - startService(intent); + try { + if (Compatibility.runsAndTargetsTwentySix(this)) { + intent.putExtra(EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE, true); + ContextCompat.startForegroundService(this, intent); + } else { + startService(intent); + } + } catch (IllegalStateException e) { + Log.e(Config.LOGTAG, "PushMessageReceiver is not allowed to start service"); } } }
\ No newline at end of file |