即使我有配置活动,为什么我的小部件仍会调用 onUpdate() ?
据我所知,如果我为我的小部件定义了配置活动,那么在首次创建它时不应调用 onUpdate
。配置活动负责执行小部件的初始配置。
为什么我仍然会在小部件提供程序中收到对 onUpdate
的调用,并且在调用之后配置活动启动。如果我取消配置活动,我在主屏幕上看不到可见的小部件。如果我取消了小部件配置(通过在配置活动中按回键)并重新安装 APK 所有小部件(包括取消的小部件),则每个小部件都会在对 onUpdate
的调用中提及。
当然,这不应该是这样。如果是,那么我如何摆脱在配置过程中取消的小部件。
我正在 Android 1.6 的模拟器上运行我的代码。
As far as I can tell, if I have defined a configuration activity for my widget then onUpdate
should not be called when it is first created. It would be the configuration activity's responsibility to perform the initial configuration of the widget.
Why is it then that I still get calls to onUpdate
in the widget provider, and after that call the configuration activity is started. If I cancel the configuration activity I get no visible widget on the home screen. If I have cancelled a widget configuration (by pressing back in the configuration activity) and reinstall the APK all the widgets, including the cancelled ones, each gets mentioned in calls to onUpdate
.
Surely this shouldn't be so. And if it is, then how do I get rid of the widgets that was cancelled during configuration.
I'm running my code on the emulator with Android 1.6.
似乎是一个错误:
http://code.google.com/p/android/issues /detail?id=13755#c0
Seems to be a bug on that:
http://code.google.com/p/android/issues/detail?id=13755#c0