I cannot find a way to insert exception dates into a repeating event.
Context
I process the .ics (ical format) file with the event with success . Here ..
BEGIN:VCALENDAR PRODID:-//Google Inc//Google Calendar 70.9054//EN VERSION:2.0 CALSCALE:GREGORIAN METHOD:PUBLISH X-WR-CALNAME:TESTING X-WR-TIMEZONE:Europe/Amsterdam X-WR-CALDESC: BEGIN:VTIMEZONE TZID:Europe/Amsterdam X-LIC-LOCATION:Europe/Amsterdam BEGIN:DAYLIGHT TZOFFSETFROM:+0100 TZOFFSETTO:+0200 TZNAME:CEST DTSTART:19700329T020000 RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU END:DAYLIGHT BEGIN:STANDARD TZOFFSETFROM:+0200 TZOFFSETTO:+0100 TZNAME:CET DTSTART:19701025T030000 RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU END:STANDARD END:VTIMEZONE BEGIN:VEVENT DTSTART;TZID=Europe/Amsterdam:20140425T103000 DTEND;TZID=Europe/Amsterdam:20140425T113000 RRULE:FREQ=WEEKLY;BYDAY=FR EXDATE;TZID=Europe/Amsterdam:20140516T103000 EXDATE;TZID=Europe/Amsterdam:20140502T103000 DTSTAMP:20140425T090449Z UID: 3bb37doi3qcuaih3t03ns0q9jo@google.com ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=TESTIN G;X-NUM-GUESTS=0:mailto: domain.com_o300s@group.calendar.google.com CREATED:20140425T090310Z DESCRIPTION: LAST-MODIFIED:20140425T090427Z LOCATION: SEQUENCE:0 STATUS:CONFIRMED SUMMARY:my-recurring-event-with-ex TRANSP:OPAQUE END:VEVENT END:VCALENDAR
The event is then inserted into the Android calendar through the CalendarContract API.
dtstart: 20140425T103000 dtend: 20140425T113000 rrule: FREQ = WEEKLY, BYDAY = FR
Problem: Exception Date
If I request my calendar now, I will see the event every Friday, starting April 25, 2014.
The problem is that I also need to exclude some dates (see ical: May 2, 2014 and May 16, 2014)
Attempt 1
I tried to insert exdate for 16, it can only use the EXDATE field, for example: android: EXDATE format when adding a calendar event But this did not work and is based on the source code of the Android calendar, it is not even used.
Attempt 2
I tried to throw an exception using CONTENT_EXCEPTION_URI Through this post: Make an exception event from the original recurring event? Google Calendar Code: https://github.com/android/platform_packages_apps_calendar/blob/master/src/com/android/calendar/EventInfoFragment.java#L1401
ContentValues values2 = new ContentValues(); values2.put(CalendarContract.Events.ORIGINAL_INSTANCE_TIME, event.getAsString(CalendarContract.Events.DTSTART)); values2.put(CalendarContract.Events.STATUS, CalendarContract.Events.STATUS_CANCELED); Uri.Builder eventUriBuilder = CalendarContract.Events.CONTENT_EXCEPTION_URI.buildUpon(); eventUriBuilder.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true"); eventUriBuilder.appendQueryParameter(CalendarContract.Calendars.ACCOUNT_NAME, accountName); eventUriBuilder.appendQueryParameter(CalendarContract.Calendars.ACCOUNT_TYPE, accountType); ContentUris.appendId(eventUriBuilder, dbId); Uri uriex = cr.insert(eventUriBuilder.build(), values2);
uriex is always null.
Attempt 3
I tried to insert a new event with a link to its source event, for example, in the Google calendar code to delete one record of a repeating event https://github.com/android/platform_packages_apps_calendar/blob/master/src/com/android/calendar/DeleteEventHelper. java # L361
Q
Does anyone know how to handle the CalendarContract API for exceptions in a repeating event?