0

I have a launcher ActivityA (launch mode - singleTask), that opens ActivityB on pressing a button. Now, I press the home button and open the application again. I see ActivityA but not ActivityB. I want the activity which is displayed before pressing the home button to be displayed even after re-opening the application.

Note: When I change the launcher mode for ActivityA to singleTop, then this problem gets fixed. But I can't use that launcher mode because of some other unrelated reason (I don't want to create another instance of the ActivityA).

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • did u try keeping activity b's launch mode as SingleTop ? – Aalap Patel Oct 20 '17 at 20:20
  • Have a look at this to understand how launch modes work::https://developer.android.com/reference/android/content/Intent.html – Barns Oct 20 '17 at 20:34
  • yeah, I have tried to launch activity B with singleTop and it does not help. :( – shilpa sarawagi Oct 24 '17 at 19:50
  • You do not need to use `singleTask` to solve your problem. If `ActivityA` is your root `Activity`, Android will not (generally) create another instance of it if it is launched again, it will just bring your existing task to the foreground. You need to back up and try to solve your problem using the standard launch modes. Please explain exactly the scenario where Android creates 2 instances of `ActivityA`. – David Wasser Nov 02 '17 at 13:45
  • You may be seeing this nasty Android bug: https://stackoverflow.com/a/16447508/769265 . To check if you are seeing that bug, kill your app (Settings->Apps->YourAp->Force Stop), then start your app by clicking the icon on from the HOME screen and see if the problem has gone away (ie: it shouldn't start 2 instances, even if you have no special launch mode). – David Wasser Nov 02 '17 at 13:48
  • Have you resolved your problem? Can you tell us what you did? – David Wasser Nov 28 '17 at 17:18

0 Answers0