date time trigger set to wakeup

This commit is contained in:
jens 2023-12-31 15:59:02 +01:00
parent a21f90acb5
commit 5e3d268815

View File

@ -29,7 +29,7 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
{ {
private static AutomationService automationServiceRef; private static AutomationService automationServiceRef;
private static AlarmManager centralAlarmManagerInstance; private static AlarmManager centralAlarmManagerInstance;
private static boolean alarmListenerActive=false; private static boolean alarmListenerActive = false;
private static ArrayList<ScheduleElement> alarmCandidates = new ArrayList<>(); private static ArrayList<ScheduleElement> alarmCandidates = new ArrayList<>();
private static ArrayList<Integer> requestCodeList = new ArrayList<Integer>(); private static ArrayList<Integer> requestCodeList = new ArrayList<Integer>();
static PendingIntent alarmPendingIntent = null; static PendingIntent alarmPendingIntent = null;
@ -250,7 +250,10 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
else else
alarmPendingIntent = PendingIntent.getBroadcast(automationServiceRef, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); 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"); SimpleDateFormat sdf = new SimpleDateFormat("E dd.MM.yyyy HH:mm:ss");
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();