Last active
June 13, 2016 11:34
-
-
Save engincancan/9f68957a919e29ec0877e1bdcbd30b6c to your computer and use it in GitHub Desktop.
doublebackAndroid
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
private static final int TIME_DELAY = 2000; | |
private static long back_pressed; | |
@Override | |
public void onBackPressed() { | |
if (back_pressed + TIME_DELAY > 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