Search code examples
androidstatusbarandroid-statusbar

Hidden statusBar re-appears when I show an alert dialog, How to prevent it? (Android)


I am using Android studio, and I have set up my main Activity in order to not show the statusBar. But when I display an alert dialog, the status bar reapears, and it won't hide after. (Also if I receive a notfication on my phonem the status bar will also show up and not hide)

How can I fix that? Can I set my entire app to keep the status Bar hidden?

Here is my current setting: in onCreate()

View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

Solution

  • I found a working solution!

    In my onCreate method, I replaced the previous code by this one:

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