title: Android DialogFragment Dismissal
body: <p>I've looked at several of the questions pertaining to handling an orientation change in a DialogFragment, and the common theme seems to be that the askers aren't getting any answers, at none that I understand...  </p>
  
  <p>So, I'd like to take a different approach...  Is there a way I can programmatically dismiss the dialog...  Looking at my LogCat, I can see that if the dialogfragment is active, and the screen orientation is changed, then my Activity restarts.  </p>
  
  <p>Along the way, the DialogFragment is also restarted, but this happens after onCreate and before onResume (as close as I can tell).  It's fairly simple for me to detect this in my dialog, and what I'd like to do is abort the dialog view creation in this case.  What I've tried so far is like this:  </p>
  
  <pre><code>    if (normal_conditions_detected)
      {
          View v = inflater.inflate (R.layout.dialog_layout, container, false);
          final Dialog d = getDialog();
          d.setTitle (R.string.sensor_config);
  
          ... more stuff
          return v
      }
      else
      {
          getDialog().cancel();
          return null;
      }
  </code></pre>
  
  <p>This does avoid the null pointer nonsense I was getting, but now I get what I can only describe as an empty dialog, even with the cancel() command in there.  Is there a way I can get my dialogFragment code to refuse to create the view?</p>