Question

I'm a bit confused with pending intents in the notification builder. I've got a MainActivity activity and a MessageList activity. I have a service to show a notification when a new message in found, and I want it to be that if the user presses the notification it opens to the MessageList activity but when they press back they will return to the activity they were in.

Essentially I want to add MessageList activity to the top of the activity stack when they press the notification without modifying the current activity stack.

Thank you

Was it helpful?

Solution

Okay, so I got it to work with some old code I wrote a while back. This does what I wanted -

Intent notificationIntent = new Intent(this, AlertListActivity.class);

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

mBuilder.setContentIntent(contentIntent);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top