我想在星期一设置闹钟,但它不能正常工作,所以如何在星期一只设置一次闹钟。
if (chk_wednesday.isChecked()) {
weekday = 7 - calNow.get(Calendar.DAY_OF_WEEK);
calSet.add(Calendar.DATE, weekday);
forday(weekday);
}
public void forday(int week) {
days = calNow.get(Calendar.DAY_OF_MONTH);
month = calNow.get(Calendar.MONTH);
year = calNow.get(Calendar.YEAR);
calSet.set(Calendar.DAY_OF_WEEK, week);
calSet.set(Calendar.HOUR_OF_DAY, hour);
calSet.set(Calendar.MINUTE, minuts);
calSet.set(Calendar.SECOND, 0);
calSet.set(Calendar.MILLISECOND, 0);
calSet.set(Calendar.DAY_OF_MONTH, days);
calSet.set(Calendar.MONTH, month);
calSet.set(Calendar.YEAR, year);
if (calSet.compareTo(calNow) <= 0) {
// Today Set time passed, count to tomorrow
calSet.add(Calendar.DATE, 1);
}
Log.i("time1", "" + calSet.getTimeInMillis());
alarmManager.set(AlarmManager.RTC_WAKEUP, calSet.getTimeInMillis(),
pendingIntent);
}
任何人帮助我。在此先感谢