The simple-but-underdocumented solution is to use the 2nd parameter to
getActivity(), getService(), etc. The "Private request code for the
sender" that is "currently not used" still results in unique
PendingIntents, based on various reports that I have seen, though I
have not yet had cause to use this myself.

A more cumbersome solution that does not rely upon quasi-documented
behavior is to generate a unique action string and add that to your
Intent. Assuming that you are setting the component on the Intent
(e.g., new Intent(this, MyActivity.class)), the action string will
have no effect on the routing of the Intent, but its uniqueness will
get you distinct PendingIntents.

On Thu, May 3, 2012 at 12:34 AM, Vadim Peretokin <[email protected]> wrote:
> I'm using my notifications as a method of launching an activity to the
> proper state it needs to be in. There can be several notifications that all
> need to launch the same activity, but in different states.
>
> The issue that I'm running into is that the PendingIntent is not being
> unique.
>
> I pass data via extras to the Intent (that does it's lookup via an alias
> string) for the notification, and with the default PendingIntent.getActivity
> with no extra flags passed, the first notifications Intents data ends up
> being an extra in the activity. So if I click on the 3rd notification,
> extras data from the first comes up.
>
> If I pass it the FLAG_UPDATE_CURRENT flag, then the 3rd notifications data
> comes through if I click on first or second. If I pass it FLAG_ONE_SHOT,
> then only one notification will work.
>
> So it's rather clear that the PendingIntent is the issue at hand - but I'm
> not sure how to avoid this kind of behaviour. Can anyone help?
>
> --
> 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



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

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