I am setting local notifications to fire at specific time in Xamarin.Android application. It all works but the set time seems to be little off, set time comes from user input (with minute precision). When setting notifications further in the future (days later) the notification fired at the next minute than it should have.
Below is my current code to calculate time. calendarEvent.StartTime is a DateTime property.
TimeSpan span = calendarEvent.StartTime - DateTime.Now;
manager.Set(AlarmType.ElapsedRealtime,(long)(SystemClock.ElapsedRealtime() + span.TotalMilliseconds),pendingIntent);
I would like to know how to accurately calculate the time so that notifications would fire at the start of the minute they are supposed to. In the current code they fire in the middle of the minute or later.