Q:

WidgetProvider Intent extras sent with button click not found in onReceive

I am trying to detect when widget button is clicked but none of the Intent extras are showing up in the onReceive method.
onReceive gets called with every click but none of my Intent extras show up.
My code is below:  I only hook up the toggle button in on update so not sure if this is correct.  None of the extras show up and categories are null even though I set this.
onUpdate(Context context etc):
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), 
                                R.layout.my_widget);

Intent buttonIntent = new Intent(context, MyWidgetProviderClass.class);
buttonIntent.setAction(ACTION_WIDGET_RECEIVER);
buttonIntent.putExtra("BUTTON_CLICKED", "buttonClick");
buttonIntent.putExtra("BUTTON",899);

PendingIntent muPendingIntent = PendingIntent.getBroadcast(context, 0, 
                                        buttonIntent, 
                                        PendingIntent.FLAG_CANCEL_CURRENT);
buttonIntent.addCategory("buttonclick");
remoteViews.setOnClickPendingIntent(R.id.ToggleImageButton, myPendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);

onReceive():
intent.getIntExtra("BUTTON",-1);    ---> 1
intent.getCategories()   --- > null

A:

Try FLAG_UPDATE_CURRENT instead of FLAG_CANCEL_CURRENT.
Also, your code may have a typo: you have muPendingIntent instead of myPendingIntent.
Also also, please do not use buttonclick as a category. Please namespace it (e.g., com.something.whatever.buttonclick), or remove it, as I am not sure why you would need it.
Here is a sample project demonstrating an app widget that, on a click, triggers an update on itself, with an extra (used to supply the app widget IDs).

