/** * 连续按两次返回键就退出 */ private long firstTime; @Override public void onBackPressed() { if (System.currentTimeMillis() - firstTime < 3000) { finish(); } else { firstTime = System.currentTimeMillis(); Toast.makeText(this, R.string.press_again_exit, Toast.LENGTH_SHORT) .show(); } }