Hiding the Status Bar under Android 4.2.2 (SDK 17)

12,110

Solution 1

Chris Banes and Roman Nurik have develop this usefull tool to controls the System UI easily

https://gist.github.com/chrisbanes/73de18faffca571f7292

Solution 2

No, it seems like there is no way to do this for your entire application on tablets running 4.+. Also, fully disabling it so it never appears is NOT possible.

However, the solution you linked does sort of work for Android 4.2.2, (tested on Nexus S and 10 inch tablet on emulator) but even when it works it reloads the status bar if certain user interactions occur to allow navigation (for example, pressing the menu button on a phone). So this means you should plan on spamming the flag every now and then.

I personally tried with this code in my oncreate:

View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();

Which resulted in:

capture

With the 4.2.2 phone the actionBar below also disappears, this does not seem to be possible for tablets.

Coming from the Android documentation about hiding the status bar, it seems that on Android 4.0 or lower, you would be able to set the fullscreen flag for the entire application and be done with it, but this has been changed to the piece of code above.

Next, the UI documentation has this to say:

The SYSTEM_UI_FLAG_LOW_PROFILE flag replaces the STATUS_BAR_HIDDEN flag. When set, this flag enables “low profile" mode for the system bar or navigation bar. Navigation buttons dim and other elements in the system bar also hide. Enabling this is useful for creating more immersive games without distraction for the system navigation buttons.

So I guess it could be that the galaxy tab 3 requires some playing around with these kinds of flags and does not support actually hiding the status bar but rather prefers making it "less visible" ...

Finally, the setSystemUiVisibility method has some great examples if you're still interested in making sure the status bar stays hidden throughout your application.

Solution 3

Please note, that the status bar and the navigation bar are two completely different things. The navigation bar contains the back, home, and recent apps buttons, while the status bar contains the notifications, clock, battery, etc... The status bar can be easyly hidden with flags like SYSTEM_UI_FLAG_FULLSCREEN, but more convenient, using this as your app base theme:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

In tablets, the navigation bar often consists the status bar, so if the navbar is visible, the status bar will be too. You can't just hide the status bar, because then you would have to hide the nav bar too.

The purpose of you can't hide the navigation bar forever, is that the user must be able to control his device and navigate as he wants to.

You can't hide the navigation bar before 4.0, and as in the developer guide says, you can hide the nav bar with the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag, however, it won't stay hidden once the user touches the tablet. More explanation here: Android Developers - Hiding the Navigation Bar

In 4.4 KitKat, a new API was introduced, the immersive mode, with that you can hide the navigation bar and still make the user to be able to interact with your app, without the navigation bar revealing itself. The user can swipe down from the bottom of his screen to make it visible again, this clears the SYSTEM_UI_FLAG_IMMERSIVE flag. If you want to make the navigation bar disappear when the user doesn't interact with it, then you can use the SYSTEM_UI_FLAG_IMMERSIVE_STICKY flag, so it will disappear if the user finishes with it. More explanation here: Android Developers - Android 4.4 API

Also immersive tutorial: Android Developers - Using Immersive Full-Screen Mode

Also, make sure you are targetting the API 19, and only use this flag, when your app runs on API 19 or later. More on checking API version: Here (StackOverflow)

Solution 4

Hiding the Status Bar under Android 4.2.2 (SDK 17)

This solution worked for me.

getWindow().getDecorView().setSystemUiVisibility(8);

Share:
12,110
Andrzej Reduta
Author by

Andrzej Reduta

DBs, PM,

Updated on June 15, 2022

Comments

  • Andrzej Reduta
    Andrzej Reduta about 2 years

    Is it possible to permanently hide Navigation/Status Bar under Android 4.2.2 This solution seems not working under Jelly Bean.

    I have GalaxyTab 3 (10.1) and hidding of Status Bar has no effect.
    It's hidden on application Start on every screens, but i can expand it. Problem occurs also after rooting device.

    Somebody has faced it before (there is also video how to fix it): forum.xda-developers.com/showthread.php?p=37466852

    So my question is: Is there any way to do this on application level?