Configure Alarm Manager on specific days

I am creating an application that uses an alarm manager. The user sets the day and time, and there are 7 flags, one for each day of the week, and those that they mark will exit them the other day. As I know, you can put the date and time in the alarm manager, is there a way that I can put both day and time in the alarm manager, and they will go away that day every week?

+3
android
source share
1 answer

AlarmManager.setRepeating takes as a parameter:

type One of ELAPSED_REALTIME, ELAPSED_REALTIME_WAKEUP}, RTC, or RTC_WAKEUP.

Here you will need RTC or RTC_WAKEUP

triggerAtTime The time during which the alarm should first turn off using the appropriate clock (depending on the type of alarm).

Here you indicate the date / time of the first alarm (I believe this is UTC, so be careful)

Calendar calendar = new GregorianCalendar(2011, Calendar.APRIL, 19, 23, 12); long firstTime = calendar.getTimeInMillis(); 

interval Interval between subsequent alarms.

Repeating every week, you will indicate the number of milliseconds for the whole week as an interval:

 long interval = 1000 * 60 * 60 * 24 * 7; 

or

 long interval = 7 * AlarmManager.INTERVAL_DAY; 
+6
source share

All Articles