问题
I need your help to resolve this problem :
Context.startForegroundService() did not then call Service.startForeground()
I'm using a BroadcastReceiver to start the notification service :
@Override
public void onReceive(Context context, Intent intent) {
WakeLock.acquire(context);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ContextCompat.startForegroundService(context, new Intent(context, StartNotificationService.class).putExtras(intent));
} else {
context.startService(new Intent(context, StartNotificationService.class).putExtras(intent));
}
}
Have you any idea please ? How can I resolve this issue ? Thanks you
回答1:
Your Service
must call startForeground()
when it is started, otherwise the system will not allow it to run.
来源:https://stackoverflow.com/questions/56043351/context-startforegroundservice-did-not-then-call-service-startforeground-in