I have an activity that is being opened from the notification bar, but when I do NotificationManager.notify(...)
, I'm giving to the intent a different bundle, so that each notification opens the same activity, but obtaining from the DB other information each other.
But when I try to enter to any of the notifications (for example there are 3 notifications), they all send me to the activity with the same bundle that the last one. After trying with some Flags, I really don't know where is the problem (some flags makes the notification enter to the activity with the first bundle).
I'm following the way they used it in the tutorial.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.
If the PendingIntent has the same operation, action, data, categories, components, and flags it will be replaced.
Depending on the situation i usually solve this by providing a unique request code either as static values (0,1,2) or the row id of the data I'm receiving from the DB.
PendingIntent.getActivity(context, MY_UNIQUE_VALUE , notificationIntent, PendingIntent.FLAG_ONE_SHOT);
Then I use the same unique value for notify() as
mNotificationManager.notify(MY_UNIQUE_VALUE, notification);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With