title: How to set Alarm for working days in android
body: <p>I have a scenario</p>
  
  <p>Setting alarm for (Monday to Friday)</p>
  
  <p>Let say I choose time that is: <code>hour = 9, minutes = 15, am_pm = "AM"</code>.</p>
  
  <p>Now I want to set Alarm for every <code>Monday to Friday at 9:15 AM</code></p>
  
  <p>Code below I tried but not getting desired result.</p>
  
  <pre><code>if(choice.equals("Week Days (Mon-Fri)"))
  {
      for(int a = 2; a &lt;= 5; a++) //here I am assuming a is from 2 to 5 (calendar DAY_OF_WEEK from Monday to Friday)
      {
          Calendar alarmCalendar = Calendar.getInstance();
  
          alarmCalendar.set(Calendar.HOUR_OF_DAY, _hourOfDay);
  
          alarmCalendar.set(Calendar.MINUTE, _minute);
  
          alarmCalendar.set(Calendar.SECOND, 0);
  
          alarmCalendar.set(Calendar.MILLISECOND, 0);
  
          if(am_pm.equals("AM"))
          {
              alarmCalendar.set(Calendar.AM_PM, 0);
          }
          else
          {
              alarmCalendar.set(Calendar.AM_PM, 1);
          }
  
  
          alarmCalendar.set(Calendar.DAY_OF_WEEK, a);
  
          Long alarmTime = alarmCalendar.getTimeInMillis();
  
          alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 
                  alarmTime, 24 * 60 * 60 * 1000 , pendingIntent);
      }
  
      Toast.makeText(ActivityReminder.this, "Meeting Reminder Set on Week Days (Mon-Fri)", 
                          Toast.LENGTH_LONG).show();
  }
  </code></pre>
  
  <p>I've used <code>BroadcastReceiver</code> like:</p>
  
  <pre><code>public class AlarmReceiver extends BroadcastReceiver
  {
      NotificationManager mNotificationManager;
  
      Context context;
  
      public static final String TAG = "Reminder...";
  
      @Override
      public void onReceive(Context context, Intent intent)
      {
          this.context = context;
  
          String subject = "&lt;h3&gt;Meeting Reminder: &lt;/h3&gt;" + intent.getStringExtra("subject");
  
          Toast.makeText(context, Html.fromHtml(subject), Toast.LENGTH_LONG).show();
  
          showNotification(subject);
      }
  
      @SuppressWarnings("deprecation")
      private void showNotification(String msg) 
      {
          Intent notificationIntent = new Intent(context.getApplicationContext(),
                  ActivityMainScreen.class);
  
          TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
  
          stackBuilder.addParentStack(ActivityMainGeofence.class);
  
          stackBuilder.addNextIntent(notificationIntent);
  
          String arrivalTime = TimeUtil.toString(Calendar.getInstance().getTime(), 
                  "dd-MM-yyyy hh:mm:ss a");
  
          notificationIntent.putExtra("subject", msg)
          .putExtra("time", arrivalTime).putExtra("type", "Meetings/Reminder");
  
          PendingIntent notificationPendingIntent = stackBuilder
                  .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
  
          Notification notification = new Notification();
          notification.icon = R.drawable.app_icon;
  
          notification.setLatestEventInfo(context.getApplicationContext(), 
                  "WFM Meeting Reminder", Html.fromHtml(msg), notificationPendingIntent);
  
          notification.flags |= Notification.FLAG_AUTO_CANCEL;
  
          notification.defaults |= Notification.DEFAULT_SOUND;
  
          notification.defaults |= Notification.DEFAULT_VIBRATE;
  
          NotificationManager mNotificationManager = (NotificationManager) 
                  context.getSystemService(Context.NOTIFICATION_SERVICE);
  
          mNotificationManager.notify(0, notification);
  
      }
  }
  </code></pre>
  
  <p>Finally in Manifest:</p>
  
  <pre><code>&lt;receiver android:name="com.my_package_name.AlarmReceiver" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
              &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p><strong>EDITED:</strong>
  Here I want to tell that <code>One Time</code> Alarm worked for me but for above choice <code>Week Days (Mon-Fri)</code> is not working correctly</p>
  
  <p>The working code is:</p>
  
  <pre><code>if(choice.equals("One Time"))
  {
      alarmManager.set(AlarmManager.RTC_WAKEUP, PERIOD, pendingIntent); // here PERIOD is the time selected by me in milliseconds...
  
      Toast.makeText(ActivityReminder.this, "Meeting Reminder Set One Time", 
              Toast.LENGTH_LONG).show();
  }
  </code></pre>
  
  <p>Where am I doing wrong. Any help would be appreciated.</p>