I have a splash screen activity at the startup of app.
the startup splash screen has finish(), so user will not see startup splash screen anymore when they press BACK from the last remain activity. But instead of app directly exit, I want the app show a exit splash screen which has different images than startup splash screen, after that the app will directly end.
So I want it to be like this :
Splash screen 1(Beginning) -> Activity A -> Activity B -> (Press Back) -> Show Activity A -> (Press Back Again) -> Splash screen 2 (End)
How to do that?
Do I have to override back button on Activity A or there's another method to show new activity when user press back button on Activity A ?
Why don't you override back button on Activity A with starting activity code for Splash 2? I think this is the only solution.
For example:
@Override
public void onBackPressed() {
Intent setIntent = new Intent(ActivityA.this, Splash2.class);
startActivity(setIntent);
finish();
}
You can just override finish() method, adding startActivity.
Depending on when you want the user to exit. If it's only in Activity A, you can simply override onKeyDown in that one, otherwise override it in each Activity you got.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
startActivity(new Intent("com.android.splashscreen"));
finish();
}
}
Create and start your end-splashscreen.
over ride method of Activity A onBackPressed()
. Inside this you can start your splash screen 2/END activity.