Reputation: 824
Using just the default way of displaying GCM notifications (and not using onMessageReceived() and GcmListenerService), is it possible to have the activity stack remain as it was and just bring the app to the foreground when a notification is touched? I'd like to get the same behavior as when the app icon is touched. Currently a new activity is launched each time a notification is touched.
Edit:
Here's the situation in detail. I've read that documentation but I'm still not able to get the desired behavior. Let's say my stack looks like this:
Activity B
Activity A
Activity B is currently on top and active. When the user pressed the circle button and then the app icon again, the same stack gets activated (resumed).
Now when touching on a notification in this situation I get this:
Activity A
Activity B
Activity A
But I'd like to just preserve this:
Activity B
Activity A
I've tried all launchMode variants but had no success.
Upvotes: 0
Views: 110
Reputation: 8680
It has more to do with the way your activity is set up. For example, you can make your activity a singleTop
activity in your manifest:
<activity
...
android:launchMode="singleTop"
...
/>
This way when there's a new Intent
for this activity, Android OS will not make a new instance of your activity, but rather pull up the existing instance and pass the new Intent
through the onNewIntent(Intent)
function (to make it work, you should override that method in your activity).
There are more ways to do this, check out documentation (the "Using the manifest file" section) to see what's the best fit for your scenario.
Upvotes: 1