在Android中禁用主页按钮 [英] Disable home button in android

查看:96
本文介绍了在Android中禁用主页按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将此代码添加到我的活动中

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

推荐答案

您绝对不应在Android应用程序中禁用主页按钮.这是一种主要的反模式,将使您的应用程序被标记为垃圾邮件和类似恶意软件.用户讨厌禁用主页按钮,因此您应该不惜一切代价避免使用它.(至少,它将使您的市场评级不佳.)

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.)

这篇关于在Android中禁用主页按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆