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();
}
[小代码] 双击BACK键 退出
最新推荐文章于 2021-05-26 15:37:17 发布