I am setting widget data using android:configure tag which sets my configuration activity (ie it's list dialog ) which sets onClick
event and image to my widget depending on user's selection. now the problem is whenever I reboot the phone or rerun my widget clears its image and clickListener to.
and even if I set a listener to BOOT_COMPLETED intent how I am going to reset widget's value to previous values as I don't want to call my configuration activity every time I reboot.
thanks in advance.!
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
AppUtils.showToast(context, " BOOT_COMPLETED ", true);
}
}
在BOOT_COMPLETED
使用保存的数据值恢复窗口小部件后,您应该将有价值的数据保存到SQLite
Room
Realm
或您喜欢的任何数据库工具
The widget does not provide the ability to save its state after a reboot.
There is no other way here than to save it yourself in any of the persistent repositories.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.