是否可以使 HoneyComb 活动不可关闭?
我正在为 HoneyComb 平板电脑开发演示风格的应用程序。在某个阶段,平板电脑可以在房间里传递,供人们互动。如果可能的话,我想防止恶意用户离开当前活动。
到目前为止,我已经覆盖了 onBackPressed() 以防止完成活动,但用户仍然可以按状态栏上的其他按钮,也可以通过弹出的通知离开应用程序。
有什么建议或可能的解决方案吗?
谢谢
I'm developing a presentation style application for HoneyComb Tablets. At one stage the tablet may be passed around a room for people to interact with. If possible I would like to prevent malicious users from navigating away from the current activity.
So far I have overwritten the onBackPressed()
to prevent finishing the activity but users can still press the other buttons on the status bar and also leave the app via notifications that pop up.
Any suggestions or possible solutions?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
1。让您的活动全屏显示。
2 使用 AlarmManager 定期从服务触发您的活动,例如 2 或 3 秒(仅当您的活动不是前台时)。为此,请使用布尔变量并使用sharedPreference 存储它。该值在 onReume 中为 true,在 onPause、onStop 或 onDestroy 中为 false。然后仅当布尔变量为 false 时才从服务启动您的活动。现在,如果您的用户按下主页按钮,则 AlaramManager 会再次启动您的活动。
3 创建一个特殊的按钮来完成您的服务和活动以及取消alarmManager。
1. Make your activity full screen.
2 Use an alarmManager to trigger your activity from a service on a regular interval say 2or3 second (only if your activity is not foreground). For this use a boolean variable and store it using sharedPreference. this value will be true in onReume and false in onPause or in onStop or in onDestroy. And then only start your activity from your service if the boolean variable is false. Now if your user will press the Home button then AlaramManager kick start your activiy again.
3 Make a special button for finishing your service and activity and for cancel the alarmManager.
据我所知,没有办法捕获主页按钮按下的情况,所以这是不可能的。更不用说,这将是开发团队做出的一个糟糕的 UI 设计决定。主页按钮的存在让每个 Android 用户都有退出应用程序的标准方法。如果有办法让用户无法退出应用程序,就会出现一些极其恶意的应用程序。
As far as I know there is no way to capture the home button press, so this is not possible. Not to mention, it would be a bad ui design decision by the dev team. The home button is there so every Android user has a standard way to exit apps. There would be some extremely malicious apps if there was a way to make the user unable to exit an app.
我正在开发一个类似的应用程序,它以“信息亭”方式为零售商店运行。当应用程序启动时,它会以编程方式隐藏系统栏,因此您无法退出。平板电脑重新启动后系统栏会恢复。但是它需要 root/su。
I'm developing a similar application that runs in a "kiosk" fashion for retail stores. When the application launches, it programmatically hides the system bar so you cannot exit. The system bar is restored when the tablet is rebooted. It requires root/su however.