Search code examples
androidsplash-screen

Android: 'Splash screen' only once


I have a Android application that requires a splash screen. I have a simple activity which shows the splash screen and after a number of seconds, it starts the 'main' activity. Now, when a user presses the back button from that activity, the splash screen shows again. How can I prevent this? I tried keeping a boolean shownSplash and this partially works, but when the app is running and the user wants to open it from the app-launcher, the app exits (since splash calls finish() when splashShown is true). Any ideas?

Thanks, Erik


Solution

  • Set android:noHistory="true" to the activity entry at the AndroidManifest.xml. That will prevent the activity from being saved on the stack.