1

I made a Full-Screen app for android which hides both Navigation Bar & Status Bar that supports API 16 (starting from Jelly Bean).. I know that if I want to hide both Navigation Bar & Status Bar starting from KitKat I can use the following code:

getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

But that code doesn't work for Jelly Bean, it hides the bars only once and they reappear once you touch the screen. So I know that the following code supports Jelly Bean but it only hides the Status Bar:

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

Can anyone show me the way to hide the Navigation Bar as well on Jelly Bean permanently?

  • Please check the Android documentation https://developer.android.com/training/system-ui/navigation.html – JGPhilip Aug 17 '15 at 14:04
  • possible duplicate of [Permanently hide navigation bar on activity](http://stackoverflow.com/questions/16713845/permanently-hide-navigation-bar-on-activity) – Viktor Yakunin Aug 17 '15 at 14:40
  • I didn't find an answer to that, All I found was to be able to dim the Navigation Bar but not hide it. – Ibraheem Tuffaha Aug 19 '15 at 09:30

1 Answers1

0

Try hiding statusbar/navigation bar once again after it appears on the screen.

Here is information how to listen for UI changes:

https://developer.android.com/training/system-ui/visibility.html

Relevant part:

View decorView = getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener
        (new View.OnSystemUiVisibilityChangeListener() {
    @Override
    public void onSystemUiVisibilityChange(int visibility) {
        if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
            // system bars are visible
            // hide them again, maybe with some delay?
        }
    }
});
pelotasplus
  • 9,852
  • 1
  • 35
  • 37
  • I tried this in onCreat() by adding this instead of the comments above: getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); Still doesn't work! – Ibraheem Tuffaha Aug 19 '15 at 09:04
  • do you see this callback being called, ie add Log.d(...) and see if you have this message in the logs... – pelotasplus Aug 19 '15 at 09:23
  • It doesn't show in the log, the whole method "onSystemUiVisibilityChange" isn't being called! – Ibraheem Tuffaha Aug 19 '15 at 09:58