Disable home button in android

我的梦境 提交于 2019-12-02 18:51:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!