Is there a way to push an update to a widget from another activity?
It seems like in order to use the AppWidgetManager.updateAppWidget
method, it has to be within the widget code itself?  Can i push an
update to the widget from the app personally?  I tried this and it
didn't do anything

    // Push update for this widget to the home screen
            ComponentName thisWidget = new ComponentName(this,
WordWidget.class);
            AppWidgetManager manager = AppWidgetManager.getInstance
(this);
            manager.updateAppWidget(thisWidget, updateViews);

For example, if I have a calendar app that has a calendar widget..how
do i push changes to the widget if I update an event on the calendar?
I have been looking at the calendar and calendar widget code but I
have yet to figure out how to do this.

Thanks.

On Jun 8, 12:14 am, Teo <teomina...@gmail.com> wrote:
> I've got a related question (or i'm not getting this right). The way i
> see it, onReceive can be used to handle interface events, but what
> pending intent do i need to attach to a button so that onReceive can
> be triggered?
>
> Thanks,
> Teo
>
> On Apr 23, 1:05 am, Al <alcapw...@googlemail.com> wrote:
>
>
>
> > That worked, thanks.
>
> > On Apr 22, 7:36 pm, Tom Gibara <m...@tomgibara.com> wrote:
>
> > > That's true, but notice that his service has no dependency on the class
> > > implementing the onUpdatemethod, in principal anything in the application
> > > could invoke that service. You'll find the appwidgetids available via the
> > > getAppWidgetIds() on AppWidgetManager.
> > > Tom.
>
> > > 2009/4/22 Al <alcapw...@googlemail.com>
>
> > > > In Jeff's example, the service is started from his onUpdatemethod,
> > > > which is called by AppWidgetProvider. This is different from what I'd
> > > > like to do, I'd like topushan update to thewidgetfrom inside my
> > > > activity, but with the correct int[] values.
>
> > > > On Apr 22, 7:16 pm, Tom Gibara <m...@tomgibara.com> wrote:
> > > > > Yes, you canpushupdatesto your widgets any time by obtaining an
> > > > > AppWidgetManager.
> > > > > Jeff Sharkey posted an example that performs an update within a 
> > > > > Service.
> > > > It
> > > > > includes this code that might help.
>
> > > > >             //Pushupdate for thiswidgetto the home screen
> > > > >             ComponentName thisWidget = new ComponentName(this,
> > > > > WordWidget.class);
> > > > >             AppWidgetManager manager =
> > > > AppWidgetManager.getInstance(this);
> > > > >             manager.updateAppWidget(thisWidget, updateViews);
>
> > > > > The relevant methods you are looking for are on the AppWidgetManager
> > > > class.
> > > > > In this case everywidgetis being updated in the same way so this code
> > > > > takes advantage of the updateAppWidgetmethod(which doesn't take an
> > > > array
> > > > > of ids, butupdatesallwidgetinstances identically).
>
> > > > > Jeff's blog post is at:
>
> > > > >http://android-developers.blogspot.com/2009/04/introducing-home-scree...
>
> > > > > Tom.
>
> > > > > 2009/4/22 Al <alcapw...@googlemail.com>
>
> > > > > > Depending on what I do in my application, I might want to force an
> > > > > > update on mywidget. I've have had a poke around and can't seem to
> > > > > > find any API for doing a manual update. At the moment, I have a
> > > > > > function that sends a broadcast and my onReceive does this:
>
> > > > > >       �...@override
> > > > > >        public void onReceive(Context context, Intent intent) {
>
> > > > > >                String action = intent.getAction();
>
> > > > > >                if (action != null && action.equals(UPDATE_ACTION)) {
> > > > > > //internal
> > > > > > static string
> > > > > >                        onUpdate(context,
> > > > > > AppWidgetManager.getInstance(context), new int[]
> > > > > > { 0 });
> > > > > >                }
>
> > > > > >                else {
> > > > > >                        super.onReceive(context, intent);
> > > > > >                }
> > > > > >        }
>
> > > > > > Is there a proper way to do this, which sents the int array to the
> > > > > > correct values? Or do I have to do it like this instead?
--~--~---------~--~----~------------~-------~--~----~
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