问题
I add this code in my activity
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_HOME) {
return false;
}
return super.onKeyDown(keyCode, event);
}
public void onAttachedToWindow() {
super.onAttachedToWindow();
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
}
and the home button is looks like it is disabled
But the problem is when someone press the menu button and when my menu button is shown and the user press home button then the home button is enabled and home screen is shown
回答1:
You should absolutely not be disabling the home button in an Android application. This is a major anti-pattern, and will both make your app labelled as spammy and malware-like. Users hate when you disable their home button, and you should really avoid it at all costs. (At the very least, it will get you poor market ratings.)
来源:https://stackoverflow.com/questions/9825706/disable-home-button-in-android