2

I'm using the AlarmManager.setAlarmClock() to remind my app users to take their medicine.

Today (after 15 days of correct work) setAlarmClock() did not fire an alarm to notify my users.

How do i schedule?

        for (Reminder reminder : reminderArrayList) {
        if(reminder.isActive()){
            GregorianCalendar cal = new GregorianCalendar();
            cal.set(GregorianCalendar.HOUR_OF_DAY, reminder.getHour());
            cal.set(GregorianCalendar.MINUTE, reminder.getMinute());
            cal.set(GregorianCalendar.SECOND, 0);
            while(cal.before(Calendar.getInstance())){
                cal.add(GregorianCalendar.DAY_OF_YEAR, getDaysFromIntervall(reminder.getIntervall()));
            }
            Intent intent = new Intent(context, AlarmReceiver.class);
            intent.putExtra("reminder_id", reminder.getId());

            PendingIntent pi = PendingIntent.getBroadcast(context, reminder.getCode(), intent, PendingIntent.FLAG_CANCEL_CURRENT);

            AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
            am.setAlarmClock(new AlarmManager.AlarmClockInfo(cal.getTimeInMillis(), pi), pi);

        }
    }

The problem occurred on Galaxy S7 edge with Android 8.0.0

How can I ensure that my alarms will fire?

Help would be appreciate.

Thanks in advance.

Patrick

p4trick
  • 21
  • 2
  • No help but you don't seem to be the only one with this problem, see this [post](https://stackoverflow.com/questions/39583776/setalarmclock-not-working) – Bö macht Blau Jul 03 '18 at 17:02
  • This can't be true... Today it works like charm :-( – p4trick Jul 04 '18 at 13:01
  • I am facing a similar problem. I should rather say the same problem. My alarm fired for the past few days at exact time but then one day it did not fire. Again, when I rebooted the device (it sets the alarm on boot complete), it worked fine. Did you find any way to ensure that this does not happen? Or is there any way to set another alarm after some time automatically when the alarm does not fire? – Samudra Ganguly Apr 27 '22 at 12:24

0 Answers0