如何覆盖Android主键 [英] How to override android home button

查看:172
本文介绍了如何覆盖Android主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找通过Android的文档和计算器,大部分我看说,你无法禁用或覆盖Android主按钮的答案。

I have been searching through Android docs and stackoverflow and most of the answers I am reading say that you cannot disable or override the Android home button.

试过了 - 不工作

<一个href="http://stackoverflow.com/questions/12683418/android-disable-all-hardware-keys-for-lockscreen-app">Says不可能

这个问题是存在已知的正在做这样的应用程序:

The problem is there are known apps that are doing this:

照顾孩子

儿童广场

这就是我想要的:

父加载应用程序,然后给设备一个孩子。孩子只能看到已批准的应用程序,是在设备上(我知道如何做到这一点的一部分)。如果他们加载批准的应用程序,从我的应用程序的主发射器屏幕 - 如果他们preSS home键,这需要他们回到我的应用程序,而不是回设备主屏幕。如果用户$ P $从我的应用程序psses home键 - 什么都不发生。同去的后退按钮。

A parent loads the app then gives device to a child. The child can only see the approved apps that are on the device (I know how to do this part). If they load an approved app from the main launcher screen on my app - if they press the home button, it takes them back to my app and not back to the device home screen. If a user presses the home button from my app - nothing should happen. Same goes for the back button.

我要寻找一个在复制中压倒一切的Home按键照顾孩子的应用程序的功能得到妥善解决。我该怎么做呢?

I am looking for the proper solution in duplicating functionality of Kids Care app in overriding home button. How do I do it?

推荐答案

如果有人仍然有兴趣,你可以尝试把这个在您的主要活动在的Andr​​oidManifest.xml

If anyone is still interested, you could try putting this in your main activity in AndroidManifest.xml

<activity
    ...
    android:launchMode="singleTask">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.HOME" />
        <category android:name="android.intent.category.DEFAULT" />
        ....
    </intent-filter>
</activity>

这篇关于如何覆盖Android主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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