Skip to content Skip to sidebar Skip to footer

Implementing An Alarm Every 5 Days, Code Correct?

I am trying to set an alarm every 5th day of the week and the 24th hour of that day. Here is the code i am using. Ive been reading over the Calendar and AlarmManager docs, a and he

Solution 1:

To get a Calendar instance, that points to a date 5 days in the future, you take the current date and add 5 days like this:

Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, 5);

Then you set your alarm:

am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
                pendingIntent);

Post a Comment for "Implementing An Alarm Every 5 Days, Code Correct?"