title: Maintain Immersive mode when DialogFragment is Shown
body: <p>I have an Android Application that is made using Fragments</p>
  
  <p>I am hiding the bars at top and bottom of my screen, using the following code.</p>
  
  <pre><code> @Override
  protected void onResume() {
      super.onResume();
      isInBackground = false;
  
      if(null == getFragmentManager().findFragmentById(R.id.content_container))
      {
          getFragmentManager().beginTransaction().add(R.id.content_container,new PresenterFragment(), PresenterFragment.FRAG_TAG).commit();
      }
  
      if(Build.VERSION.SDK_INT &gt;=19)
      {
          View decorView = getWindow().getDecorView();
          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 // hide nav bar
                  | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                  | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
          decorView.setSystemUiVisibility(uiOptions);
          decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
              @Override
              public void onSystemUiVisibilityChange(int visibility) {
                  View decorView = getWindow().getDecorView();
                  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 // hide nav bar
                          | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                          | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
                  decorView.setSystemUiVisibility(uiOptions);
              }
          });
      }
  }
  </code></pre>
  
  <p>When the soft keyboard it shown the bars show, I can live with this as they hide when the keyboard is dismissed.However if a dialog Fragment is show while the soft keyboard is shown then when both the keyboard and the dialog fragment are dismissed they bars remain over the top of the application.</p>
  
  <p>My 3 questions are</p>
  
  <p>Is it possible to stop the softkeyboard for changing the UI mode?</p>
  
  <p>Is it possible to stop the showing of DialogsFraments from changing the UI mode?</p>
  
  <p>edit: I used to below code to see if the keyboard is shown</p>
  
  <pre><code>public static boolean isKeyBoardShown(){
      InputMethodManager imm = (InputMethodManager)currentActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
      if (imm.isAcceptingText()) {
          return true;
      } else {
          return false;
      }
  }
  </code></pre>
  
  <p>-> I know that there is a work around for dialogs in an activity but I can't see one or rework the code to work in a DialogFragment</p>
  
  <p>If neither is possible why does the app get stuck in the wrong UI mode when there is both a shown keyboard and DialogFrament?</p>