Why widget does not work after reboot?

前端 未结 2 1697
南笙
南笙 2021-01-03 12:47

I have this simple widget and when I click on it, it should open my activity, it works, but it doesn\'t work after reboot. I must delete and then again add widget to my home

相关标签:
2条回答
  • 2021-01-03 12:57

    The AppWidgetProvider which widgets inherit calls onUpdate on startup when it receives ACTION_APPWIDGET_UPDATE from the operating system.

    If you override onReceive without calling super.onReceive(), you would need to intercept this Intent on your own.

    0 讨论(0)
  • 2021-01-03 13:09

    After reboot you OnEnabled is called instead of onUpdate so move the code from onUpdate into a separate method and then call that method to update all widgets from onEnabled

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