我正在为日历条目添加提醒。我正在使用这段代码,
ContentValues eventValues = new ContentValues();
eventValues.Put(CalendarContract.Events.InterfaceConsts.CalendarId, _calId);
eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, "Test Event");
eventValues.Put(CalendarContract.Events.InterfaceConsts.Description, "This is an event created for demo app");
eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart, GetDateTimeMS(DateTime.Today, DateTime.Now));
eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend, GetDateTimeMS(DateTime.Today.AddDays(1), DateTime.Now));
eventValues.Put(CalendarContract.Events.InterfaceConsts.HasAlarm, true);
eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "Local");
eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "Local");
var eventUri = ContentResolver.Insert(CalendarContract.Events.ContentUri,
eventValues);
long eventID = long.Parse(eventUri.LastPathSegment);
string reminderUriString = "content://com.android.calendar/reminders";
ContentValues reminderValues = new ContentValues();
// reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.CalendarId, _calId);
reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.EventId, eventID);
reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.Method, RemindersMethod.Alert.ToString());
reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.Minutes, 5);
Android.Net.Uri url = Android.Net.Uri.Parse(reminderUriString);
var reminderUri = ContentResolver.Insert(url, reminderValues);
这不会给出任何异常,但也不会添加提醒。怎么了?我如何添加提醒?我有写权限。我可以添加日历活动,但无法添加提醒