title: Alarm Manager set Daily Alarm at a specific time?
body: <p>I've been working on this application that is supposed to run at a given time daily, except on weekends. I've used an <code>AlarmBroadCastReceiver</code> to fire a certain block of code at a given time. I have this code in my <code>AlarmBroadCastReceiver</code> class:</p>
  
  <pre><code>public void SetAlarm(Context context) {
      AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
      Intent intent = new Intent(context, AlarmManagerBroadcastReceiver.class);
      intent.putExtra(ONE_TIME, Boolean.FALSE);
      PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0);
  
      Calendar calendar = Calendar.getInstance();
      calendar.setTimeInMillis(System.currentTimeMillis());
      calendar.set(Calendar.HOUR_OF_DAY, 2);
      calendar.set(Calendar.MINUTE, 30);
      calendar.set(Calendar.SECOND, 0);
      am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 0, pi);
  
  }
  </code></pre>
  
  <p>Basically I try and set a repeating alarm on that time.</p>
  
  <p>Then at a press of a button, I have this in my MainActivity where I'm calling it from:</p>
  
  <pre><code>public void onStartAlarmClicked(View view){
      Context context = this.getApplicationContext();
      if(alarm != null){
          Log.e(TAG, "starting alarm");
          alarm.SetAlarm(context);
      }else{
          Log.e(TAG, "Alarm is null");
      }
  }
  </code></pre>
  
  <p>where <code>alarm</code> is an object of the <code>AlarmBroadCastReceiver</code> class. </p>
  
  <p>The problem I have with it is that the code only fires once. Once it hits 2:30, it fires. However, when I set the time back to 2:29 and wait for 2:30, or set the date 1 day forward and then set the time to 2:20 and wait for 2:30, the code no longer fires.</p>
  
  <p>I have a feeling I'm overlooking something rather simple with regards to setting the alarm time but I can't see it right now.</p>