Notification PendingIntent Intent extras are overridden by another notification
android, android-intent, android-pendingintent, notifications
Solution
There are two ways to solve this:
One is to set a different action on the Intent. So in your example, you could set `Intent1.setAction("Intent1")` and `Intent2.setAction("Intent2")`. Since the action is different, Android will not override the extras on the intent.
However, there may be a case where you actually need to set a specific action on this intent (i.e. your action corresponds to a specific broadcast receiver). In this case, the best thing to do is set the request code to something different in each PendingIntent:
PendingIntent pendingIntent1 = PendingIntent.getActivity(context,
(int) System.currentTimeMillis() /* requestCode */, intent1,
PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pendingIntent2 = PendingIntent.getActivity(context,
(int) System.currentTimeMillis() /* requestCode */, intent2,
PendingIntent.FLAG_UPDATE_CURRENT);
By setting a new request code on the PendingIntent, Android will not override the extras on each of their corresponding intents.
Problem
When creating a new notification with a new PendingIntent, the extras in its intent override any previous notification's PendingIntent Intent extras. For example, lets say I create Notification1 with PendingIntent1, which has Intent1 and its extras. When I create Notification2 with PendingIntent2, which has Intent2 with its own different extras, Intent1 will now have the same extras as Intent2. Why is this happening? How do I work around this?