android再点一次返回退出
@Override public boolean onKeyDown(int keyCode, KeyEvent event)//主要是对这个函数的复写 { // TODO Auto-generated method stub if((keyCode == KeyEvent.KEYCODE_BACK)&&(event.getAction() == KeyEvent.ACTION_DOWN)) { if(System.currentTimeMillis() - temptime >2000) // 2s内再次选择back键有效 { System.out.println(Toast.LENGTH_LONG); Toast.makeText(this, "请在按一次返回退出", Toast.LENGTH_LONG).show(); temptime = System.currentTimeMillis(); } else { finish(); System.exit(0); //凡是非零都表示异常退出!0表示正常退出! } return true; } return super.onKeyDown(keyCode, event); }