title: AlarmManager Being Triggered immediately because time occurs in the past
body: <p>When launching my application, the AlarmManager is being triggered immediately because the time occurs in the past. </p>
  
  <p>My idea was to check the actual time with the schedule one :</p>
  
  <pre><code>if(calendar.before(Calendar.getInstance())); //where calendar is my scheduled calendar
  </code></pre>
  
  <p>If the above condition is true then:</p>
  
  <pre><code>calendar.add(Calendar.DAY_OF_YEAR, 1);
  </code></pre>
  
  <p>I think this will work. </p>
  
  <p>However the confusion is at day 365:</p>
  
  <p>If the scheduled time was before the Actual time, it will add one day according to this line: <code>calendar.add(Calendar.DAY_OF_YEAR, 1);</code> 
  and it will become <strong>1</strong></p>
  
  <p>Doesn't that make it always in the past? Because there is no 366 ? Thus the AlarmManager will be always triggering it immediately considering it in the past?</p>
  
  <p>EDIT:</p>
  
  <p>Do you suggest I put instead :</p>
  
  <pre><code>calendar.add(Calendar.HOUR_OF_DAY, 24);
  </code></pre>