title: android prevent immediate trigger of alarm service if alarm time has passed for the day
body: <p>The reference for Alarm Manager says that </p>
  
  <blockquote>
    <p>If the stated trigger time is in the past, the alarm will be triggered
    immediately.</p>
  </blockquote>
  
  <p>I am facing this problem in my application. Here is my alarm manager code :</p>
  
  <pre><code>Intent myIntent = new Intent(getActivity(), DinnerAlarmReceiver.class);
                  pendingDinnerIntent = PendingIntent.getBroadcast(getActivity(), 0, myIntent, 0);
  
                  Calendar calendar = Calendar.getInstance();
                  calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
                  calendar.set(Calendar.MINUTE, minute);
  
                  alarmManager.set(AlarmManager.RTC_WAKEUP,
                          calendar.getTimeInMillis(), pendingDinnerIntent);
  </code></pre>
  
  <p>Is there any workaround to this problem?</p>
  
  <p><strong>-----EDIT------</strong></p>
  
  <p>I have written some code to estimate if the set time for the alarm is before the current time . Here is the above portion with corresponding changes : </p>
  
  <pre><code>Calendar calendar = Calendar.getInstance();
                  long currentTime = calendar.getTimeInMillis();
                  calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
                  calendar.set(Calendar.MINUTE, minute);
                  long setTime = calendar.getTimeInMillis();
                  Timestamp setTimestamp = new Timestamp(setTime);
                  Timestamp currentTimestamp = new Timestamp(currentTime);
                  if (setTimestamp.after(currentTimestamp))
                  {
                      alarmManager.set(AlarmManager.RTC_WAKEUP,
                              calendar.getTimeInMillis(), pendingDinnerIntent);
                  }
                  else
                  {
                  }
  </code></pre>
  
  <p>What should I the <code>alarmManager</code> to in case <code>setTimestamp</code> is before <code>currentTimestamp</code> ?</p>