mirror of https://github.com/M66B/FairEmail.git
Start foreground on create
Sometimes there is a significant delay between on create and on start command
This commit is contained in:
parent
eaf3ea4a7c
commit
954c8db225
|
@ -36,11 +36,15 @@ public class ServiceExternal extends Service {
|
|||
// adb shell am startservice -a eu.faircode.email.DISABLE
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
startForeground(Helper.NOTIFICATION_EXTERNAL, getNotification().build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
try {
|
||||
startForeground(Helper.NOTIFICATION_EXTERNAL, getNotification().build());
|
||||
|
||||
Log.i("Received intent=" + intent);
|
||||
Log.logExtras(intent);
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ public class ServiceSend extends ServiceBase {
|
|||
public void onCreate() {
|
||||
Log.i("Service send create");
|
||||
super.onCreate();
|
||||
startForeground(Helper.NOTIFICATION_SEND, getNotificationService(null, null).build());
|
||||
|
||||
cowner = new TwoStateOwner(ServiceSend.this, "send");
|
||||
final DB db = DB.getInstance(this);
|
||||
|
@ -223,10 +224,7 @@ public class ServiceSend extends ServiceBase {
|
|||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
startForeground(Helper.NOTIFICATION_SEND, getNotificationService(null, null).build());
|
||||
|
||||
super.onStartCommand(intent, flags, startId);
|
||||
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue