Thank you all, I have gotten this to work. Mark, I apologize, I didn't
quite understand what you were saying, but now I do. I was able to get
it working easily once I understood this.

You can also update the app widget from any class in your application,
like so:

AppWidgetManager appWidgetManager = AppWidgetManager.getInstance
(context);
RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.main);
// Perform updates on the view
appWidgetManager.updateAppWidget(new ComponentName(context,
TheWidgetProvider.class), views);

This was probably obvious, but I didn't understand it right away. You
can call this from anywhere, assuming you have a context. Thank you
all for helping me better understand something so simple.

-John

On Sep 27, 4:55 pm, Al <alcapw...@googlemail.com> wrote:
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to