I am using an AlarmManager in a Service to be triggered every minute.
PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(), 0,
You should probably use
AlarmManager#setExact(int type, long triggerAtMillis, PendingIntent operation)
instead of
AlarmManager#set(int type, long triggerAtMillis, PendingIntent operation))
Take a look
From google :
AlarmManager#set(int type, long triggerAtMillis, PendingIntent operation))
Note: Beginning in API 19, the trigger time passed to this method is treated as inexact: the alarm will not be delivered before this time, but may be deferred and delivered some time later. The OS will use this policy in order to "batch" alarms together across the entire system, minimizing the number of times the device needs to "wake up" and minimizing battery use. In general, alarms scheduled in the near future will not be deferred as long as alarms scheduled far in the future.
Edit :
What i am using for an alarm application :
Manifest :
<uses-permission android:name="android.permission.WAKE_LOCK"/>
Java Code :
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AlarmManager.AlarmClockInfo alarmClockInfo = new AlarmManager.AlarmClockInfo(nextAlarm.getTimeInMillis(), pendingIntent);
alarmManager.setAlarmClock(alarmClockInfo, pendingIntent);
}else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
alarmManager.setExact(android.app.AlarmManager.RTC_WAKEUP, nextAlarm.getTimeInMillis(), pendingIntent);
}else {
alarmManager.set(android.app.AlarmManager.RTC_WAKEUP, nextAlarm.getTimeInMillis(), pendingIntent);
}