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

