我們可以從源收到currentMonth值,它是一個整數
if (currentMonth == Calendar.JANUARY || currentMonth == Calendar.MARCH || currentMonth == Calendar.MAY || currentMonth == Calendar.JULY
|| currentMonth == Calendar.AUGUST || currentMonth == Calendar.OCTOBER || currentMonth == Calendar.DECEMBER){
alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY * 31, alarmIntent);
}
if (currentMonth == Calendar.APRIL || currentMonth == Calendar.JUNE || currentMonth == Calendar.SEPTEMBER
|| currentMonth == Calendar.NOVEMBER){
alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY * 30, alarmIntent);
}
if (currentMonth == Calendar.FEBRUARY){//for feburary month)
GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();
if(cal.isLeapYear(year)){//for leap year feburary month
alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY * 29, alarmIntent);
}
else{ //for non leap year feburary month
alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY * 28, alarmIntent);
}
}
看看[這個](http://stackoverflow.com/questions/7568233/how-to-implement-yearly-and-monthly-repeating-alarms)有幫助。 – 2014-10-30 05:36:22
我想通過另一種方式發佈,作爲一個喉嚨,我認爲這是它可以工作 – mushahid 2014-10-30 05:56:14