Using SystemUiHider to keep the navigation bar hidden
Asked Answered
F

1

8

In older versions of Android, it was necessary to use: android:theme="@android:style/Theme.NoTitleBar.Fullscreen" in the manifest to make the title bar disappear.

In the newer ADT versions, I have noticed a SystemUiHider class, which lets you make calls to it's hide() method to remove not only the title bar, but also the action bar and navigation bar.

I am trying to write a fullscreen app, that I would like to stay full screen (for a kiosk implementation), unless a small hidden button is pressed.

I've tried taking the standard FullscreenActivity (generated from the new android project wizard), and prevent the UI from reappearing in a number of ways:

  • Making calls to mSystemUiHider.hide() in the setOnVisibilityChangeListener (to try and immediately hide the UI when it detects a change in visibility)
  • Setting: AUTO_HIDE_DELAY_MILLIS = 0 (to try and immediately hide it if it is visible)
  • Preventing the call to mSystemUiHider.show(); within the onClick method of the contentView.setOnClickListener (to prevent it from being shown)
  • I have also seen the setSystemUiVisibility example in the docs for android.view (again to try and hide it immediately if shown or visibility is changed)

None of them seem to work (Android defaults to the Low Profile Mode for the Navigation Bar when any of these are tried.

I understand that they probably don't want developers doing what I'm trying to do, but I was hoping that I could extend SystemUiHider (and/or SystemUiHiderBase) and override the show() methods to essentially not show unless passed a true flag. I can't seem to find any documentation on either of these classes (perhaps because they're utility classes?).

Fyn answered 28/1, 2013 at 2:20 Comment(1)
There has to be a solution, the app MXPlayer solves this nicely with the lock button.Smallish
O
1

Any interaction with the device brings back the navigation bar.

https://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_HIDE_NAVIGATION

Orgy answered 31/1, 2013 at 13:6 Comment(1)
I realised this from my experiments with the four methods I tried. My question is whether one could override this behaviour (with or without root access).Fyn

© 2022 - 2024 — McMap. All rights reserved.