[英]onUpdate called when Configuration Activity is launched
According to the App Widgets documentation, onUpdate
method should not be called if a Configuration Activity has been declared. 根据App Widgets文档,如果已声明配置活动,则不应调用onUpdate
方法。
Still it is being called when the configuration activity is launched... 启动配置活动时仍会调用它...
How do I prevent it from being called and call it only when the configuration activity has been closed with RESULT_OK
code. 如何防止调用它,并且仅当使用RESULT_OK
代码关闭配置活动时才调用它。
Thank you upfront. 预先感谢您。
I'm never too certain about what methods are called on you AppWidget, because some of the logic is up to the developer of the launcher application, not to the Android OS itself. 对于您在AppWidget上调用的方法,我永远不会太确定,因为某些逻辑取决于启动器应用程序的开发人员,而不取决于Android OS本身。 So this differs quite a lot between Launchers (Samsung, Google, HTC, KK etc.) Your widget should be prepared to degrade in a way acceptable for the user. 因此,启动器(三星,谷歌,HTC,KK等)之间有很大的不同。您的小部件应准备好以用户可以接受的方式降级。
Take a look at AppWidgetProvider source: 看一下AppWidgetProvider的源代码:
https://android.googlesource.com/platform/frameworks/base.git/+/android-cts-4.2_r1/core/java/android/appwidget/AppWidgetProvider.java https://android.googlesource.com/platform/frameworks/base.git/+/android-cts-4.2_r1/core/java/android/appwidget/AppWidgetProvider.java
It extends BroadcastReceiver, so you can add extra logic to onReceive() to avoid calling onUpdate() if your configuration activity hasn't been closed yet. 它扩展了BroadcastReceiver,因此,如果尚未关闭配置活动,则可以向onReceive()添加额外的逻辑以避免调用onUpdate()。
You can use SharedPreferences to pass this information. 您可以使用SharedPreferences传递此信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.