Skip to content Skip to sidebar Skip to footer

Start New Activity When User Click "back" From Another Activity

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 las

Solution 1:

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
publicvoidonBackPressed() {
   Intent setIntent = new Intent(ActivityA.this, Splash2.class);
   startActivity(setIntent);
   finish();
}

Solution 2:

You can just override finish() method, adding startActivity.

Solution 3:

As simple as

  1. call your activity A from splash with startActivityForResult method without calling finish

  2. override onActivityResult of splash to show the end splash screen

Solution 4:

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.

@OverridepublicbooleanonKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK)) {
        startActivity(newIntent("com.android.splashscreen"));
        finish();
    }
}

Create and start your end-splashscreen.

Solution 5:

over ride method of Activity A onBackPressed(). Inside this you can start your splash screen 2/END activity.

Post a Comment for "Start New Activity When User Click "back" From Another Activity"