Alarm Manager Confusion

Issue

I am trying to setup a Alaram below, however sometimes it fires normally and sometimes it does not and it only fires when i "open" the app. so say if alarm was schedule for 6pm, and then when i open my app at 7pm then it will fire. any ideas?

Intent intent = new Intent(AndroidApp.Context, typeof(AlarmHandler));
PendingIntent pendingIntent = PendingIntent.GetBroadcast(AndroidApp.Context, uniqueMessageId, intent, PendingIntentFlags.UpdateCurrent | PendingIntentFlags.Immutable);

AlarmManager alarmManager = AndroidApp.Context.GetSystemService(Context.AlarmService) as AlarmManager;

 alarmManager.SetExactAndAllowWhileIdle(AlarmType.RtcWakeup, triggerTime, pendingIntent);

Solution

Switching alarmManager.SetExactAndAllowWhileIdle to alarmManager.SetAlarmClock Fixed it for me. Hope it can help someone else.

Documentation: https://developer.android.com/reference/android/app/AlarmManager#setAlarmClock(android.app.AlarmManager.AlarmClockInfo,%20android.app.PendingIntent)

Answered By – user2404597

Answer Checked By – Jay B. (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *