using onBackPressed() with backward compatibility
问题 I want to use onBackPressed() method and still want to provide support for Android SDK before 2.0. onBackPressed() is introduced in Android SDK 2.0. but how to do ? 回答1: Using onKeyDown; public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { // Your Code Here return true; } return super.onKeyDown(keyCode, event); } 回答2: You may capture a key event and check for the back key. On your activity: @Override public boolean onKeyDown(int keyCode, KeyEvent