title: ANDROID - setOnDismissListener on a DialogFragment
body: <p>I've got a <code>DialogFragment</code> used to display a <code>TimePickerDialog</code> when pressing a <code>button</code>, and I would like to change the text of the button to the new time set.</p>
  
  <p>My problem is I can't call <code>setOnDismissListener</code> on the <code>DialogFragment</code> from my <code>Activity</code>.</p>
  
  <p><strong>This is my DialogDragment</strong> </p>
  
  <pre><code> public class TimePickerFragment extends DialogFragment
          implements TimePickerDialog.OnTimeSetListener {
  
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState) {
          int hour = Application.getSettings().getInt("hour", 11);
          int minute = Application.getSettings().getInt("minute", 11);
  
          // Create a new instance of TimePickerDialog and return it
          return new TimePickerDialog(getActivity(), this, hour, minute,
                  DateFormat.is24HourFormat(getActivity()));
      }
  
      @Override
      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
          FirstTimeLaunchSettingsActivity.hours = hourOfDay;
          FirstTimeLaunchSettingsActivity.minutes = minute;
  
      }
  }
  </code></pre>
  
  <p>And this is <strong>how I call this DialogFragment</strong></p>
  
  <pre><code>    public void showTimePickerDialog(View v) {
      DialogFragment newFragment = new TimePickerFragment();
      newFragment.show(this.getFragmentManager(), "timePicker");
  }
  </code></pre>
  
  <p>I've already thought making a <code>Handler</code> in my <code>activity</code> which would <code>refresh</code> the <code>Activity</code> every seconde, but that's not how I would like to solve the problem.</p>
  
  <p>I just want, when I close my <code>DialogFragment</code>, my button to be set to the time I've entered.</p>
  
  <p>Thanks for your help.</p>