2012/5/16 Skip Morrow <[email protected]>
> Koysta, thanks for replying!
>
> Are you saying that it isn't possible?
>
No, I'm not saying that.
> Because I have app widgets on my desktop right now that I have multiple
> instances of, and they all do something different when clicked.
>
Right.
>
> I've been trying to figure this one thing out for three days and for the
> life of me I can't crack the code.... *sigh*
>
The heart of the issue is creating distinct PendingIntent objects for
associating with distinct widgets.
There is a number of ways to do it:
1) By using a unique requestCode in PendingIntent.getBroadcast or
getActivity. The app widget id would do nicely.
2) By specifying a unique data URI in the Intents used to create your
PendingIntent objects
3) As a variation of 2, you can "serialize" the extras into this URI, like
this:
Intent intent = new Intent(context, StackWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
*intent**.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)))*
( taken from the app widget docs at
https://developer.android.com/guide/topics/appwidgets/index.html#implementing_collections
)
In this case, the intent would need to be "unserialized" on the receiving
side by using Intent.parse(String uri, int flags).
-- K
>
> On Wednesday, May 16, 2012 12:13:53 PM UTC-4, Kostya Vasilyev wrote:
>
>> http://developer.android.com/**reference/android/app/**PendingIntent.html<http://developer.android.com/reference/android/app/PendingIntent.html>
>>
>> >>>
>> If the creating application later re-retrieves the same kind of
>> PendingIntent (same operation, same Intent action, data, categories, and
>> components, and same flags), it will receive a PendingIntent representing
>> the same token
>> <<<
>>
>> Note that the list of things making an intent unique does not mention
>> extras.
>>
>> -- K
>>
>> 2012/5/16 Skip Morrow
>>
>>> I am trying to create an AppWidget that allows for independently
>>> configured multiple instances. I can create the AppWidgets just fine, but
>>> when I click on them, they always want to do the same thing. So I have
>>> searched high and low, and everyone talks about putting the appWidgetId in
>>> an extra in the intent. I have tried that, but even the extras come in all
>>> the same. They always hold the appWidgetId for the lat-added widget. Here
>>> is a post where someone supposed ly it this way:
>>> http://stackoverflow.com/**questions/4225197/android-**
>>> multiple-appwidgets-playing-**diferent-sounds<http://stackoverflow.com/questions/4225197/android-multiple-appwidgets-playing-diferent-sounds>.
>>> I have posted on StackOverflow, trying to get some help, but no one has
>>> responded ( http://stackoverflow.com/**questions/10607518/android-**
>>> appwidget-multiple-instances<http://stackoverflow.com/questions/10607518/android-appwidget-multiple-instances>).
>>> I was hoping that someone here could point me to some actual complete
>>> working code that I can look at and see where I am missing something.
>>> Please? :)
>>>
>>> --
>>> 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 <[email protected]>
>>> To unsubscribe from this group, send email to
>>> android-developers+**[email protected]<android-developers%[email protected]>
>>> For more options, visit this group at
>>> http://groups.google.com/**group/android-developers?hl=en<http://groups.google.com/group/android-developers?hl=en>
>>>
>>
>> --
> 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
>
--
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