title: Dismiss DatePickerDialog on pressing back button
body: <p>On my view I have a button which when pressed pops up a DatePickerDialog. The poppedup dialog has a "Done" button. When I press that button the selected date is populated into an EditText box.</p>
  
  <p>Now, when I press the back button (<img src="https://i.stack.imgur.com/SZHYn.png" alt="Back button">), it still populates the date in the EditText. How do I dismiss the dialog without returning any value from it.</p>
  
  <p>This is code I've got-</p>
  
  <p>The activity which invokes the fragment:</p>
  
  <pre><code>public class TransactionActivity extends FragmentActivity implements iRibbonMenuCallback {        
      .....
      public void selectDate(View view) { 
          // This is the method invoked by the button
          SelectDateFragment newFragment = new SelectDateFragment();
          newFragment.show(getSupportFragmentManager(), "DatePicker");
      }
  
      public void populateSetDate(int year, int month, int day) {
          // Puts the date in the EditText box
          mEdit = (EditText)findViewById(R.id.DateText);
          mEdit.setText(month+"/"+day+"/"+year);
      }
  }
  </code></pre>
  
  <p>A fragment for the Dialog (based on <a href="http://developer.android.com/guide/topics/ui/controls/pickers.html" rel="noreferrer">this</a> page on Android API guides):</p>
  
  <pre><code>public class SelectDateFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState) {
          final Calendar calendar = Calendar.getInstance();
          int yy = calendar.get(Calendar.YEAR);
          int mm = calendar.get(Calendar.MONTH);
          int dd = calendar.get(Calendar.DAY_OF_MONTH);
          return new DatePickerDialog(getActivity(), this, yy, mm, dd);
      }
  
      public void onDateSet(DatePicker view, int yy, int mm, int dd) {
               // Calls a method on the activity which invokes this fragment
           ((TransactionActivity)getActivity()).populateSetDate(yy, mm+1, dd);    
  
      }
  }
  </code></pre>
  
  <p>There doesn't seem to be a method analogous with onDataSet for handling the case when data was not set.</p>
  
  <p>Is there a way to cancel/dismiss the popped up datepicker without getting it's value?</p>
  
  <p>Thanks.</p>