From 9e24bec144f3aeddc1195c6da7723051eaed9e10 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 29 Sep 2019 18:00:58 +0200 Subject: [PATCH] Fixed wakeup in doze mode --- app/src/main/java/eu/faircode/email/EntityMessage.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/EntityMessage.java b/app/src/main/java/eu/faircode/email/EntityMessage.java index e9c9151e88..41d4feb315 100644 --- a/app/src/main/java/eu/faircode/email/EntityMessage.java +++ b/app/src/main/java/eu/faircode/email/EntityMessage.java @@ -23,6 +23,7 @@ import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; +import android.os.Build; import androidx.annotation.NonNull; import androidx.room.Entity; @@ -235,7 +236,10 @@ public class EntityMessage implements Serializable { am.cancel(pi); } else { Log.i("Set snooze id=" + id + " wakeup=" + new Date(wakeup)); - am.set(AlarmManager.RTC_WAKEUP, wakeup, pi); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) + am.set(AlarmManager.RTC_WAKEUP, wakeup, pi); + else + am.setAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, wakeup, pi); } }