0

I have set up an alarm using the Alarm manager and to test it changed the time of the device manually. At this time the alarm not triggers, but if we wait till the time it gets triggered. Is there any better option to test the alarm?

The alarm setting code is given below.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            alarmManager.setExactAndAllowWhileIdle(
                AlarmManager.RTC_WAKEUP,
                total,
                operation
            )
        } else {
            alarmManager.setExact(
                AlarmManager.RTC_WAKEUP,
                total,
                operation
            )
        }

1 Answers1

0

No that will not triggered by AlarmManager. So you should listen about time change actions and re-create the alarm.

Those actions are

Intent.ACTION_TIME_TICK
Intent.ACTION_TIMEZONE_CHANGED
Intent.ACTION_TIME_CHANGED

does Alarm Manager persist even after reboot? is a better answer to understand your problem and resolve that.

For more better understanding you may follow Date and time change listener in Android?

Ghulam Qadir
  • 471
  • 3
  • 12