super.onUpdate()在AppWidgetProvider建议? [英] super.onUpdate() in AppWidgetProvider recommend?
问题描述
我想,如果在调用super.onUpdate(弄清楚)正在开发一个AppWidgetProvider时推荐。
I'm trying to figure out if calling super.onUpdate() is recommend when developing an AppWidgetProvider.
public class MyAppWidgetProvider extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
// My code starts here
...
}
}
我不知道,因为它需要调用super.onCreate开发一个活动时,()。但我找不到在JavaDoc类似的事情:
<一href=\"http://developer.android.com/reference/android/appwidget/AppWidgetProvider.html#onUpdate(android.content.Context\" rel=\"nofollow\">http://developer.android.com/reference/android/appwidget/AppWidgetProvider.html#onUpdate(android.content.Context, android.appwidget.AppWidgetManager,INT [])
I'm wondering because it is necessary to call super.onCreate() when developing an Activity. But I can't find anything similar in the JavaDoc: http://developer.android.com/reference/android/appwidget/AppWidgetProvider.html#onUpdate(android.content.Context, android.appwidget.AppWidgetManager, int[])
我也查了Android源(2.2和4.0):
I also checked the Android sources (2.2 and 4.0):
<一个href=\"http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/2.2_r1.1/android/appwidget/AppWidgetProvider.java\" rel=\"nofollow\">http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/2.2_r1.1/android/appwidget/AppWidgetProvider.java
现在的方法不执行任何操作,但也许会做在以后的版本的东西。我认为它应该是安全的,现在要添加调用方法,也为将来的版本中是安全的。
Right now the method does nothing, but maybe it will be doing something in future releases. I think that it should be safe to add the call to the method now and also be safe for future releases.
上任何建议?
推荐答案
它不会伤害叫的onUpdate()
这里,而且,正如你所说的,它可能有未来价值。话虽这么说,我相信有很多,很多开发商的不的调用的onUpdate()
,所以如果Android的移动,使得链接到在超的onUpdate()
是非常关键的,我希望谷歌会从山顶上喊吧。
It does not hurt to call onUpdate()
here, and, as you say, it may have future value. That being said, I am sure that there are many, many developers not calling onUpdate()
, and so if Android shifts such that chaining to the superclass in onUpdate()
is critical, I hope Google will shout it from the mountaintops.
这篇关于super.onUpdate()在AppWidgetProvider建议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!