title: Passing Integer Value to Broadcast Receiver class
body: <p>I am trying to get start time and stop time from user using Time Picker in one class and then passing this time to the broadcast class.</p>
  
  <p>But when I am checking whether the values of the start time and stop time is reached in the Broadcast Receiver class by using a toast message, I am not able to get the required start time or stop time that is passed.</p>
  
  <p>CODE [Main Class]:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.setting);
      initialize();
      alarmIntent = new Intent(Settings.this, AlarmReceiver.class);
      pendingIntent = PendingIntent.getBroadcast(Settings.this, 0, alarmIntent, PendingIntent.FLAG_CANCEL_CURRENT);
      alarmRepeat();              
  }
  @Override
  public void onClick(View v) {
      // TODO Auto-generated method stub
      Calendar c = Calendar.getInstance();
      switch(v.getId()){
      case R.id.startTime :
          // Process to get Current Time
          startHour = c.get(Calendar.HOUR_OF_DAY);
          startMinute = c.get(Calendar.MINUTE);
  
          // Launch Time Picker Dialog
          TimePickerDialog tpd1 = new TimePickerDialog(this,
                  new TimePickerDialog.OnTimeSetListener() {
  
                      @Override
                      public void onTimeSet(TimePicker view, int hourOfDay,
                              int minute) {
                          // Display Selected time in textbox
                          eStart.setText(hourOfDay + ":" + minute);
                          startHour = hourOfDay;
                          startMinute = minute;
                          alarmIntent.putExtra("startHour", startHour);
                          alarmIntent.putExtra("startMinute", startMinute);//passing these variables to Broadcast class
                      }
                  }, startHour, startMinute, false);
          tpd1.show();
  
  public void alarmRepeat(){
      Calendar cal = Calendar.getInstance();
      AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
      manager.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 1000, pendingIntent);
  }
  </code></pre>
  
  <p><strong>Broadcast Class :</strong></p>
  
  <pre><code>public void onReceive(Context context, Intent intent) {
      // TODO Auto-generated method stub
      startHour = intent.getIntExtra("startHour", 0);
      stopHour = intent.getIntExtra("StopHour", 0);
  
      Toast.makeText(context, startHour + ":" + startMinute, Toast.LENGTH_LONG).show();
  </code></pre>
  
  <p><strong>Program explanation</strong>: I have passed startHour and startMinute from the onTimeSet method in the main class to broadcast class.</p>
  
  <p>In the Broadcast Class I am storing this startHour and StopMinute in the variables as defined above.</p>