当我们的Activity继承了TabActivity,在该类中重写onKeyDown是监听不到返回键的,
具体解决方法如下:
重写dispatchKeyEvent
/** * 退出 */ @Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { //具体的操作代码 } return super.dispatchKeyEvent(event); }