How can I create a multiple repeating alarm. As an example I have created an alarm at 4:30 PM , and I want to repeat it in each Sunday, Monday and Thursday. I can schedule periodic alarm like repeat after interval , but how can I accomplish this ?
Asked
Active
Viewed 341 times
1 Answers
0
Hello this is an example of adding an alarm once a month.
private void setAlarmForOneMonth() {
AlarmManager mAlarmMgr = (AlarmManager) CONTEXT.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(CONTEXT, YOURALARMRECEIVERCLASS);
PendingIntent mAlarmIntent = PendingIntent.getBroadcast(CONTEXT, ONE_MONTH_ALARM, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mAlarmMgr.set(AlarmManager.RTC_WAKEUP, getDuration(), mAlarmIntent);
}
private long getDuration() {
Calendar calendar = Calendar.getInstance();
int updatedMonthValue = calendar.get(Calendar.MONTH) + 1;
calendar.set(Calendar.MONTH, updatedMonthValue);
return calendar.getTimeInMillis(); // this is what you set as trigger point time i.e one month after
}
Also you can read more on this link Alarm Manager

Aris Panayiotou
- 142
- 6