这里的间隔是两个警报之间的时间(以毫秒为单位)。
//e.g
long interval=5*60*1000;
mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, mCalendar.getTimeInMillis(), interval , pendingIntent);
然后我的闹钟会在 5 分钟后重复一次。
编辑
int days=GetTotalDays(current_month);
interval=(days)*24*60*60*1000;
public int GetTotalDays(int current_month)
{
//here u can fetch current months total days
//suppose current month is 6(means july as it starts from 0)
//& u want to set alarm to next month(august)
//so get remaining days from calender of current month + day of next month
//e.g(14-7 to 14-8) so
//remaining days from calender of current month = 18(14-7 to 31-7)
//day of next month =14.
//so return would be (18+14-2=30).(-2.as it takes currentdate and nextdate also in calculation)
int currentdate=14;
int nextdate=14;
int totalDays=getDaysInMonthInPresentYear(6);
int myDays=(totalDays-currentdate)+nextdate;
return myDays-2;
}
public static int getDaysInMonthInPresentYear(int monthNumber)
{
int days=0;
if(monthNumber>=0 && monthNumber<12){
try
{
Calendar calendar = Calendar.getInstance();
int date = 1;
int year = calendar.get(Calendar.YEAR);
calendar.set(year, monthNumber, date);
days = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
} catch (Exception e)
{
if(e!=null)
e.printStackTrace();
}
}
return days;
}