1

Some background information:

  • My app will be used by guests at an event to perform self check-ins. They should not be able to navigate away from the page, access the device's settings, etc. This means that it has to enter a Kiosk Mode of sorts.

  • I need to disable the notifications tray completely, meaning even if the user swipes downward from the top of the screen, the status bar should not appear. It's the one which shows your battery life, WiFi/3G connection, etc.

  • I have already made my application fullscreen, which hides the status bar, but somehow the status bar still appears once the user swipes downward from the top of the screen. Performing another swipe will subsequently open the notifications tray.

  • My device runs on Jelly Bean, but is aimed to cater to devices as old as Ice Cream Sandwich.

How should I go about disabling the notifications tray? Is there code that can help me, or is it as simple as advising the user to disable some settings of some sort (like how the iPad can simply disable gestures in the device's settings)?

Thanks in advance,

Rei

Wakka02
  • 1,491
  • 4
  • 28
  • 44

1 Answers1

0

Take a look at this.

View disableStatusBar = new View(context);

WindowManager.LayoutParams handleParams = new WindowManager.LayoutParams(
    WindowManager.LayoutParams.FILL_PARENT,
    <height of the status bar>,
    // This allows the view to be displayed over the status bar
    WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
    // this is to keep button presses going to the background window
    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
    // this is to enable the notification to recieve touch events
    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
    // Draws over status bar
    WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
    PixelFormat.TRANSLUCENT);

handleParams.gravity = Gravity.TOP;
context.getWindow().addView(view, handleParams);
Community
  • 1
  • 1
Cameron
  • 84
  • 1
  • 11
  • Hi Cameron, have you tested this? It looks nice and shiny, but I can't seem to get it to work on my application. The view gets added, but the status bar can still be pulled down. – Wakka02 Jul 11 '13 at 08:02
  • I haven't, sorry. I ran across [this](http://developer.samsung.com/android/technical-docs/Neat-tricks-when-implementing-a-kiosk-app), though, which might be of some help. – Cameron Jul 11 '13 at 16:50
  • It seems then to be a security feature on the level of Android you're targeting. Your app would require special permissions to cover the status bar. My advice would be to install a kiosk app, such as [LOCKiosk](https://play.google.com/store/apps/details?id=com.telelogos.standalonekiosk&hl=en) (just the first one I found) and set it to allow only your app to be run. – Cameron Jul 12 '13 at 13:52
  • A less technical approach would be to seal off the top part of the screen on your display case. That's the change I had requested for my app. – Archimedes Trajano Nov 03 '13 at 05:38
  • @ArchimedesTrajano: the preferred way would be to create a transparent overlay at the top and then swallow all touch events, like explained in [this answer](http://stackoverflow.com/a/25397029/69809). – vgru Nov 21 '14 at 09:21