I have a notification that when pressed should launch an activity that in turn launches a dialog box. That all works, but the dialog box pulls info from the notification thought Intent.putExtra(). The problem is, it always pulls the latest information from the putExtra, so if a user clicks a more recent notification, they get info from the older one. Is there a way to dictate which putExtra goes with which notification?
Here’s the code I’m using:
ID is an int and UserText is a string:
Intent notificationIntent = new Intent(this, DialogActivity.class);
notificationIntent.putExtra("Text", UserText).putExtra("NotifyID", ID);
And in the DialogActivity
Bundle extras = getIntent().getExtras();
String test;
int NID;
if (extras != null) {
test = extras.getString("Text");
NID = extras.getInt("NotifyID");
}
The problem is that those are always the “Text” and “NotifyID” from the first notification no matter what notification the user selects.
Use
removeExtra. In your case: