Notification in android taking same intent on clicking. I am sending notifications after installing the theme. Consider I install 4 themes and 4 notifications appear in Noti
Used this code which worked for me.
int requestCode = new Random().nextInt();
PendingIntent contentIntent = PendingIntent.getActivity(this, requestCode,
notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
I had the same issue, and the problem is that Android is being a little too smart and giving you the same PendingIntents instead of new ones. From the docs:
A common mistake people make is to create multiple
PendingIntentobjects withIntents that only vary in their "extra" contents, expecting to get a differentPendingIntenteach time. This does not happen. The parts of theIntentthat are used for matching are the same ones defined byIntent.filterEquals. If you use twoIntentobjects that are equivalent as perIntent.filterEquals, then you will get the samePendingIntentfor 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.