Android点击两次返回键退出

    xiaoxiao2021-04-04  51

    private static Boolean isQuit = false; Timer timer = new Timer(); public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (isQuit == false) { isQuit = true; Toast.makeText(getBaseContext(), "再按一次退出?", Toast.LENGTH_SHORT).show(); TimerTask task = null; task = new TimerTask() { @Override public void run() { isQuit = false; } }; timer.schedule(task, 2000); } else { ActivityControler.finishAllActivity(); } } return true; }
    转载请注明原文地址: https://ju.6miu.com/read-666264.html

    最新回复(0)