From 3199a0abdc37a7006457213d7a05d178fac3f764 Mon Sep 17 00:00:00 2001 From: jacques Date: Wed, 23 Mar 2022 09:16:47 +0100 Subject: [PATCH] Add isScheduled method to avoid schedule notification on each onPause of DrugListActivity. --- app/src/main/java/net/foucry/pilldroid/AlarmReceiver.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/net/foucry/pilldroid/AlarmReceiver.java b/app/src/main/java/net/foucry/pilldroid/AlarmReceiver.java index c2fe9ca..7912308 100644 --- a/app/src/main/java/net/foucry/pilldroid/AlarmReceiver.java +++ b/app/src/main/java/net/foucry/pilldroid/AlarmReceiver.java @@ -148,4 +148,10 @@ public class AlarmReceiver extends BroadcastReceiver { if (BuildConfig.DEBUG) { Toast.makeText(context, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()), Toast.LENGTH_SHORT).show(); } } + + public static Boolean isAlarmScheduled(Context context) { + AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + + return alarmManager.getNextAlarmClock() != null; + } }