这些问题与你想要的一样.这些答案将会有所帮助:
您只需指定启动日期,然后每7天重复一次.在给定问题的答案中指定的方法很少:
更新:
在你的评论中你说
How to set the triggerAtMillis part in setRepeating. say for example today is Tuesday,I choose weekly Monday,Wednesday,Friday. – What do I put for Wednesday ?
我明白,如果今天是星期二,如何设置闹钟让我们说星期三重复,对吧?首先,您可以使用mulltiple id来分别设置每天的闹钟.
然后可以添加alarmCalendar.set(Calendar.DAY_OF_WEEK,week);符合您现有的代码.根据本周(从1-7起),当天重复.您可以将其作为参数传递给函数.喜欢:
setAlarm(2); //set the alarm for this day of the week
public void setAlarm(int dayOfWeek) {
// Add this day of the week line to your existing code
alarmCalendar.set(Calendar.DAY_OF_WEEK,dayOfWeek);
alarmCalendar.set(Calendar.HOUR,AlarmHrsInInt);
alarmCalendar.set(Calendar.MINUTE,AlarmMinsInInt);
alarmCalendar.set(Calendar.SECOND,0);
alarmCalendar.set(Calendar.AM_PM,amorpm);
Long alarmTime = alarmCalendar.getTimeInMillis();
//Also change the time to 24 hours.
am.setRepeating(AlarmManager.RTC_WAKEUP,24 * 60 * 60 * 1000,pi);
}
我从上述问题中抽出了一个例子.希望现在更清楚.