代码改变世界
Android点击两次返回退出程序
private long mExitTime;
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if ((System.currentTimeMillis() - mExitTime) > 2000) {
Object mHelperUtils;
Toast.makeText(this, "再按一次退出程序", Toast.LENGTH_SHORT).show();
mExitTime = System.currentTimeMillis(); } else {
finish();
}
return true;
}
return super.onKeyDown(keyCode, event);
}