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

前端 未结 2 1815
不思量自难忘°
不思量自难忘° 2021-01-13 09:07

My app widget stops working after upgrading to targetSDk to 28.

  • It is flawlessly working on old targetsdk devices.

I am getting the following e

相关标签:
2条回答
  • 2021-01-13 09:10

    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);
    }
    
    0 讨论(0)
  • 2021-01-13 09:26

    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

    0 讨论(0)
提交回复
热议问题