Search code examples
androiduser-interfacestatusbar

Android Hiding the status bar after exiting


So I have a code that hides the status bar but the only problem is that if I went to the homepage and then reopen the application (Still running) the status bar shows up. Also, when I press the option button (The button below), it shows the status bar. Is there a way to disable the option button and hide the status bar when reopening the running application?

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

Solution

  • well its happening because when your activity pause the Statusbar gets visible so you need hide the Statusbar in onResumeof your activity, something like this example:

    @Override
    protected void onResume() {
        super.onResume();
        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
        decorView.setSystemUiVisibility(uiOptions)
    }
    

    Now if you resume the app it will Statusbar will stay hidden.