You need to create a pending intent which will send an event to your widget,
then handle that event in your widget
Intent intent = new Intent(context, MightyToggleWidget.class);
intent.setAction("MY_HANDLE_BUTTON_EVENT_NAME");
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent,
0);
views.setOnClickPendingIntent(button, pendingIntent);
This will make the MY_HANDLE_BUTTON_EVENT_NAME event to be broadcast.
Now you need to handle this event in your AppWidgetProvider implementation
...To do this you need to tell Android O/S that your AppWidgetProvider will
handle the event, you do this by adding an entry in the <intent-filter>
section like so:-
<action android:name="MY_HANDLE_BUTTON_EVENT_NAME" />
Now you need to actually handle the event. You need to override
AppWidgetProvider's onReceive like so: -
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
if
(intent.getAction().equals("MY_HANDLE_BUTTON_EVENT_NAME"){
doSomething();
}
}
I hope this helps!
All the best,
Ash
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en