How to restore previous activity after pressed home button and return to the app

the flow is like below.

  • MainActivity -> Second Activity
  • Press home key then device main screen shown.
  • Enter to app box and click the application icon.

I expect the second activity should be launched but main activity launched.

is there any way that I control it -?!


The default Android behaviour when you press the home button is that the current activity is pushed onto the stack, unless you called finish() in your activity. Whenever you open your application it will launch the activity that’s on top of your stack.

I’ts based on your system memory. If you don’t have enough memory to keep your activity backgrounded then Android will kill your activity and its state to recoup some memory. I’m thinking that perhaps your phone (or emulated device) is running short of memory.