title: How to get value TimePicker inside AlertDialog?
body: <p>I have a TimePicker that is generated within a AlertDialog so do not know what your ID. How to get the value set by the user? I want to send you a notification to him every day at this time (I already have a prompt notification). 
  And then: what they suggest?` </p>
  
  <pre><code>/** Private members of the class */
  private TextView MostraTime;
  private Button Time;
  
  private int DayHour;
  private int DayMinute;
  
  Intent VoltaMenu;
  
  /**
   * This integer will uniquely define the dialog to be used for displaying
   * time picker.
   */
  static final int TIME_DIALOG_ID = 0;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.notify);
  
      /** Capture our View elements */
  
      MostraTime = (TextView) findViewById(R.id.MostraTempo);
      Time = (Button) findViewById(R.id.TempoAlerta);
  
      /** Listener for click event of the button */
      Time.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
  
              showDialog(TIME_DIALOG_ID);
          }
      });
  
      /** Get the current time */
      final Calendar cal = Calendar.getInstance();
      DayHour = cal.get(Calendar.HOUR_OF_DAY);
      DayMinute = cal.get(Calendar.MINUTE);
  
      /** Display the current time in the TextView */
      updateDisplay();
  
  }
  
  @Override
  protected Dialog onCreateDialog(int id) {
      switch (id) {
      case TIME_DIALOG_ID:
          return new TimePickerDialog(this, mTimeSetListener, DayHour,
                  DayMinute, false);
  
      }
      return null;
  }
  
  /** Callback received when the user "picks" a time in the dialog */
  private TimePickerDialog.OnTimeSetListener mTimeSetListener = new TimePickerDialog.OnTimeSetListener() {
      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
  
          DayHour = hourOfDay;
          DayMinute = minute;
          updateDisplay();
          displayToast();
      }
  };
  
  /** Updates the time in the TextView */
  private void updateDisplay() {
      MostraTime.setText(new StringBuilder().append(pad(DayHour)).append(":")
              .append(pad(DayMinute)));
  }
  
  /** Displays a notification when the time is updated */
  private void displayToast() {
  
      VoltaMenu = new Intent(MenuNotificacao.this, Prefs.class);
      startActivity(VoltaMenu);
  
      Toast.makeText(
              this,
              new StringBuilder().append(
                      getResources().getString(R.string.horario) + " ")
                      .append(MostraTime.getText()), Toast.LENGTH_SHORT)
              .show();
  
  }
  
  /** Add padding to numbers less than ten */
  private static String pad(int c) {
      if (c &gt;= 10)
          return String.valueOf(c);
      else
          return "0" + String.valueOf(c);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>`</p>