I have an app that contains several activities…so lets say user is navigating activity stack A->B->C. Then presses the HOME button. Now when the user clicks on the Widget, I just want bring my app’s existing/current instance to the foreground. I do NOT want a new instance of the app. I want activity C to get back to foreground.
I tried launchMode to "singleTask" | "singleInstance" but that does NOT solve my desired requirement since it clears the current instance and creates a new one with activity A.
Any ideas how to solve this?
Thanks much!
I managed to figure out a solution. I set the specialized launch mode….
Every time the user clicks on the widget or the app icon again, the default activity A is started. To open the app up where it last was, inside the
onCreate()method in yourMainActivityclass just checkisTaskRoot(). If false, callfinish()and the activity A (MainActivity) will not appear and the app will open up to where it was in activity B.