diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-09-27 19:45:25 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-09-27 19:45:25 +0200 |
commit | 59dd2bb1c9b2be4c6b8802fbe0ee48085881d74d (patch) | |
tree | ef4ba57451d409f99653ea537aa4f6f021500bca /src/main/java/de/pixart/messenger/services/EventReceiver.java | |
parent | c8d159adca8258c88e91c8decc41fe1b90afc765 (diff) |
behave nicely (no foreground service by default) if app is built with targetSdk <26
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/EventReceiver.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/services/EventReceiver.java b/src/main/java/de/pixart/messenger/services/EventReceiver.java index 529741ead..a77db569e 100644 --- a/src/main/java/de/pixart/messenger/services/EventReceiver.java +++ b/src/main/java/de/pixart/messenger/services/EventReceiver.java @@ -8,6 +8,7 @@ import android.support.v4.content.ContextCompat; import android.util.Log; import de.pixart.messenger.Config; +import de.pixart.messenger.utils.Compatibility; public class EventReceiver extends BroadcastReceiver { @@ -24,7 +25,11 @@ public class EventReceiver extends BroadcastReceiver { final String action = originalIntent.getAction(); if (action.equals("ui") || hasEnabledAccounts(context)) { try { - ContextCompat.startForegroundService(context, intentForService); + if (Compatibility.runsAndTargetsTwentySix(context)) { + ContextCompat.startForegroundService(context, intentForService); + } else { + context.startService(intentForService); + } } catch (RuntimeException e) { Log.d(Config.LOGTAG, "EventReceiver was unable to start service"); } |