Is Android Widget ID persistent

2019-07-20 23:51发布

Is the widget id that you receive from the OS for a specific instance of your widget on the users desktop consistent until that instance of the Widget is deleted from the desktop? I can't find any documentation that definitive says that it is, but I am assuming that it is because the documentation says you can use the widget id to store any instance configuration information.

I want to store some configuration info into a database and tie it to a widget id as the unique reference. So that when a phone is rebooted I can lookup the previously saved off configuration for that instance based on the widget id and populate it in onUpdate.

Thanks for the help!

1条回答
Emotional °昔
2楼-- · 2019-07-21 00:14

Widget ids change only when you add the widgets on your home screen. You can remove the widget from your home screen and add it again. In this case your widget's id will be different.

查看更多
登录 后发表回答