EDIT : Found a solution to your problem in a somewhat random fashion today! See this bug report report . This exactly explains your problem. The reason I could not reproduce the problem is because Eclipse is not launching the application directly. I use Eclipse to install the application and then run it myself.
This is already the default behavior for Android applications; special tricks are not required to achieve this. I am surprised that your application does not exhibit this behavior. Each Android application supports an activity stack, literally represents a LIFO action stack. These actions can be grouped into tasks, but 99% of worldly applications will never know anything about tasks in my experience.
When you press the home button, the entire application stack is placed in the background. Although in the background it can be killed for memory problems at any time, but if it does not take a long time to restore it, it usually does not kill and does not need to be re-created. When you select an application again, the stack is restored (or, more precisely, only the top item in the stack).
If your application does not exhibit this behavior, I suspect it has something to do with how you start mainActivity and childActivity, and any additional Intent flags that you can use. Can you post code snippets about how you start mainActivity and childActivity?
sooniln
source share