title: Dismissing DialogFragment programmatically
body: <p>How does one programatically dismiss a DialogFragment? I am currently creating dialogs by:</p>
  
  <pre><code>void showDialogWithId(int id){
  
      FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
      Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
      if (prev != null) {
          ft.remove(prev);
      }
      ft.addToBackStack(null);
  
      if (id == SEARCHING_DIALOG){
  
          // Create and show the dialog.
          DialogFragment newFragment = MyDialogFragment.newInstance(SEARCHING_DIALOG,"TEST");
          newFragment.show(ft, "dialog");
      }
  
      if (id == CONNECTING_DIALOG){
  
          // Create and show the dialog.
          DialogFragment newFragment = MyDialogFragment.newInstance(CONNECTING_DIALOG,"TEST");
          newFragment.show(ft, "dialog");
      }
  
      if (id == CONNECTIVITY_DIALOG){
  
  
          // Create and show the dialog.
          DialogFragment newFragment = MyDialogFragment.newInstance(CONNECTIVITY_DIALOG);
          newFragment.show(ft, "dialog");
      }
  
  }
  </code></pre>
  
  <p>And I expect to dismiss them by:</p>
  
  <pre><code>public void dismissDialog(){
  
      getFragmentManager().popBackStack();
  
      FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
      Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
      if (prev != null) {
          ft.remove(prev);
      }
      ft.addToBackStack(null);
  
  
  }
  </code></pre>
  
  <p>However, the dialogs are not being dismissed...</p>