In Android Disable Only Homekey Button
Solution 1:
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) {
returntrue;
}
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);
Solution 2:
Yes, it is possible. In you manifest, under your activity deceleration, replace
<categoryandroid:name="android.intent.category.LAUNCHER" />
with
<categoryandroid:name="android.intent.category.HOME" />
Note that with this change, your application will not be visible in the "All Apps" section. Also, user needs to set you application as the default home screen. Try out "Toddler Lock" application, it handles this scenario nicely.
Post a Comment for "In Android Disable Only Homekey Button"