首页 > 代码库 > 2秒内双击返回退出应用

2秒内双击返回退出应用

@Override    public boolean onKeyDown(int keyCode, KeyEvent event) {        if (keyCode == KeyEvent.KEYCODE_BACK) {            if (System.currentTimeMillis() - mExitTime > 2000) {                Toast.makeText(getApplicationContext(), "再按一次返回键退出",                        Toast.LENGTH_SHORT).show();                mExitTime = System.currentTimeMillis();            } else {                finish();                ExitApplication.getInstance().exit();            }            return true;        }        return super.onKeyDown(keyCode, event);    }

2秒内双击返回退出应用

2秒内双击返回退出应用