Android Multiple Notification sending same data on clicking
I had the same issue, and the problem is that Android is being a little too smart and giving you the same PendingIntent
s instead of new ones. From the docs:
A common mistake people make is to create multiple
PendingIntent
objects withIntent
s that only vary in their "extra" contents, expecting to get a differentPendingIntent
each time. This does not happen. The parts of theIntent
that are used for matching are the same ones defined byIntent.filterEquals
. If you use twoIntent
objects that are equivalent as perIntent.filterEquals
, then you will get the samePendingIntent
for both of them.
Modify your code as follows to supply a unique requestCode
:
// ...
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, packageName.hashCode(), intent, 0);
// ...
This will ensure that a unique PendingIntent
is used, as opposed to the same one.
Note that hashCode()
may not be unique, so if possible use another unique integer as the requestCode
.