Created
August 12, 2016 14:25
-
-
Save Jamp/d27dde6fcb796fbd602f463f07469dc3 to your computer and use it in GitHub Desktop.
Cliquear 2 veces para salir de una aplicación
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boolean doubleBackToExitPressedOnce = false; | |
@Override | |
public void onBackPressed() { | |
if (doubleBackToExitPressedOnce) { | |
super.onBackPressed(); | |
return; | |
} | |
this.doubleBackToExitPressedOnce = true; | |
Toast.makeText(this, "Please click BACK again to exit", Toast.LENGTH_SHORT).show(); | |
new Handler().postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
doubleBackToExitPressedOnce=false; | |
} | |
}, 2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment