Search code examples
androidandroid-activityback-button

back button's function on first activity


Normally when the back button is clicked it goes to the previous activity and if the current activity is the first activity, the application closes.

I have a splash screen (that is logically my first activity) and then the menu activity loads.

I want to close the program when the back button is pressed on my menu activity (as if it is the first activity) and avoid going back to the splash screen again, but I know that I should not exit the program.

I was wondering what is the functionality of back button on the first activity? does it put the program to pause?


Solution

    1. Avoid splash screens !

    2. Instead of using your splash as the main activity, use menu activity as the main one, and in onCreate() chain off the splash activity, which will close and disappear forever.