Get back press work only at second press and notify user to press again to exit.
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();
}
5 Comments
thank you but why do i use double back key press? i can not use single key press for exit? what different between two action?
Nice and Simple :)
very nice ;)
Problem SOLVED. Thank you! :)
nice. thank you!