0

I have an application where I to "lock down" an Activity completely. I am running an Android 4.2 Jellybean on an S3.

Now my application needs to have a specific screen where it will be interacted by multiple, different people (kind of like a self-checkin app), and I don't want them being able to access anything else but what that screen has. So I disabled the back button, but I still need to disable the following:

  1. The Home button
  2. Long press on the Home button
  3. The notifications bar. Android has this feature where you can drag down from the topmost part of the screen, and a drawer where you can configure some settings like mute or bluetooth will appear, and I need to disable that too.
  4. The screen from auto-locking

Does anyone have any idea how to accomplish any of them?

Wakka02
  • 1,491
  • 4
  • 28
  • 44
  • do you want that your application is the only one to run on your device? – Blackbelt Jul 05 '13 at 10:13
  • No.. I just need that particular Activity to be very hard to get out of. I implemented a 5 finger touch detection feature; in order to exit the Activity, the user must touch the screen with 5 fingers and type in a password. That works fine. Now I need to disable the above, so that only the owner of the device can exit the application... – Wakka02 Jul 05 '13 at 10:24

2 Answers2

0

This sounds like you need the app to be fullscreen.

You achieve that like this in your Activity.onCreate():

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);

Be aware that an incoming call will go on top of the current application.

To be sure the device will not go to sleep:

  1. Simply disable that in the settings
  2. Use android:keepScreenOn="true" in your layout (by far the easiest option)
  3. Use a WakeLock

Also, the user still can press the power button to lock the device. But disabling the power button doesn't seem like a good idea to me.

About the notification bar (discussed in the comments): take a look at this thread: Disable Android Notification Bar in Full Screen (in SGIII)

Community
  • 1
  • 1
Leon Joosse
  • 959
  • 1
  • 7
  • 17
  • Yes, well... that's true. But it's meant to be that way. :/ Only the owner of the device can exit that application. – Wakka02 Jul 05 '13 at 10:32
  • I managed to keep screen on, which worked wonderfully :D But setting it to fullscreen doesn't cut it. The notifications bar does disappear, but Android has a feature where if you touch the top of the screen in a fullscreen activity and swipe down, the notification bar will still appear temporarily. Doing it again will cause the notifications and settings drawer to open. Any idea how I can stop this from happening? – Wakka02 Jul 05 '13 at 10:57
  • I'm not aware of any solution to disable the notification bar for a specific activity... – Leon Joosse Jul 05 '13 at 11:29
  • Well I'd be okay with it disabling for the entire app if necessary... is that possible? – Wakka02 Jul 05 '13 at 11:39
  • Please see the last line I added to the answer – Leon Joosse Jul 05 '13 at 13:00
0

What you want is to make your app into "Kiosk Mode". This still isn't a complete solution. I'm assuming that you will be in direct control of the devices using your app so it may work, because the user has to opt-in to make it their home screen.

Android for kiosk apps

Locking down kiosk mode android devices

For obvious reasons, Android doesn't make this convenient due to potential malicious apps. There may be other solutions if the device is rooted.

Community
  • 1
  • 1
telkins
  • 10,440
  • 8
  • 52
  • 79
  • This sounds awesome, however how do I make my app the "home screen app"? The blog post listed is exactly what I want, but it doesn't say much on how to do it.. – Wakka02 Jul 08 '13 at 07:04