How to repeat the alarm for “n” days at a particul

2019-06-10 08:27发布

问题:

This is my code to set the alarm for every 24 hours. How can I repeat this for 20 days only?

alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 
     calendar.getTimeInMillis(), 
     24*60*60*1000, 
     pendingIntent);

回答1:

that will be repeating forever until you cancel it. So, what you can do, it's to fire something in 20 days,and when managing that event, cancel your alarm.