Search code examples
androidalarmmanager

How to repeat the alarm for "n" days at a particular time


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);

Solution

  • 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.