On Marshmallow (23) and up, Doze mode can kick in and prevent timers from firing. I normally have my phone on a charger overnight, which apparently stops Doze mode from engaging. However, last night I did not, and as a result, crond did not start my job at the correct time.
There is a whitelist that end users can use that can help (Settings -> Battery -> Battery Optimization), but the best way to avoid the issue is to call a different API method:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, next.getMillis(), alarmIntent);
} else {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, next.getMillis(), alarmIntent);
}
On Marshmallow (23) and up, Doze mode can kick in and prevent timers from firing. I normally have my phone on a charger overnight, which apparently stops Doze mode from engaging. However, last night I did not, and as a result, crond did not start my job at the correct time.
There is a whitelist that end users can use that can help (Settings -> Battery -> Battery Optimization), but the best way to avoid the issue is to call a different API method: