title: Android-Multiple Alarms with different timings fires at wrong time
body: <p>I have four <code>Repeating Alarms</code> in my app each of which fires at different timings to do some important tasks.
  They are</p>
  
  <ol>
  <li>Alarm 1 - 12:30 AM</li>
  <li>Alarm 2 - 01:00 AM</li>
  <li>Alarm 3 - 06:00 AM</li>
  <li>Alarm 4 - 12:15 PM</li>
  </ol>
  
  <p>Every alarm fires no problems. Time interval for each alarms are <code>24 hrs</code>. But each of the firing at random timings.</p>
  
  <p><code>Alarm      Set Time    Actual Firing Time
  Alarm 1     12:30 AM    06:31 AM
  Alarm 2     01:00 AM    06:01 AM
  Alarm 3     06:00 AM    06:01 AM
  Alarm 4     12:15 PM    Still not fired 4 hours after that time</code></p>
  
  <p><strong>My Code was</strong></p>
  
  <p>Alarm 1</p>
  
  <pre><code>Intent myIntent=new Intent(MainPage.this,db_restore.class);
  
  PendingIntent pi=PendingIntent.getBroadcast(MainPage.this,1,myIntent,0);
  
  AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
  
  Calendar calendar = Calendar.getInstance();
  
  calendar.add(Calendar.DATE, 1);
  calendar.set(Calendar.HOUR_OF_DAY, 12);
  calendar.set(Calendar.MINUTE, 30);
  calendar.set(Calendar.SECOND,0);
  calendar.set(Calendar.AM_PM,Calendar.AM);
  
  alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),1000*60*60*24,pi);
  </code></pre>
  
  <p>Alarm 2</p>
  
  <pre><code>Intent mor_flag=new Intent(MainPage.this,MorningFlag.class);
  
  PendingIntent mor_intent=PendingIntent.getBroadcast(MainPage.this,3,mor_flag,0);
  
  AlarmManager mor_alarm=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
  
  Calendar calendar=Calendar.getInstance();
  
  calendar.add(Calendar.DATE, 1);
  calendar.set(Calendar.HOUR_OF_DAY, 1);
  calendar.set(Calendar.MINUTE, 0);
  calendar.set(Calendar.SECOND,0);
  calendar.set(Calendar.AM_PM,Calendar.AM);
  
  mor_alarm.setRepeating(AlarmManager.RTC_WAKEUP,calendar.getTimeInMillis(),1000*60*60*24,mor_intent);
  </code></pre>
  
  <p>Alarm 3</p>
  
  <pre><code>Intent late_start1=new Intent(MainPage.this,late_start.class);
  
  PendingIntent piLate=PendingIntent.getBroadcast(MainPage.this,2,late_start1,0);
  
  AlarmManager alarmManager=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
  
  Calendar calendar=Calendar.getInstance();
  
  calendar.add(Calendar.DATE, 1);
  calendar.set(Calendar.HOUR_OF_DAY, 6);
  calendar.set(Calendar.MINUTE, 0);
  calendar.set(Calendar.SECOND,0);
  calendar.set(Calendar.AM_PM,Calendar.AM);
  
  alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 1000*60*60*24, piLate);
  
  Toast.makeText(MainPage.this,"Alarm Service started for Late Start monitoring",Toast.LENGTH_LONG).show();
  </code></pre>
  
  <p>Alarm 4</p>
  
  <pre><code>Intent eve_flag=new Intent(MainPage.this,EveningFlag.class);
  
  PendingIntent eve_intent=PendingIntent.getBroadcast(MainPage.this,4,eve_flag,0);
  
  AlarmManager eve_alarm=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
  
  Calendar calendar=Calendar.getInstance();
  
  calendar.add(Calendar.DATE, 1);
  calendar.setTimeInMillis(System.currentTimeMillis());
  calendar.set(Calendar.HOUR_OF_DAY, 12);
  calendar.set(Calendar.MINUTE, 15);
  calendar.set(Calendar.SECOND,0);
  calendar.set(Calendar.AM_PM, Calendar.PM);
  
  eve_alarm.setRepeating(AlarmManager.RTC_WAKEUP,calendar.getTimeInMillis(),1000*60*60*24,eve_intent);
  </code></pre>
  
  <p>I don't know what I'm doing wrong. Please take a look and help me. Thanks.</p>
  
  <p><strong>Note:</strong> I'm checking this in <code>API Level 19</code> <code>Android 4.4.4</code> with minimum as 14.</p>