Background
I have a very weird situation that i've never seen on any app i've created .
The app has multiple activities , while the first one is used for some initializations and for the splash screen .
The problem
Suppose the app has the activities "A", "B", "C" ,... , and the end user goes from "A" (the first one , of the splash screen) to "B" , and then presses the home key , and returns to the app by clicking its icon on the launcher .
In short ,scenario is :
app launched -> activity A (splash) -> activity B -> pressed on home -> returned to app (via the launcher) -> ?
Expected result : the app should return to the last activity that was shown , meaning that "?" = activity B
The actual result : the app actually returned to activity "A" , meaning that "?" = activity A , and after that , to the activity that i've left it (in this case , B )
There is not much to show in both the manifest and the code , since they are all very standard .
Clues for solving the problem
However , there are some clues that might tell something about the cause of this:
each activity might take some memory for showing images, but they are not taking a lot.
all activities extend from the roboSherlock activities variants , including the splash screen activity that extend from RoboSplashActivity .
On the first activity (the splash screen) , i didn't let the call to super.andFinishThisOne(); within the andFinishThisOne method , since i need to initialize more things other than the roboguice injections . However , when everything is ready , i start the new activity and closes the current one using finish() .
There is a bug report (here) that describes a similar scenario . Not sure how similar , and what can be done to handle it.
What i've tried so far
I've tried the next solutions so far:
Playing with different flags and properties for the first activity (mainly the launchMode ) in the manifest but none helped the situation.
used startActvityForResult on the splash screen activity , without calling finish() . it also didn't work and re-created the activity .
for now , i've simply added the next code to skip the first activity in case it's not the root activity , but that's more like a workaround than a real solution.
if (!isTaskRoot()) {
finish();
return;
}