title: DatePickerDialog listener
body: <p>I am making an Android app where I use a <code>DatePickerDialog</code>. The intended function is for the user to select a date in the dialog, and then for a <code>TextView</code> to reflect that chosen date. However, I can't find any sort of a click listener to notify my Activity when the user has selected a date. I am looking for a way to detect when the user has selected a date, but from my main Activity. This is my <code>DatePickerDialog</code> class:</p>
  
  <pre><code>public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
  
  private GregorianCalendar date;
  
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
      // Use the current date as the default date in the picker
      final Calendar c = Calendar.getInstance();
      int year = c.get(Calendar.YEAR);
      int month = c.get(Calendar.MONTH);
      int day = c.get(Calendar.DAY_OF_MONTH);
  
      // Create a new instance of DatePickerDialog and return it
      return new DatePickerDialog(getActivity(), this, year, month, day);
  }
  
  @Override
  public void onDateSet(DatePicker datePicker, int year, int month, int day) {
      date = new GregorianCalendar(year, month, day);
  }
  
  public GregorianCalendar getDate() {
      return date;
  }
  }    
  </code></pre>
  
  <p>And the code where I launch the dialog:</p>
  
  <pre><code>DialogFragment datePicker = new DatePickerFragment();
  datePicker.show(getSupportFragmentManager(), "datePicker");
  </code></pre>
  
  <p>I currently launch the dialog from a class that extends <code>Activity</code>, and I am looking for a way to detect from within that class if a user has selected a date from the dialog. Any suggestions?</p>