I want to have a fullscreen app, that hides the status bar in onCreate
, and then at some point, when the user opens the Options Menu, I want to show the status bar. Then, when the Options Menu is closed, to hide the status bar again.
Currently I am unable to achieve this, as changes to status bar can only be done before adding content to the Activity, so trying to do it like this:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
throws this exception
09-01 12:37:19.415: E/AndroidRuntime(2737): java.lang.RuntimeException: Unable to pause activity {com.bla.blabla/com.bla.blabla.MainActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
Can this be achieved at all?
EDIT: I know that when you make it for first time, the code must be called before setContentView
, THAT IS CLEAR ENOUGH, I want to know if it's possible for these changes to be made later at runtime, when the user interacts with the app.
Try using Immersive Full-screen mode (available on 4.4+). Read more about it here.