I have splash screen in an application. When user is at home screen and presses the back button; an alert dialog with “Do you want to exit?” is appeared and if users slects OK then moveTaskToBack(true); is called: and the app will exit. But on immediate launch of the application the splash screen is not shown. How to show splash screen on every launch of the application?
I have splash screen in an application. When user is at home screen and
Share
A few pointers on how to make a splash screen.
Say we have
SplashActivityandHomeActivity.SplashActivityshould be your launcher activity (in the manifest).When you start
HomeActivityyou should callfinish()onSplashActivityso that you wouldn’t return to it upon clicking the back button.In
HomeActivitywhen you intercept the back button to show the dialog, don’t callmoveTaskToBack(true);on OK because this only moves your application to the background and doesn’t terminate it.You should call
finish()instead. And since you already called finish onSplashActivity, the only activity left isHomeActivity, so your application will close.