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

@@ -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;
}