The root of the issue is described here:

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 extras are not mentioned in as things that make a pending intent
unique.

Since your intent contains extras, use PendingIntent.FLAG_UPDATE_CURRENT so
that any new values are picked up.

Or use PendingIntent.FLAG_CANCEL_CURRENT as Dianne suggested to cancel the
current pending intent with the old extras and create a new one with new
values.

Or use a unique requestId (the parameter that's documented as not used).

Or use PendingIntent.FLAG_ONE_SHOT so the old pending intent is forgotten
after being fired, and the a pending intent is created the next time.

Or use intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))) to
give your intent a unique data Uri that contains the extras in an encoded
form.

-- K

2012/7/19 Matt Schoen <mtsch...@gmail.com>

> No, I did not.  Should I?  There are currently no flags on the intent.
>
>
> On Wednesday, July 18, 2012 10:33:46 PM UTC-4, Dianne Hackborn wrote:
>>
>> Did you use PendingIntent.FLAG_CANCEL_**CURRENT?
>>
>> On Wed, Jul 18, 2012 at 7:55 AM, Matt Schoen <mtsch...@gmail.com> wrote:
>>
>>> Hi there,
>>>
>>> I'm having an issue with an activity, which is started via a
>>> notification, which is spawned by an alarm.
>>>
>>> I've added debug outputs to determine whether the right data is being
>>> sent, and it is.  What's happening is this:
>>>
>>> The alarm fires, which picks a random entry from my database, and
>>> creates a notification with an intent starts an activity with that ID value
>>> as a bundle extra.  When this activity starts, the notification is
>>> cancelled.  The first time this all works like a charm.  However, the
>>> second time this alarm fires, it creates a new notification, and adds a
>>> different ID to the bundle extra (I'm sure of this since I print out the
>>> value of the variable).  However, when the new activity starts, it reads
>>> the OLD ID from the bundle extras.
>>>
>>> What gives?
>>>
>>> --
>>> 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 <android-developers@googlegroups.com>
>>> To unsubscribe from this group, send email to
>>> android-developers+**unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
>>> 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>
>>
>>
>>
>>
>> --
>> Dianne Hackborn
>> Android framework engineer
>> hack...@android.com
>>
>> Note: please don't send private questions to me, as I don't have time to
>> provide private support, and so won't reply to such e-mails.  All such
>> questions should be posted on public forums, where I and others can see and
>> answer them.
>>
>>  --
> 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
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to