@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode==KeyEvent.KEYCODE_BACK){ if ((System.currentTimeMillis() - mExitTime) > 2000) { new UIUtil(MainActivity.this).ShortToast("再按一次回退键退出程序"); mExitTime = System.currentTimeMillis(); } else { MainActivity.this.finish(); overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out); } } return true; }