Widget issue: BroadcastQueue: Background execution not allowed: receiving Intent

爷,独闯天下 提交于 2019-12-01 06:04:45

The problem is in implicit broadcast that you're making in sendWidgetRefresh. You can break through the ban by defining a component name in your intent.

private static void sendWidgetRefresh(Context context) {
    // send update broadcast to widget
    Intent broadcast = new Intent(ClockWidgetProvider.WIDGET_DATA_CHANGED_ACTION);
    ComponentName componentName = new ComponentName(context, WorldClockWidgetProvider.class);
    broadcast.setComponent(componentName);
    context.sendBroadcast(broadcast);
}

This worked for me! Change your implicit intent to explicit intent, because starting Oreo implicit intents don't run in background! https://developer.android.com/about/versions/oreo/background.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!