How to Prevent Accidental App Exit w/in Android Fragments/Activities?
How Do I Prevent Accidental App Exit w/in Android? IE: When the he/she presses the back button and reaches the last activity in the BackStack, show a toast to ask if the user wants to exit using the onBackPressed() method. Also, It needs to function with backStacks for fragments. This functionality can easily be implemented by overriding main activity's onBackPressed() method. In this example when user presses back button then the app will display a toast for 4 seconds on which time a new back press terminates the app immediately. ref You can put it in a BaseActivity that extends Activity like