From 267410f1de6c079f9a36e1634a1968be5e42ae1d Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 17 Oct 2018 06:00:48 +0000 Subject: [PATCH] Fixed init/start/stop --- .../main/java/eu/faircode/email/ServiceSynchronize.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 55c34805..f9bb43c4 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -2148,22 +2148,22 @@ public class ServiceSynchronize extends LifecycleService { public static void init(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (prefs.getBoolean("enabled", true)) - ContextCompat.startForegroundService(context, new Intent(context, ServiceSynchronize.class)); + start(context); } public static void start(Context context) { - context.startService(new Intent(context, ServiceSynchronize.class).setAction("start")); + ContextCompat.startForegroundService(context, new Intent(context, ServiceSynchronize.class).setAction("start")); } public static void stop(Context context) { - context.startService(new Intent(context, ServiceSynchronize.class).setAction("stop")); + ContextCompat.startForegroundService(context, new Intent(context, ServiceSynchronize.class).setAction("stop")); } public static void reload(Context context, String reason) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (prefs.getBoolean("enabled", true)) { Log.i(Helper.TAG, "Reload because of '" + reason + "'"); - context.startService(new Intent(context, ServiceSynchronize.class).setAction("reload")); + ContextCompat.startForegroundService(context, new Intent(context, ServiceSynchronize.class).setAction("reload")); } }