title: Returning String from Dialog Fragment back to Activity
body: <p>I have read many posts on this but I can't find any that apply to this case.</p>
  
  <p>I have a time picker dialog and I have put the integer values together in a string and I need to get this string back to the main activity.</p>
  
  <p>This string value will then be used to set the text of a button.</p>
  
  <p>If someone could help me with this it would be most appreciated.</p>
  
  <p>Thank you </p>
  
  <p><strong>Dialog Fragment</strong></p>
  
  <pre><code>public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState) {
          // Use the current time as the default values for the picker
          final Calendar c = Calendar.getInstance();
          int hour = c.get(Calendar.HOUR_OF_DAY);
          int minute = c.get(Calendar.MINUTE);
  
          // Create a new instance of TimePickerDialog and return it
          return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
      }
  
      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
          // Do something with the time chosen by the user
          String Time =Integer.toString(hourOfDay) + " : " + Integer.toString(minute);
      }
  }
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_second);
  
  
          Button btn = (Button) findViewById(R.id.start_time_button);
          Button.setText(Time);
  
  
      }
  </code></pre>