当我们的Activity继承了TabActivity,在该类中重写onKeyDown是监听不到返回键的,
具体解决方法如下:
重写dispatchKeyEvent
//因为Activity继承了TabActivity,所以不能监听到onKeyDown()方法,重写以下方法@Overridepublic boolean dispatchKeyEvent(KeyEvent event) {if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { //exitBy2Click(); //调用双击退出函数 sysExit();} return super.dispatchKeyEvent(event);}
转载自:
http://blog.csdn.net/johnny901114/article/details/7822878