Created
December 16, 2018 08:11
-
-
Save Binary-Finery/3de0fee5d6c47094023a1b855913b3b8 to your computer and use it in GitHub Desktop.
press back again to exit example
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
@Override | |
public void onBackPressed() { | |
if (doubleBackToExitPressedOnce) { | |
super.onBackPressed(); | |
return; | |
} | |
doubleBackToExitPressedOnce = true; | |
Toast.makeText(this, "press back again to exit app", 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