I create an AlarmManager and set up a call every 15 minutes. I assign half the current hour as the call point (in this case, 1:30 pm), but the AlarmManager is one minute late, and then another minute late! Then I get an even stranger result: my BroadcastReciever is called 2 minutes earlier and works exactly in an hour, then everything goes fine, every 15 minutes. Here is the log:

 11-01 13:31:07.940 26601-26601/? I/RLOG: onReceive 11-01 13:47:44.703 26601-26601/? I/RLOG: onReceive 11-01 14:00:47.623 26601-26601/? I/RLOG: onReceive 11-01 14:15:00.601 26601-26601/? I/RLOG: onReceive 11-01 14:30:00.587 26601-26601/? I/RLOG: onReceive 

Here is my calling code:

  Intent intent = new Intent(mContext, NotificationShower.class); intent.putExtra(NotificationShower.EXTRA_NOTIFICATIONS_ARRAY, notifications); PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); alarmManager.setRepeating( AlarmManager.RTC_WAKEUP, nextHourInMs() - 30 * 60 * 1000, AlarmManager.INTERVAL_FIFTEEN_MINUTES, pendingIntent); 

Why AlarmManager work after the designated time several times in a row, and then “catch up” the lost time?

    1 answer 1

    The official documentation says that alarmmanger does not guarantee execution at the exact time.