Skip to content

Instantly share code, notes, and snippets.

@Jamp
Created August 12, 2016 14:25
Show Gist options
  • Save Jamp/d27dde6fcb796fbd602f463f07469dc3 to your computer and use it in GitHub Desktop.
Save Jamp/d27dde6fcb796fbd602f463f07469dc3 to your computer and use it in GitHub Desktop.
Cliquear 2 veces para salir de una aplicación
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