Thanks for the example, it cleared some things up. But i'm still trying to
find the right PendingIntent to attach, with no success, nothing happens. I
made a service after the same model, and my line now looks like this:
rv.setOnClickPendingIntent(R.id.widgetLeft, PendingIntent
.getActivity(context, 0, new Intent(context,
WidgetService.class), 0));

Nothing in the service gets launched according to the debugger...

On Tue, Jun 9, 2009 at 6:54 PM, Mark Murphy <mmur...@commonsware.com> wrote:

>
> > i'm having a difficult time understanding the right way to do this. To
> > put it simply, i want to generate a reaction within my own widget
> > (e.g. i press a button so a TextView changes) - i don't want to launch
> > a separate activity.
> >
> > Here's some code from my onReceive function (from the widget):
> >
> > mRemoteViews.setOnClickPendingIntent(R.id.widgetLeft, whatToPutHere);
> >
> > R.id.widgetLeft is a button. Is there something i can put as a
> > PendingIntent that would trigger that same onReceive function? Is the
> > only way to do this through a separate service?
>
> It doesn't have to be a separate service, but it does have to be a
> PendingIntent.
>
> If you hop out to
>
> http://commonsware.com/AdvAndroid/
>
> and download the source code to my one book, you will find a TwitterWidget
> project. As the name suggests, this puts the latest tweet in your timeline
> in a widget.
>
> The widget also has a refresh button which, when clicked, triggers the
> same behavior as when the updateTimeMillis time elapses, to get the latest
> stuff from Twitter. To do that, I use a PendingIntent that raises a
> broadcast Intent back to my AppWidgetProvider. That means I only have one
> service rather than two.
>
> In my case, I cheated a bit, and used the null action as indicating a
> manual refresh.
>
> For a more flexible solution, create a custom action that your existing
> AppWidgetProvider can watch for, register it in your manifest, and process
> that action when it arrives, updating your TextView.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com
> _The Busy Coder's Guide to Android Development_ Version 2.0 Available!
>
>
>
> >
>


-- 
Teo (a.k.a. Teominator a.k.a. Teodor Filimon)
site www.teodorfilimon.com | blog www.teodorfilimon.blogspot.com
GMT +2

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