Skip to content

Instantly share code, notes, and snippets.

@webserveis
Created September 21, 2016 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webserveis/84a20d65aca7396283665524a9b85e8a to your computer and use it in GitHub Desktop.
Save webserveis/84a20d65aca7396283665524a9b85e8a to your computer and use it in GitHub Desktop.
Sistema pulsación doble para salir App de Android
private long firstClickTime;
...
@Override
public void onBackPressed() {
if (firstClickTime + Constants.TIME_INTERVAL > System.currentTimeMillis()) {
super.onBackPressed();
return;
} else {
Toast.makeText(this, getString(R.string.double_back_pressed), Toast.LENGTH_SHORT).show();
}
firstClickTime = System.currentTimeMillis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment