0

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

JackMahoney
  • 3,423
  • 7
  • 32
  • 50

3 Answers3

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.

Sunny
  • 14,522
  • 15
  • 84
  • 129
0

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.

onit
  • 6,306
  • 3
  • 24
  • 31
  • On the other hand, it could be very useful if not misused. For example, we have Android phones and iPhones on display showing interactive slideshows. They must be put in special cases which cover the buttons so the visitors cannot misbehave. Similarly, imagine if a game could intercept the Home button and ask the user if they wish to save before exiting. I know I've bumped the home button on several occasions. – Ozzah Feb 21 '12 at 03:51
  • @Ozzah For interactive slideshows, you can lock the screen and as much of the UI on the screen as you want. The game idea is why Android always tries to recreate the Activity exactly as is. I know it puts a huge burden on the developer managing instance data when apps go out of memory, but that is the model. Allowing the developer to create an app that a user can never get out of without restarting their phone or some crazy technique that might not be intuitive can lead to a bad user experience. I'm not saying it can't be disabled for a good cause, but I can see why they don't allow it. – onit Feb 21 '12 at 04:07
0

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.

Aaron
  • 1,024
  • 11
  • 11
  • That's an interesting idea. What libraries does it require and what method calls do you make on a device with root/su? – JackMahoney Mar 05 '12 at 23:21
  • The call to kill the system bar is: `proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 79 s16 com.android.systemui"}); ` however this only worked on Honeycomb. – Aaron Feb 09 '13 at 00:59