Created
June 21, 2016 05:19
-
-
Save nisrulz/a9dbb8d0a8c762e5c70961c94a41b370 to your computer and use it in GitHub Desktop.
Get back press work only at second press and notify user to press again to exit.
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 static long back_pressed; | |
@Override | |
public void onBackPressed(){ | |
if (back_pressed + 2000 > System.currentTimeMillis()) super.onBackPressed(); | |
else Toast.makeText(getBaseContext(), "Press once again to exit!", Toast.LENGTH_SHORT).show(); | |
back_pressed = System.currentTimeMillis(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment