0

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);
user2404597
  • 488
  • 4
  • 18
  • 3
    have you read the docs? There is a big red box that describes changes in this class for API 19, as well as a discussion of options to wake the device when it is asleep. https://developer.android.com/reference/android/app/AlarmManager – Jason Oct 04 '22 at 21:29
  • but i am using "SetExact", so it should not really matter? – user2404597 Oct 04 '22 at 21:38
  • 1
    "there is a big red box" and https://stackoverflow.com/questions/33110246/setexactandallowwhileidle-is-not-exact-as-of-developer-reference – Jason Oct 04 '22 at 21:41
  • SetAlarmClock did the trick. – user2404597 Oct 05 '22 at 23:01

1 Answers1

0

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)

user2404597
  • 488
  • 4
  • 18