How to avoid going back to the Splash Screen Activity on the press of Back Button? [SOLVED] – Android Studio

To prevent the user from going back to the splash screen on pressing the ‘back’ button, just add the following line to the splash screen activity, in your AndroiManifest.xml:


This attribute will prevent the splash screen from going to the stack, and thus it won’t be displayed at t he press of the ‘back’ button.

You could also do this programatically, by calling finish(); after calling startActivity to start the MainActivity.

public void onClick(View v) {
    Intent intent = new Intent(Main.this, Splash.class);

Reference: Stack Exchange

PhD researcher at Friedrich-Schiller University Jena, Germany. I'm a physicist specializing in theoretical, computational and experimental condensed matter physics. I like to develop Physics related apps and softwares from time to time. Can code in most of the popular languages. Like to share my knowledge in Physics and applications using this Blog and a YouTube channel.
[wpedon id="7041" align="center"]

Leave a Reply

Your email address will not be published. Required fields are marked *