Context.startForegroundService() 然后没有在 BroadcastReceiver 中调用 Service.startForeground()
Context.startForegroundService() did not then call Service.startForeground() In BroadcastReceiver
我需要你的帮助来解决这个问题:
Context.startForegroundService() did not then call Service.startForeground()
我正在使用 BroadcastReceiver 来启动通知服务:
@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));
}
}
你有什么想法吗?我该如何解决这个问题?
谢谢你
你的Service
启动时必须调用startForeground()
,否则系统不允许运行。
我需要你的帮助来解决这个问题:
Context.startForegroundService() did not then call Service.startForeground()
我正在使用 BroadcastReceiver 来启动通知服务:
@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));
}
}
你有什么想法吗?我该如何解决这个问题? 谢谢你
你的Service
启动时必须调用startForeground()
,否则系统不允许运行。