Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

super.onUpdate() in AppWidgetProvider recommend?

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
    ...
  }
}

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[])

I also checked the Android sources (2.2 and 4.0):

http://grepcode.com/file/repository.grepcode.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.

Any recommendations on that?

like image 391
egore911 Avatar asked Oct 27 '25 06:10

egore911


1 Answers

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.

like image 124
CommonsWare Avatar answered Oct 28 '25 20:10

CommonsWare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!