HUWWW
我使用这种简单得多的方法...public class XYZ extends Activity { private long backPressedTime = 0; // used by onBackPressed() @Override public void onBackPressed() { // to prevent irritating accidental logouts long t = System.currentTimeMillis(); if (t - backPressedTime > 2000) { // 2 secs backPressedTime = t; Toast.makeText(this, "Press back again to logout", Toast.LENGTH_SHORT).show(); } else { // this guy is serious // clean up super.onBackPressed(); // bye } }}