@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) {
exit();
return false;
}
return super.onKeyDown(keyCode, event);
}
private void exit() {
if ((System.currentTimeMillis() - exitTime ) > 2000) {
showToast( "再按一次退出程序");
exitTime = System.currentTimeMillis();
} else {
finish();
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
}
}
点两下退出
最新推荐文章于 2023-05-31 17:05:09 发布