AppWidget ID Life

I have an application with some AppWidget s. I store some information about each widget, including its appWidgetId inside the database. I need this information to properly update each widget. The problem is that after rebooting the device I can no longer address these appWidgetId , as it seems that they are changing their values. How can I solve this problem? Thanks in advance.

+4
source share
3 answers

It seems that only on some devices the appwidget ids change on reboot (due to an error). See this thread .

I looked at the Android source. Appwidget identifiers are indeed stored in a file in /data/system/appwidgets.xml . Your device may have the error indicated in this thread.

I can’t think of a suitable job.

+4
source

I think Dheeraj is right. I am also a developer of Android Widgets and do the same as you: I save the settings for each widget, remembering WidgetId. This works flawlessly on all the devices that I know. The identifier does not change after reboot on all devices that I know. Are you confident in your observations?

+1
source

The new appWidgetId propagates in R.java every time you launch the application instead of storing the id from R.java, you can store the id from android: id = "@ + id / btn_add" in your database.

-1
source

Source: https://habr.com/ru/post/1402239/


All Articles