diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-01-25 23:03:26 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-01-25 23:03:59 +0100 |
commit | ce2cf51df08b8b0ad4250c3396975108aa3f5085 (patch) | |
tree | a3dc10ed007e2c6734cb707583e806a6a8b86103 /src/standardPush/java | |
parent | d4a584c88a80ebf3f48bbe5ecb9860de3c59dbbb (diff) |
explicitly start service (instead of just bind) service from contact chooser
Diffstat (limited to 'src/standardPush/java')
-rw-r--r-- | src/standardPush/java/de/pixart/messenger/services/MaintenanceReceiver.java | 7 | ||||
-rw-r--r-- | src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java | 22 |
2 files changed, 3 insertions, 26 deletions
diff --git a/src/standardPush/java/de/pixart/messenger/services/MaintenanceReceiver.java b/src/standardPush/java/de/pixart/messenger/services/MaintenanceReceiver.java index 5706a487a..34627ae64 100644 --- a/src/standardPush/java/de/pixart/messenger/services/MaintenanceReceiver.java +++ b/src/standardPush/java/de/pixart/messenger/services/MaintenanceReceiver.java @@ -29,12 +29,7 @@ public class MaintenanceReceiver extends BroadcastReceiver { FirebaseInstanceId.getInstance().deleteInstanceId(); final Intent intent = new Intent(context, XmppConnectionService.class); intent.setAction(XmppConnectionService.ACTION_FCM_TOKEN_REFRESH); - if (Compatibility.runsAndTargetsTwentySix(context)) { - intent.putExtra(EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE, true); - ContextCompat.startForegroundService(context, intent); - } else { - context.startService(intent); - } + Compatibility.startService(context, intent); } catch (IOException e) { Log.d(Config.LOGTAG, "unable to renew instance token", e); } diff --git a/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java b/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java index 594225f3b..17f4ef32a 100644 --- a/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java +++ b/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java @@ -24,16 +24,7 @@ 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")); - 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 after receiving message"); - } + Compatibility.startService(this, intent); } @Override @@ -44,15 +35,6 @@ public class PushMessageReceiver extends FirebaseMessagingService { } final Intent intent = new Intent(this, XmppConnectionService.class); intent.setAction(XmppConnectionService.ACTION_FCM_TOKEN_REFRESH); - 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 after receiving new token"); - } + Compatibility.startService(this, intent); } }
\ No newline at end of file |