如何禁用不使用TYPE_KEYGUARD主页按钮? [英] How to disable Home button without using the TYPE_KEYGUARD?

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

问题描述

我创建了一个锁屏应用程序,我需要禁用主页按钮,所以如果手机被盗,该手机不能访问..我的锁屏是一个全屏的活动..即时通讯使用code禁用主页按钮,但它给了我一些问题。这里的code:

i create a lockscreen application and i need to disable a home button, so if that phone is stolen, that phone can't be accessed.. my lockscreen is a fullscreen activity.. im use this code to disable a home button, but it gave me some bug. here's the code:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    }

    @Override
    public void onAttachedToWindow()
    {  
        this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);     
        super.onAttachedToWindow();  
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        return false;
    }

这code给了我一些bug一样还是可以,如果我关掉我的显示器并打开它再次被访问,即使我在全屏模式下的活动,通知/状态区..错误是这样的:

that code gave me some bug like a notification/status area still can be accessed even my activity on the full screen mode, if i turn off my display and turn on it again.. the bug is like this :

第一次启动应用程序:(仍然没有问题)

first time application started: (still no problem)

在我关掉我的屏幕从电源按钮,然后再次打开它:

after i turn off my screen from power button and turn it on again:

的主要问题是在锁屏。当通知区域仍然可以访问,那么锁屏是没有用的。

the main problem is on the lockscreen.. when the notification area still can be accessed, then the lockscreen is not useful..

任何想法如何解决这个问题?请帮助..

any idea how to solve this?? please help..

我也面临着同样的问题,当我preSS结束键按钮。

I am also facing the same problem when i press the end key button.

推荐答案

有关我的手机TYPE_KEYGUARD似乎覆盖全屏,没有标题栏的主题。通知栏总是present。试试这个:

For my phone TYPE_KEYGUARD seems to override the fullscreen, no titlebar theme. The notification bar is always present. Try this:

@Override
public void onAttachedToWindow()
{  
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);     
    super.onAttachedToWindow();  
}

请您查看拉伸整个屏幕,它会掩盖通知区域。您的通知区域可能仍然是可点击(不可见),但我相信,如果你发现你的视图中的所有重要事件不应该传播到了吧。

Make your view stretch the entire screen and it will cover up the notification area. Your notification area may still be clickable (invisibly) but I believe if you catch all the key events on your view it should not propagate down to the bar.

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

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