Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onUpdate not being called in widget, even though I see the android.appwidget.action.APPWIDGET_UPDATE intent in onreceive

I'm working with the emulator using the debugger and I've noticed that onUpdate() is not getting called. When I add the widget to the emulator homescreen I see my breakpoint being hit in the onReceive method. The onReceive() method does get the android.appwidget.action.APPWIDGET_UPDATE intent. However, the onUpdate() method never gets called. I believe it's defined correctly.

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,int[] appWidgetIds)  {
    // code that sets up remove view and updates appWidgetManager
}
like image 793
JonF Avatar asked Jul 14 '10 04:07

JonF


1 Answers

Call the super class method in onReceive()

@Override
public void onReceive(Context context, Intent intent)
{
    // Chain up to the super class so the onEnabled, etc callbacks get dispatched
    super.onReceive(context, intent);
    // Handle a different Intent
   Log.d(TAG, "onReceive()" + intent.getAction());

}

If you override onReceive() in your subclassed AppWidgetProvider, then the provider's onEnabled, onUpdate, etc callbacks are not triggered unless you call the superclass.

like image 151
Andy Lawton Avatar answered Sep 19 '22 09:09

Andy Lawton