Non-deprecated way to hide status bar on android?

Viewed 2779

I have seen two ways to disable the status bar. Both of them are deprecated.

The first one from the documentation:

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);

The other one from here, for example:

requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

In the first method setSystemUiVisibility is deprecated, and in the second method WindowManager.LayoutParams.FLAG_FULLSCREEN is deprecated. What is a non-deprecated/current way to hide the status bar on android? I'd prefer a method which hides the status bar throughout the app, not just in one activity.

1 Answers
Related