Created
September 21, 2016 13:37
-
-
Save webserveis/84a20d65aca7396283665524a9b85e8a to your computer and use it in GitHub Desktop.
Sistema pulsación doble para salir App de Android
This file contains 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
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