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 computational material science. I write efficient codes for simulating light-matter interactions at atomic scales. I like to develop Physics, DFT and Machine Learning 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 *