3

How to, when the application first started, lock on my application avoiding the event of any use of 'back' and 'home' button.
Only the application should have the ability to release the access to the device, the user is blocked to use his home or back button.

Is there any way, even if some hack is needed.

Sorry about breaking the freedom of Android, but it's a client specific need. He doesn't want his waiters kidding around with some Android's game.

Thank you.

Rodrigo Gurgel
  • 1,696
  • 2
  • 15
  • 32
  • The usual recourse is to make the app a home screen replacement - though that can be circumvented unless you modify the installation of android itself. – Chris Stratton Jun 19 '12 at 18:15
  • Everything is so fine when you find the correct buzzword: kiosk-mode. Google returned some helpful sites. – Rodrigo Gurgel Jun 19 '12 at 19:54

2 Answers2

2

For Back: override onBackPressed in your activity so that it doesn't call super.onBackPressed()

For the home button, check out this stack overflow thread.

Community
  • 1
  • 1
soost
  • 91
  • 3
0

Fortunately, there isn't a reliable way to do this. On any given Android device, the user can simply reboot in safe mode (hold down the Home key during boot) to disable all 3rd party apps (which means your apps) and run the standard apps/uninstall 3rd party apps. Android was designed to ensure that the user remains in control of his device.

Maybe it will work for whatever your client requires, but just know that it can be easily bypassed if the user knows how. :)

Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
  • Very helpful. Devices could be manually checked by an in charge supervisor, unless a copy of .apk is made they won't be able to hide the ride =) But this I'll postpone. \m/ – Rodrigo Gurgel Jun 20 '12 at 14:24
  • At some point Android must introduce some sort of user concept into the operating system... like there is on a computer (Admin, Guest, Regular users, etc.). Well I hope they do at least... keep your finger crossed for jelly bean. :) – Alex Lockwood Jun 20 '12 at 14:38
  • Actually there's the situation where the user can hold the home button on some devices where the 'task manager' is called. The journey has just began... – Rodrigo Gurgel Jun 20 '12 at 14:43
  • Those are all internal to the OS though... the problem is that anything you find might not work the same on a different device. For example, the UI on the Samsung Galaxy Tablet is much different than a normal Android device UI. Make sure you don't use anything from internal APIs either... these APIs are not guaranteed to be maintained (they could be removed in the next release, etc). – Alex Lockwood Jun 20 '12 at 14:46