Android - 是否可以禁用单击主页按钮 [英] Android - Is It possible to disable the click of home button

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

问题描述

我有一个应用程序,当它启动时,我必须禁用 Android 设备上的所有按钮,我成功地禁用了挂断电话和其他按钮.我需要禁用主页按钮点击.它不应在点击时产生任何动作.

I have an application, when it launches I have to disable all the buttons on Android device, I succeeded in disabling end call and others. I need to disable home button click. It should not produce any action on click.

非常感谢任何建议

推荐答案

我很确定 Toddler Lock 只是使用 BroadcastReciever 并监听 Intent.ACTION_MAIN 和类别 Intent.CATEGORY_HOME - 这就是为什么当您第一次启动它时,它会告诉您选中将此应用程序用作默认值"框,并让您选择幼儿锁.

I'm pretty sure Toddler Lock just uses a BroadcastReciever and listens for Intent.ACTION_MAIN and the category Intent.CATEGORY_HOME - that's why when you first launch it, it tells you to check the "use this application as default" box, and makes you select toddler lock.

所以,它根本没有真正阻止 Home 按钮,它只是将自己设置为默认广播接收器:

So, it's not really blocking the Home button at all, it's just setting itself up as the default broadcast receiver for:

Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);

当您启动 Toddler Lock 时,它可能会设置一个内部标志,如果您按下主页按钮,它只会将窗口带到前面.如果未设置该标志,它可能会显式启动 Launcher.

When you launch Toddler Lock, it probably sets an internal flag, and if you press the home button, it just brings the window to the front. If the flag is not set, it probably launches Launcher explicitly.

我希望这是有道理的.这只是一个理论,但我几乎 100% 确定它是如何完成的.

I hope that makes sense. It's just a theory, but I'm almost 100% sure that's how it's done.

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

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