One way that works pre API 11 is to start ActivityGameMain
first, then in the onCreate
of that Activity start your ActivitySplashScreen
activity. The ActivityGameMain
won't appear as you call startActivity too soon for the splash.
Then you can clear the stack when starting ActivityGameMain
by setting these flags on the Intent:
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
You also must add this to ActivitySplashScreen:
@Override
public void onBackPressed() {
moveTaskToBack(true);
}
So that pressing back on that activity doesn't go back to your ActivityGameMain
.
I assume you don't want the splash screen to be gone back to either, to achieve this I suggest setting it to noHistory
in your AndroidManifest.xml
. Then put the goBackPressed
code in your ActivitySplashScreenSignUp
class instead.
However I have found a few ways to break this. Start another app from a notification while ActivitySplashScreenSignUp
is shown and the back history is not reset.
The only real way around this is in API 11:
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);