I have an application that has an initial activity (A - also the one specified in the launcher) from which it allows the user to launch another activity (B). I am saving the state of Activity B (onSaveInstanceState() and restoring it in onCreate()).
On some phones (N1 and Motrola Milestone as of now but not the Galaxy S) after launching B if the user presses the home button (i.e. app goes to background) and then immediately re-launches the app, they are shown activity A again (not B). But if they launch it from the 'Recent' apps (Home button long press) they are taken to the activity B.
From what I understand of the Android docs, unless the task has been killed (doesnt seem like the case here as nothing else is done except re-launch the activity from the app screen) we should see activity B restored on launch (as that is on top of the stack). So I just can't seem to figure out what the heck is wrong here.
BTW orientation changes during app usage works fine (everything saves and restores fine). This weird problem has been bugging me for some time now and by trial and error I discovered that when I disabled orientation for that activity and then trying the re-launching got B to show as expected.
So has anyone else faced something like this and if so how can this be resolved?
I am looking into saving the running activity in SharedPreferences (as mentioned in this post) and they restoring it from that in activity A, however would like to know if I am missing something here. Shouldn't having B restored on re-launch be the default behavior?