[code]private boolean isExit = false;public boolean onKeyDown(int keyCode, KeyEvent event) {//2s内按2次返回键退出if (keyCode == KeyEvent.KEYCODE_BACK ) {if (isExit) {//第2次返回键finish();} else {//第一次返回键isExit=true;new Handler().postDelayed(new Runnable() {public void run() {isExit = false;}},2000);Toast.makeText(context, \"再按一次退出!\", Toast.LENGTH_LONG).show();return true;// true:表示自己已经处理按键事件, false:表示系统处理}}return super.onKeyDown(keyCode, event);}