双击返回退出

private static long back_pressed;

@Override
public void onBackPressed()
{
        if (back_pressed + 2000 > System.currentTimeMillis()) super.onBackPressed();
        else Toast.makeText(getBaseContext(), "按再一次退出!", Toast.LENGTH_SHORT).show(); back_pressed = System.currentTimeMillis();
}



你可能感兴趣的:(双击返回退出)