From 5e3d2688159e075190dd446adace467f5bfa25d1 Mon Sep 17 00:00:00 2001 From: jens Date: Sun, 31 Dec 2023 15:59:02 +0100 Subject: [PATCH] date time trigger set to wakeup --- .../com/jens/automation2/receivers/DateTimeListener.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/jens/automation2/receivers/DateTimeListener.java b/app/src/main/java/com/jens/automation2/receivers/DateTimeListener.java index 75f49e78..be4079ab 100644 --- a/app/src/main/java/com/jens/automation2/receivers/DateTimeListener.java +++ b/app/src/main/java/com/jens/automation2/receivers/DateTimeListener.java @@ -29,7 +29,7 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis { private static AutomationService automationServiceRef; private static AlarmManager centralAlarmManagerInstance; - private static boolean alarmListenerActive=false; + private static boolean alarmListenerActive = false; private static ArrayList alarmCandidates = new ArrayList<>(); private static ArrayList requestCodeList = new ArrayList(); static PendingIntent alarmPendingIntent = null; @@ -250,7 +250,10 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis else alarmPendingIntent = PendingIntent.getBroadcast(automationServiceRef, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); - centralAlarmManagerInstance.set(AlarmManager.RTC_WAKEUP, scheduleCandidate.time.getTimeInMillis(), alarmPendingIntent); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) + centralAlarmManagerInstance.setAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, scheduleCandidate.time.getTimeInMillis(), alarmPendingIntent); + else + centralAlarmManagerInstance.set(AlarmManager.RTC_WAKEUP, scheduleCandidate.time.getTimeInMillis(), alarmPendingIntent); SimpleDateFormat sdf = new SimpleDateFormat("E dd.MM.yyyy HH:mm:ss"); Calendar calendar = Calendar.getInstance();