I am trying to add an event on a calendar that i created programmatically like this, ` var uri = CalendarContract.Calendars.ContentUri; ContentValues val = new ContentValues();
val.Put(CalendarContract.Calendars.InterfaceConsts.CalendarAccessLevel, CalendarAccess.AccessOwner.ToString());
val.Put(CalendarContract.Calendars.Name, "Mary");
val.Put(CalendarContract.Calendars.InterfaceConsts.Visible, true);
val.Put(CalendarContract.Calendars.InterfaceConsts.SyncEvents, true);
val.Put(CalendarContract.Calendars.InterfaceConsts.CalendarColor, "0xff00ffff");
val.Put(CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, "Mary");
uri = uri.BuildUpon()
.AppendQueryParameter(CalendarContract.CallerIsSyncadapter, "true")
.AppendQueryParameter(CalendarContract.Calendars.InterfaceConsts.AccountName, AccountName)
.AppendQueryParameter(CalendarContract.Calendars.InterfaceConsts.AccountType, CalendarContract.AccountTypeLocal)
.Build();
var calresult = ContentResolver.Insert(uri, val);
calID = int.Parse(calresult.LastPathSegment);
AddCalendarEvent( calID);`
it gets added successfully and I am able to see this calendar
I am adding event like this, ` private void AddCalendarEvent( int calID) { // Create Event code ContentValues eventValues = new ContentValues(); eventValues.Put(CalendarContract.Events.InterfaceConsts.CalendarId, calID); eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, "Test Event from M4A"); eventValues.Put(CalendarContract.Events.InterfaceConsts.Description, "This is an event created from Mono for Android"); eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart, GetDateTimeMS(2013, 9, 15, 10, 0)); eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend, GetDateTimeMS(2013, 9, 15, 11, 0));
// GitHub issue #9 : Event start and end times need timezone support.
// https://github.com/xamarin/monodroid-samples/issues/9
eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "UTC");
eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "UTC");
var uri = ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues);
Console.WriteLine("Uri for new event: {0}", uri);
}`
My problem is that when I am trying to open this event to see the description, it gives me an error that "Unfortunately the calendar has stopped". I am able to open the event when it is added to the default calendar. What wrong am I doing in the creating the calendar??