0

I've been doing a research about exact repeat alarm for API 19 and above and I've found that all alarm repeating are inexact from API 19. I'd like to know how to handle alarm repeating part for API 19 and above.

I found this:

you'll need to handle the "repeating" part manually.

took from here: How to set an exact repeating alarm on API 19 (kitkat)?

how do I handle the "repeating" part manually?

Community
  • 1
  • 1
iYonatan
  • 916
  • 3
  • 10
  • 26
  • simply: it´s time and your alarm is coming up. Exact at this time, you have to start the next alarm. In Your BroadcastReceiver where you catch the alarm, there you have to start the next one. – Opiatefuchs Sep 23 '16 at 13:16
  • 1
    Set the exact alarm again whenever it fires, kinda like is shown here: http://stackoverflow.com/questions/28269752/repeat-alarm-manager-at-exact-interval-in-api-19. – Mike M. Sep 23 '16 at 13:16
  • 1
    @MikeM. Thanks :) – iYonatan Sep 23 '16 at 13:26

1 Answers1

-1

Use this:

public void scheduleAlarm() {
        Long time = new GregorianCalendar().getTimeInMillis()+1000 * 60 * 60 * 24;// current time + 24 Hrs
        Intent intent = new Intent(this, AlarmReceiver.class);
        PendingIntent intentAlarm  = PendingIntent.getBroadcast(this, 0, intent, 0);
        AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, time, 1000 * 60 * 60 * 24, intentAlarm);// 24 Hrs
        Toast.makeText(this, "Alarm Scheduled for 24 Hrs", Toast.LENGTH_LONG).show();
    }
nishith kumar
  • 981
  • 7
  • 20