gpt4 book ai didi

java - 如何使应用程序无法关闭?

转载 作者:太空狗 更新时间:2023-10-29 12:40:52 25 4
gpt4 key购买 nike

在用户打开我的应用程序后,我不希望他们离开。因此,当他们按下主页或后退按钮时,它不会让他们退出应用程序。我知道有一些方法可以使用服务让应用程序始终在后台运行,但我什至不希望它们退出。

这甚至可能吗?如果可能的话怎么办?无需破解内核。

我知道这听起来很奇怪,但它不是用于商业应用程序,而是用于我的实验室,它永远不会出现在 GooglePlay 上。这些平板电脑将提供给 child 子,他们将对其进行测试,所以我不能让他们使用 youtube 或其他任何东西。


相关帖子:Android, How to make the task of the app unclosable? Only closable by task killing

CommonWare的回答似乎表明内核破解是唯一的方法,但它是吗?

我也在使用 Android L

最佳答案

目前还没有官方支持 - 将通过任务锁定 API 支持 android L

The L Developer Preview introduces a new task locking API that lets you temporarily restrict users from leaving your app or being interrupted by notifications. This could be used, for example, if you are developing an education app to support high stakes assessment requirements on Android. Once your app activates this mode, users will not be able to see notifications, access other apps, or return to the Home screen, until your app exits the mode.

https://developer.android.com/preview/api-overview.html

编辑:正如你所说你使用 L 这已经过时了 - 但我把它留在这里作为对其他人的提示

说 - 如果必须的话,今天您也可以在没有 root 的情况下进行此类工作(例如,某些硬件上的信息亭模式应用程序)。这并不简单——也没有适用于所有设备的解决方案——但如果你需要它,你可以通过以下技巧让它工作: - 对主屏幕 Intent 使用react(并将其设置为默认值) - 当你回到背景时 - 再次把你自己带到前景 - ..

关于java - 如何使应用程序无法关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26324810/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com