在冰淇淋三明治和果冻豆块主页按钮 [英] block Home Button in Ice cream sandwich and jelly bean

查看:139
本文介绍了在冰淇淋三明治和果冻豆块主页按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发展锁定屏幕,我想禁用冰淇淋三明治和果冻豆Home按键,我可以使用以下方法在Android 2.2的阻止它,2.3

I am developing Lock screen where i want to disable Home button in ice cream sandwich and in Jelly bean , i can block it using following methods in android 2.2 , 2.3

  @Override
public void onAttachedToWindow() {
    // TODO Auto-generate method stub
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
    super.onAttachedToWindow();
}

也试过这种

   getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

我在这里也没有得到事件信息通过的onPause 方法或的onkeydown

但这些方法done't在ICS,果冻豆对我的工作,如果有任何可以代替它,然后让​​我知道的方法

But these methods done't work for me in ICS,Jelly bean if is there any method that can replace it then let me know

推荐答案

邮政ICS即安卓4+,在为homeButton的首要已被删除出于安全原因,以使在案件中的应用原来是一个用户出口恶意软件。

Post ICS i.e. Android 4+, the overriding of the HomeButton has been removed for security reasons, to enable the user exit in case the application turns out to be a malware.

另外,它并不是一个非常好的做法,不能让用户导航离开该应用程序。但是,因为你是一个锁屏应用程序,你可以做的就是申报活动为启动,这样,当为homeButton为pressed将只需重新启动您的应用程序,并保持有自己(用户会发现只是轻微的闪烁在屏幕)。

Plus, it is not a really good practice to not let the user navigate away from the application. But, since you are making a lock screen application, what you can do is declare the activity as a Launcher , so that when the HomeButton is pressed it will simply restart your application and remain there itself (the users would notice nothing but a slight flicker in the screen).

编辑#1:以下是另一种解决方法,更适合您的需求。

EDIT #1 : Here is another workaround, more suited to your needs.

编辑#2:只是碰到这。没有测试过。但看起来有点前途。不知道是否会工作,但你可以试试看。

EDIT #2 : Just came across this. Haven't tested it. But looks kinda promising. Not sure if it would work, but you could give it a try.

这篇关于在冰淇淋三明治和果冻豆块主页按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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