Android 软件退出系统按键方法重写

     //针对Andriod软件退出系统按键方法重写

     private long exitTime = ;//key down time
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if (System.currentTimeMillis() - exitTime >= ) {
exitTime = System.currentTimeMillis();
showToast(getString(R.string.quit_on_double_click_));
return true;
} else {
showToast(getString(R.string.exiting));
try {
Thread.sleep();
} catch (InterruptedException e) {
e.printStackTrace();
}
finish();
}
break;
}
return super.onKeyDown(keyCode, event);
}
05-06 06:47