Double Back Press to Exit Application In Android

by Sasikumar 2013-11-05 10:18:09

To make Double back press to exit application :
To make Double back press to exit application use following,
private static long back_pressed;

@Override
public void onBackPressed()
{
if (back_pressed + 2000 > System.currentTimeMillis()) super.onBackPressed();
else Toast.makeText(getBaseContext(), "Press Back again to exit!", Toast.LENGTH_SHORT).show();
back_pressed = System.currentTimeMillis();
}
751
like
0
dislike
0
mail
flag

You must LOGIN to add comments