I am developing an application that I don't want user to touch home/back button. Trust me, I have a good reason for开发者_如何转开发 it. What I need to do is to disable home/back or even the keyboard using terminal. I've look through commands in adb shell already and I cannot find any command to fix this.
I'm not sure about AVD, but in real phone this buttons are hard buttons. So, no software can remove them. All you can do is to override the behaviour for this buttons using onKeyDown()
method.
Using the following piece of a code in an Activity subclass would work for intercepting key events:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
return true;
// return super.onKeyDown(keyCode, event);
}
The back key is the constant KeyEvent.KEYCODE_BACK; the home button should be similar.
精彩评论