在 Android ICS (4.0) 中禁用主页按钮 [英] Disable Home Button in Android ICS (4.0)

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

问题描述

我正在为一家公司制作专有应用程序,该应用程序永远不会在 Ice Cream Sandwich (Android 4.0) 中将其发布到 Android Market(或我猜现在的 Play 商店).

I am making a proprietary app for a company which will never release it to the Android Market (or Play Store I guess now) in Ice Cream Sandwich (Android 4.0).

我需要禁用 Home 以便用户不能恶意卸载软件或删除应用程序捕获的数据.这个最新版本是第一个用 4.0 编写的,之前的版本是用 2.2 和 3.2 编写的.

I need to disable the Home so the users cannot maliciously uninstall software or delete the data that the app captures. This latest version is the first to be written in 4.0, the previous versions were written in 2.2 and 3.2.

为了在 2.2 中禁用主页按钮,我将应用程序关联为主页替换,因此按钮刚刚重新打开应用程序,但我不能再使用此方法,因为这在某种程度上阻止了我们对应用程序进行更新(我们不想让用户重新选择家庭默认设置,因为这会导致数据删除.

For disabling the Home button in 2.2, I associated the app as a home replacement, so the button just reopened the app, but I can no longer use this method, as that somewhat prevents us from doing our updates to the app (we don't want to give the user the option of reselecting a Home default, as that would lead to data deletion.

我在 3.2 中禁用主页按钮的代码是:

The code I have for disableing the Home button in 3.2 is:

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

并且,在 onCreate 下:

and, under onCreate:

KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard();

但是当我运行在我的 3.2 平板电脑上运行的相同代码时,它在我的 4.0 平板电脑上不起作用.

But when I run the same code that worked on my 3.2 tablet, it does not work on my 4.0 tablet.

我想知道 4.0 是否有新的 API 或方法可以实现与我目前在 3.2 实现中相同的效果.

I was wondering if there is a new API or method that 4.0 has that will accomplish the same effect as I currently have in my 3.2 implementation.

感谢您的帮助或指导.

亚当

推荐答案

如何解决..

编写实现主屏幕的第二个应用程序,当按下主屏幕按钮时,该应用程序将出现在前台.然后,您需要从这个应用程序将主应用程序推回前台.唯一的问题是您的主屏幕应用程序必须永远不需要更新,但您应该能够自由更新主应用程序,而无需要求设置主屏幕启动器的选项卡.

Write a second app that implements the home screen, when the home screen button is pressed this app will come to the foreground. From this app you then need to push your main app back to the foreground. The only catch is that your Home screen app must never need an update, but you should be able to update the main app freely without the tab asking to set the home launcher.

希望这是有道理的..

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

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