Scenario :
I open my app by clicking icon, do something, navigate through activities, pause the app by clicking home button.
Case 1:
If I open my app by clicking icon again, the app restarts from the first activity.
Case 2:
If I open my app from recently open apps (in 4.0 by pressing menu button and selecting my app) it starts from the paused state.
I want the behavior 2 always to occur, don't want my app to restart every time when it is opened by clicking icon.
I have compared my manifest file with other apps and they are similar to mine, but behave differently (i.e like 2nd case which i want).
Edit:
This has been asked here : App completely restarting when launched by icon press in launcher
but no answers :(
Option 1: Freeze Apps Open “Settings” > “Applications” > “Application Manager“. Choose the app you wish to freeze. Select “Turn off” or “Disable“.
It will call the onResume() method if the app is already in the stack. And if the app not in the stack then it will call the onCreate() method. This mechanism is based on the launchMode specified for the activity.
I found it. I had set a flag android:launchMode="singleTask"
in my activity flag. I deleted that code.
I also added onsaveInstance
method to all the activities in my code and it's working now!
Thanks :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With