应用程序保持在最前面,并在关闭时重新启动
我需要将用户“锁定”到应用程序中。设备的唯一目的是使用此应用程序,因此不允许用户出于任何其他原因导航设备是不可行的。确保应用程序 Activity
始终位于前台的最佳方法是什么?如果不是,则启动主 Activity
?
现在我知道这违背了典型 Android 应用程序开发的一切,但这些设备将专门用于这个应用程序。
确定任何应用程序 Activity 是否位于前台并启动一个应用程序(如果不是)的最佳方法是什么?
I need to "lock" a user into an application. The device's sole purpose is to use this application, and so it is not feasible to allow the user to navigate the device for any other reason. What is the best way to make sure that the applications Activity
s are always in the foreground, and if not, launch the main Activity
?
Now I know this goes against everything about the typical Android application development, but these devices are going to be specifically used for this one application.
What is the best way to determine if any of the applications Activity
s are in the foreground, and launch one if not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你不知道。
让您的活动成为主屏幕,它们就不会去任何地方。并推出您自己的固件,以便用户无法安全启动设备并删除您的主屏幕。
You don't.
Make your activity be the home screen, and they can't go anywhere. And roll your own firmware, so that the user can't safe-boot the device and remove your home screen.
我可能会使用一项服务,该服务将使用标志作为生活活动的示例进行检查。
请在此处查看有关如何操作的更多详细信息:http://developer.android.com/guide /topics/fundamentals.html
I will probably use a service which gonna check using a flag as example for a living activity.
Look here for more detail about how to do : http://developer.android.com/guide/topics/fundamentals.html
请参阅这个问题的答案:基本上,您必须实现第二个应用程序来捕获家庭意图,并且简单地如果您的主应用程序关闭,则重新启动它。
See the answer to this question: basically you must implement a second app that captures home intents and simply re-launches your primary application if it is ever closed.
参考 CommonsWare 的说法,您实际上可以部分砖化该设备。我偶然这样做了,我把恢复菜单弄成了砖块,但不是实际的常规启动。这当然是一个糟糕的想法,不应该在实际中使用。
In reference to what CommonsWare was saying, you could actually partially brick the device. I've done it on accident where I've bricked the recovery menu, but not the actual regular boot. This is a terrible idea of course and should not be used practically.