It is possible to make a HoneyComb activity unclosable?

徘徊边缘 提交于 2019-12-25 08:35:27

问题


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


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/9371614/it-is-possible-to-make-a-honeycomb-activity-unclosable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!