android应用退出提示



private boolean IsExit;

//连点返回键退出

 @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (mIsExit) { this.finish(); } else { Toast.makeText(this, "再按一次退出", Toast.LENGTH_SHORT).show(); mIsExit = true; new Handler().postDelayed(new Runnable() { @Override public void run() { mIsExit = false; } }, 2000); } return true; } return super.onKeyDown(keyCode, event); }

你可能感兴趣的:(android应用退出提示)