Thank you very much, it runs good. Charles
On May 7, 4:19 pm, Jeff Sharkey <[email protected]> wrote: > First, remember that PendingIntents may not be unique w.r.t extra > bundles, which is why you want to use the setData() Uri. > > In the Activity or Service that you trigger with the PendingIntent, > you can use getIntent().getData() to read back the Uri used to launch > it, which includes any data you set when building thewidgetupdate. > > Here's an example where I used the setData() approach to sharing the > appWidgetId. When opening the forecast details page, you need to know > the sourcewidgetthe user clicked on: > > http://code.google.com/p/android-sky/source/browse/trunk/Sky/src/org/... > > http://code.google.com/p/android-sky/source/browse/trunk/Sky/src/org/... > > j > > > > On Thu, May 7, 2009 at 2:58 AM, Carlos <[email protected]> wrote: > > > Ok. > > But how to find the id to join it in the intent? > > > When i update mywidget, i do : > > updateViews.setOnClickPendingIntent(R.id.widget, pendingIntent); > > the pendingintent has an extra value with thewidgetid. How to get > > thewidgetid? > > > Charles > > > On May 7, 12:25 am, Jeff Sharkey <[email protected]> wrote: > >> When building thewidgetupdate, you can pack the appWidgetId into the > >> PendingIntent. Through the setData() Uri usually works best. > > >> j > > >> On Wed, May 6, 2009 at 12:18 PM, Carlos <[email protected]> wrote: > > >> > Hello, > > >> > I have awidgetlike the jeff's example. > >> > And i don't understand how to identify eachwidget(same type). > >> > getAppWidgetIds() returns a tab, how to catch the good id when i touch > >> > mywidget 1 or mywidget 2? > >> > Do you know a solution? > > >> > Charles > > >> > On Apr 23, 12:05 am, Al <[email protected]> wrote: > >> >> That worked, thanks. > > >> >> On Apr 22, 7:36 pm, Tom Gibara <[email protected]> wrote: > > >> >> > That's true, but notice that his service has no dependency on the > >> >> > class > >> >> > implementing the onUpdate method, 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 <[email protected]> > > >> >> > > In Jeff's example, the service is started from his onUpdate method, > >> >> > > which is called by AppWidgetProvider. This is different from what > >> >> > > I'd > >> >> > > like to do, I'd like to push an update to thewidgetfrom inside my > >> >> > > activity, but with the correct int[] values. > > >> >> > > On Apr 22, 7:16 pm, Tom Gibara <[email protected]> wrote: > >> >> > > > Yes, you can push updates to 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. > > >> >> > > > // Push update 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 updateAppWidget method (which doesn't take > >> >> > > > an > >> >> > > array > >> >> > > > of ids, but updates allwidgetinstances identically). > > >> >> > > > Jeff's blog post is at: > > >> >> > > >http://android-developers.blogspot.com/2009/04/introducing-home-scree... > > >> >> > > > Tom. > > >> >> > > > 2009/4/22 Al <[email protected]> > > >> >> > > > > 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? > > >> -- > >> Jeff Sharkey > >> [email protected] > > -- > Jeff Sharkey > [email protected] --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

