According to Android docs:
http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html
"When the user leaves a task by pressing the Home button, the current activity is stopped and its task goes into the background. The system retains the state of every activity in the task. If the user later resumes the task by selecting the launcher icon that began the task, the task comes to the foreground and resumes the activity at the top of the stack."
If I understand this correctly, this means:
- Activity A as MAIN Activity.
- Activity B that gets started in A, through "startActivity" - common, plain intent instance.
- I open app for first time, A gets loaded.
- I click on button in A and B is openend.
- I press home button.
- I open app again, for 2nd time, and B is expected to be shown
...right? I suppose this is the correct behavior to expect...
However, I am not seeing this in my app.
If I hit "Home button" and then resume my app, by pressing the launcher icon, it will start with the main activity - not the one at the top or latest one.
I am coding on a Samsung Galaxy Tab Android 2.2.1 - I have the most common options in the Android manifest - thing is that I handle like 10 different activities with different intent extras - and a Dispatcher class approach - or save each activity state - sounds quite demanding.
I am using Eclipse IDE with ADT version 12; and I found something very interesting:
When I run the app from the Eclipse IDE, with my device connected, I don't see this behavior. The app behaves as stated in the docs. In fact, I saw this only after I deployed my apk at the Google Play app repository; and downloaded it to test.
My question is, has anybody found the real reason why is this happening? Is the documentation wrong? or missing something? Is this a bug on Android?
Another research I have done is:
When I try my app, downloaded from the google play, as APK, if I enter my app for the 2nd time, I get the "main" activity instead of the last one openend. I press home. After pressing home, I enter application management settings for android, locate my app and click on "force stop". After doing this, the app behaves as stated in the docs.
Somebody help! :)