Android CalendarContract重复活动,包含例外日期

Ben*_*oit 7 android recurring-events android-calendar calendarcontract

我找不到一种方法来将异常日期插入到重复发生的事件中.

上下文

我正在使用成功的事件解析.ics文件(ical格式).这是.ics

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
Run Code Online (Sandbox Code Playgroud)

然后,该事件将通过CalendarContract API插入到Android日历中.

dtstart:20140425T103000 dtend:20140425T113000 rrule:FREQ = WEEKLY; BYDAY = FR

问题:排除日期

如果我现在查询我的日历,我将在2014年4月25日的每个星期五看到一个活动.

问题是我还需要排除一些日期(见ical:2014年5月2日和2014年5月16日)

尝试1

我尝试插入16的exdate可能只使用这样的EXDATE字段: 添加日历事件时的android:EXDATE格式 但是这不起作用,并且基于Android日历源代码甚至没有使用它.

尝试2

我尝试使用CONTENT_EXCEPTION_URI插入异常通过这样的帖子:从原始重复事件中创建异常事件? Google日历代码: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);
Run Code Online (Sandbox Code Playgroud)

uriex总是为空.

尝试3

我尝试插入一个新事件,其中包含指向其原始事件的链接,例如在Google日历代码中删除定期事件的单个条目 https://github.com/android/platform_packages_apps_calendar/blob/master/src/com/android/日历/ DeleteEventHelper.java#L361

Q

有人知道如何处理CalendarContract API中的重复事件中的异常吗?

k3b*_*k3b 0

我查询了我自己的设备日历数据库。

 select _ID,exdate from events where exdate is not null
Run Code Online (Sandbox Code Playgroud)

例如,它包含 exdate="20090103T093000Z,20110101T093000Z",因此日期必须格式化为 utc ("Z")

> and based on the android calendar source code it (the field exdate) 
> is not event used.
Run Code Online (Sandbox Code Playgroud)

当 android 从事件中计算/更新(事件)实例时,您是否分析了启动后事件?