1

i want to set reminder with notification

this is my code :

        Calendar calSet = Calendar.getInstance();
        calSet.set(Calendar.HOUR_OF_DAY, 20);
        calSet.set(Calendar.MINUTE, 30);
        calSet.set(Calendar.SECOND, 0);
        calSet.set(Calendar.MILLISECOND, 0);

        PendingIntent.getBroadcast(context, reminder.getReminderId(),
                intent, PendingIntent.FLAG_UPDATE_CURRENT);
        AlarmManager alarmManager = (AlarmManager) c
                .getSystemService(Context.ALARM_SERVICE);

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

this is suppose to show call my receiver every day in 20:30 , it does but in a delay..sometimes of 10 seconds and sometimes 50+ seconds...

what am i missing ? what can make this delay happen ?

Jesus Dimrix
  • 4,378
  • 4
  • 28
  • 62
  • 1
    There is a separate call for exact timing. This changed in one of the recent releases. Try setExact instead. – mjstam Feb 12 '15 at 17:17
  • what is the different ?why using setRepeating if we gut setInexactRepeating ? – Jesus Dimrix Feb 12 '15 at 18:15
  • http://stackoverflow.com/questions/21232984/difference-between-setrepeating-and-setinexactrepeating-of-alarmmanager – Jesus Dimrix Feb 12 '15 at 18:16
  • ok ill check this an will update if this solve the issue – Jesus Dimrix Feb 12 '15 at 18:17
  • 1
    From the alarm manager doc Note: Beginning with API 19 (KITKAT) alarm delivery is inexact: the OS will shift alarms in order to minimize wakeups and battery use. There are new APIs to support applications which need strict delivery guarantees; see setWindow(int, long, long, PendingIntent) and setExact(int, long, PendingIntent). Applications whose targetSdkVersion is earlier than API 19 will continue to see the previous behavior in which all alarms are delivered exactly when requested. – mjstam Feb 12 '15 at 18:17

0 Answers0