I update my widget from within my app, when I delete/add entries to a
list. To do this, I have a method (updateWidget) and a static String
(UPDATE_ACTION). My updateWidget() method sends a broadcast which is
received by the widget class and then calls onUpdate() with the
appropriate params:

private void updateWidget() {
                Intent i = new Intent(this, TVWidget.class);
                i.setAction(TVWidget.UPDATE_ACTION);
                sendBroadcast(i);
        }

In TVWidget class:

@Override
        public void onReceive(Context context, Intent intent) {

                String action = intent.getAction();

                if (action != null && action.equals(UPDATE_ACTION)) {
                        final AppWidgetManager manager = 
AppWidgetManager.getInstance
(context);
                        onUpdate(context, manager,
                                        manager.getAppWidgetIds(new 
ComponentName(
                                                        context, TVWidget.class)
                                        )
                        );
                }

                else {
                        super.onReceive(context, intent);
                }
        }

This seems to work fine.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to