AlarmManager should be repeated every 1 minute, but repeated every 1, 2, 3 or 4 minutes.
Since the application I throw AlarmManager
public class Paciente
As of KitKat (API 19), alarms are inexacted and batched together to preserve battery life by minimizing the number of times the device needs to wake up.
From the AlarmManager documentation for setRepeating()
:
Note: as of API 19, all repeating alarms are inexact. If your application needs precise delivery times then it must use one-time exact alarms, rescheduling each time as described above. Legacy applications whose
targetSdkVersion
is earlier than API 19 will continue to have all of their alarms, including repeating alarms, treated as exact.
For more precision you will need to use setExact() and reschedule an alarm every time an alarm wakes up your app. Do so very carefully though, as setting frequent alarms (such as every 1 minute) will dramatically decrease your users' battery life.
From the setExact()
documenation:
Note: only alarms for which there is a strong demand for exact-time delivery (such as an alarm clock ringing at the requested time) should be scheduled as exact. Applications are strongly discouraged from using exact alarms unnecessarily as they reduce the OS's ability to minimize battery use.