private long exitTime = 0;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
//两秒之内按返回键就会退出
if ((System.currentTimeMillis() - exitTime) > 2000) {
ToastUtil.showToast(getResources().getString(R.string.tips_exit_out));
exitTime = System.currentTimeMillis();
} else {
finish();
System.exit(0);
}
return true;
}
return super.onKeyDown(keyCode, event);
}