I want to show a local notification to the user every day on a predefined time. Android documentation has a sample code in this link (developer.android.com/training/scheduling/alarms.html#set) that can be used for scheduled repeating alarms. My code is:
var calendar = Calendar.Instance; calendar.TimeZone = TimeZone.GetTimeZone("Europe/Stockholm"); calendar.Set(CalendarField.HourOfDay, 19); calendar.Set(CalendarField.Minute, 15); //BootReceiver is derived from BroadcastReceiver which registers the service on boot (Intent.ActionBootCompleted) var alarmIntent = new Intent(Instance, typeof(BootReceiver)); var pendingIntent = PendingIntent.GetBroadcast(Instance, 0, alarmIntent, PendingIntentFlags.UpdateCurrent); var alarmManager = (AlarmManager)Instance.GetSystemService(Context.AlarmService); alarmManager.SetInexactRepeating(AlarmType.RtcWakeup, calendar.TimeInMillis, AlarmManager.IntervalDay, pendingIntent);
This partly works, depending on the current system time:
I do not want to fire notifications after the app start, could anyone please help me with daily notification registering?