Kostya,

Gee, I hope I'm not revealing my ignorance here...

I build my RemoteViews in an IntentService.  I suppose I have to find a
way to pass the widgetid into the Intent that is used to start the
service.  If the service knows the widgetid, it can putExtra that
widgetid into the Intent used to start the Preference Activity.

So now the question is how to get widgetid ID from the AppWidgetProvider
to the IntentService.  onUpdate() is passed the appWidgetIds that need
to be updated.  I, however, do not use that method for anything.
Instead, I use alarms to trigger my updates since I am updating every 60
seconds in one instance or every 24 hours in another.  Currently my
alarms send an Intent that is processed by the AppWidgetProvider's
onReceive() method.  That method does not get a widgetid.  Any idea how
I can get the set of widgetids to be updated if Android has no passed it
to me in onUpdate?

...Jake


>>>>> "KV" == Kostya Vasilyev <[email protected]> writes:

   KV> Jake,

   KV> You have the widget id where you're building your RemoteViews and
   KV> setting the PendingIntent for the click.

   KV> So the only thing is how to get the widget id into the
   KV> PendingIntent, so you can retrieve it later in the config
   KV> activity.

   KV> Probably the easiest way is to use the same extra,
   KV> AppWidgetManager.EXTRA_APPWIDGET_ID, as used for new widgets. Or
   KV> some other, as you see fit.

   KV> To make sure that you get multiple PendingIntent objects, each
   KV> with its own widgetId, you can use unique reqestId values with
   KV> PendingIntent.getActivity, such as the widget Id itself.

   KV>     Intent intent = new Intent(context, WidgetConfigActivity.class);
   KV>     intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
   KV>     PendingIntent pending = PendingIntent.getActivity(context, widgetId,
   KV> intent,
   KV>             PendingIntent.FLAG_UPDATE_CURRENT);
   KV>     updateViews.setOnClickPendingIntent(R.id.widget_top_level,
   KV>     pendingIntent);

   KV> Might be a good idea to cancel unneeded pending intents somewhere
   KV> in Widget.onDeleted.

   KV> -- Kostya

   KV> 03.05.2011 17:12, Jake Colman пишет:

   >> Kostya,
   >> 
   >> I've been noodling around thinking about this problem while
   >> working on other features but I'm stumped on one part of it.  When
   >> the Preference Activity is launched as a Configuration Activity
   >> the intent contains widget ID.  But I can also launch the same
   >> Activity if the user touches the widget so that the user can
   >> reconfigure the widget even after it has been installed. In that
   >> situation, how can I know which widget is being reconfigured?  The
   >> widget ID is not part of the widget itself so I don't how I can
   >> grab the ID of the specific widget that is being reconfigured.
   >> 
   >> ...Jake
   >> 

   KV> -- 
   KV> Kostya Vasilyev -- http://kmansoft.wordpress.com

   KV> -- 
   KV> You received this message because you are subscribed to the Google
   KV> Groups "Android Developers" group.
   KV> To post to this group, send email to [email protected]
   KV> To unsubscribe from this group, send email to
   KV> [email protected]
   KV> For more options, visit this group at
   KV> http://groups.google.com/group/android-developers?hl=en

-- 
Jake Colman -- Android Tinkerer

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

Reply via email to