Skip to content

Marshmallow Doze issue #13

@a1291762

Description

@a1291762

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);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions