Reputation: 82
Here is the problem: I am displaying notifications just fine, if I send 3 notifications I am able to see all 3 of them. However, regardless of which notification I hit or if I open the app. It will always do the action of the last notification, and it discards the older wants.
What I want it to do is on it/open app, start with the newest one and proceed to the older ones.
Do I have to deal with this using just logic? or is there a method like using pending intents that I could use?
I do not necessarily need the code to fix this, just an explanation on how to approach this could do :)
Upvotes: 2
Views: 248
Reputation: 1678
The problem lies here:
PendingIntent resultPendingIntent =
PendingIntent.getActivity(mCtx, NOTIFICATION, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Check if the requestCode
which you are passing via NOTIFICATION
is different for each PendingIntent
or not.
PendingIntent.FLAG_UPDATE_CURRENT
updates PendingIntent
with the new Intent
for a given requestCode
.
I think, whats happening in your case is, you are passing same value for requestCode
in PendingIntent.getActivity()
method, which means you are giving same id to all the 3 Intents
, and since you have specified a flag PendingIntent.FLAG_UPDATE_CURRENT
, android will update Intent
for all the Pending Intents with last provided Intent.
Try to specify different requestCode
for different PendingIntent
s. I think this should do the trick for you.
Upvotes: 1