I'm making an app where an alert dialog pops up when you hit a certain button. The status bar needs to be hidden, so I have a method in my activity:
private void hideStatusBar(){
if (Build.VERSION.SDK_INT < 16){
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
else {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
}
I call this method in the activity's onCreate method, and it works fine until the alert dialog pops up. As soon as the alert dialog is shown, the status bar comes back. I tried the following:
alertDialog.show();
hideStatusBar();
which didn't work.Then I overrode the onWindowFocusChanged method for my activity:
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
hideStatusBar();
}
which makes the background of the status bar transparent, but still doesn't hide it. Is there any way to keep the status bar hidden when the alert dialog is shown?