The documentation states:
Home key. This key is handled by the framework and is never delivered
to applications.
More specifically, the key is consumed by the PhoneWindowManager in the method interceptKeyBeforeDispatching(..)
. In this method the key is handled and consumed, meaning that Android does not allow overriding this functionality.
UPDATE:
The reason why your back-behavior does not work anymore is because you yourself have handled it. The key enters the onKeyDown
-method and you can consume the key (yes or no) by returning true or false. By implementing this:
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
return true;
}
You explicitly state that you have handled the Back key in your Activity
which also means that the default behavior of "going-back" is overridden. To restore to its original behavior use return super.onKeyDown(keyCode, event);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…