【发布时间】:2020-08-01 20:38:18
【问题描述】:
在哪些情况下我应该覆盖 onRestored?
他们只是指可以在清单中启用/禁用的备份吗?当应用程序获取更新时,是否有可能调用此方法?或者在 appWidgetIds 可能发生变化的任何其他情况下?我认为 id 应该永远保持不变,但并非所有制造商/启动器都以相同的方式对待小部件......
这对幻像/幽灵小部件有用吗?
/**
* Called in response to the {@link AppWidgetManager#ACTION_APPWIDGET_RESTORED} broadcast
* when instances of this AppWidget provider have been restored from backup. If your
* provider maintains any persistent data about its widget instances, override this method
* to remap the old AppWidgetIds to the new values and update any other app state that may
* be relevant.
*
* <p>This callback will be followed immediately by a call to {@link #onUpdate} so your
* provider can immediately generate new RemoteViews suitable for its newly-restored set
* of instances.
*
* {@more}
*
* @param context
* @param oldWidgetIds
* @param newWidgetIds
*/
public void onRestored(Context context, int[] oldWidgetIds, int[] newWidgetIds) {
}
【问题讨论】:
标签: java android android-appwidget appwidgetprovider