1

There are many question related to disable status bar.

I tried that way. But did not work in Android 8.0.

because according to Google Document

Alert windows If an app uses the SYSTEM_ALERT_WINDOW permission and uses one of the following window types to attempt to display alert windows above other apps and system windows:

TYPE_PHONE
TYPE_PRIORITY_PHONE
TYPE_SYSTEM_ALERT
TYPE_SYSTEM_OVERLAY
TYPE_SYSTEM_ERROR

...then these windows always appear beneath the windows that use the TYPE_APPLICATION_OVERLAY window type. If an app targets Android 8.0 (API level 26), the app uses the TYPE_APPLICATION_OVERLAY window type to display alert windows.

I already tried How to disable status bar click and pull down in Android? but this works only below Android 8.0.

How to disable status bar in Android 8.0?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Chirag Savsani
  • 6,020
  • 4
  • 38
  • 74

2 Answers2

0

Have you tried something with the flag SYSTEM_UI_FLAG_FULLSCREEN?

Since I'm not sure exactly what your looking for I'll try to give a generic answer that you can tweak to your use case. I hope it helps someone.

Play around with the different flags in here and see what all you need. By the sounds of it you probably just need the last flag -- unless you wish to hide the navigation as well -- then you'll probably want the last two flags set.

private void hideSystemUI() {
    // Enables regular immersive mode.
    // For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
    // Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
    View decorView = getWindow().getDecorView();
    decorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_IMMERSIVE
            // Set the content to appear under the system bars so that the
            // content doesn't resize when the system bars hide and show.
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            // Hide the nav bar and status bar
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN
    );
}

Then take and implement this new method by overriding the onWindowFocusChanged( ... ) method like so.

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);

    if (hasFocus) {
        hideSystemUI();
    }
}

Maybe you'll even want to experiment with adding in some logic to what flags are used under which circumstances or states of the application.

Another great resource as always is Google's docs. There is good info on controlling the system UI visibility here.

Rockin4Life33
  • 2,240
  • 1
  • 31
  • 29
0

See the answer here. We can't block status bar in Oreo. Only can close using a service.

https://stackoverflow.com/a/56292743/3405508

REMITH
  • 1,049
  • 12
  • 12