Created
November 24, 2022 08:40
-
-
Save ibrahim-mrq/471d8fccc2ecde3d4510b76d6b520c65 to your computer and use it in GitHub Desktop.
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 android.widget.Toast backToasty; | |
| private long backPressedTime; | |
| @Override | |
| public void onBackPressed() { | |
| if (backPressedTime + 2000 > System.currentTimeMillis()) { | |
| backToasty.cancel(); | |
| super.onBackPressed(); | |
| return; | |
| } else { | |
| backToasty = android.widget.Toast.makeText($context$, "Press back again to exit.", Toast.LENGTH_SHORT); | |
| backToasty.show(); | |
| } | |
| backPressedTime = System.currentTimeMillis(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment