title: Full Screen Immersive Mode in Android
body: <p>I have set full screen immersive mode for my android app in <code>onResume</code> like this:</p>
  
  <pre><code>    @Override
      public void onResume() {
      super.onResume();  
      final View decorView = getWindow().getDecorView();
      decorView.setSystemUiVisibility(
              View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                      | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                      | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                      | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                      | View.SYSTEM_UI_FLAG_FULLSCREEN
                      | View.SYSTEM_UI_FLAG_IMMERSIVE);
       decorView.setOnSystemUiVisibilityChangeListener
              (new View.OnSystemUiVisibilityChangeListener() {
                  @Override
                  public void onSystemUiVisibilityChange(int visibility) { decorView.setSystemUiVisibility(
                             View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                      | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                      | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                      | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                      | View.SYSTEM_UI_FLAG_FULLSCREEN
                      | View.SYSTEM_UI_FLAG_IMMERSIVE);
  
                  }
              });
        }
  </code></pre>
  
  <p><code>OnSystemUiVisibilityChangeListener()</code> is also implemented to hide the bars immediately incase a user does an inward swipe. Since the app will be run on a kiosk device, it is important to ensure that the user does not have access to home/back or any system information.</p>
  
  <p>The above works fine, but when a <code>DialogFragment</code> is shown, the system and navigation bars become visible till the dialog is visible. How can i ensure that the bars stay hidden no matter what. Also, is there a better way to handle full screen mode and disable access to system,navigation,action,app bars completely.</p>
  
  <p>EDIT:
  I have managed to hide the bars on the dialog by using the following code in my dialog class:</p>
  
  <pre><code>@Override
  public void onStart() {
      super.onStart();
      Window window = getDialog().getWindow();
      window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
      int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
              | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
              | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN
              | View.SYSTEM_UI_FLAG_IMMERSIVE;
      window.getDecorView().setSystemUiVisibility(uiOptions);
  }
  </code></pre>
  
  <p>But there is a transient time where the bars get visible before sliding out of view. How can i get the bars to not show at all.</p>