Start foreground on create

Sometimes there is a significant delay between on create and on start command
This commit is contained in:
M66B
2019-07-30 08:46:38 +02:00
parent eaf3ea4a7c
commit 954c8db225
3 changed files with 8 additions and 7 deletions

View File

@@ -119,6 +119,7 @@ public class ServiceSynchronize extends ServiceBase {
public void onCreate() {
Log.i("Service create version=" + BuildConfig.VERSION_NAME);
super.onCreate();
startForeground(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(null).build());
// Listen for network changes
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
@@ -251,8 +252,6 @@ public class ServiceSynchronize extends ServiceBase {
Log.i("Service command intent=" + intent + " action=" + action);
Log.logExtras(intent);
startForeground(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(null).build());
super.onStartCommand(intent, flags, startId);
if (action != null)