My service has a notification with an intent to launch the associated activity, but I find sometimes that when pressing back in my activity it returns to a previously loaded activity, so it looks like there are sometimes where there are more than one copy of the activity in memory. How can I avoid this? I suppose I must bring to front in case exist or launch a new one but dont know exactly how.
thanks.
My service has a notification with an intent to launch the associated activity, but
Share
In you
AndroidManifest.xmladdandroid:launchMode="singleTask"with the as attribute with the desire activity you want to run only 1 instance.e.g
You can even use
Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONTflag with you activity intent. So that when activity is already running it will be brought to front instead of creating new.