2

我尝试实现与 android 日历事件的一种同步方式(我需要原始事件 - 而不是事件实例)。所以,我有以下查询:

String[] projection = new String[]{
                    CalendarContract.Events.DTSTART,
                    CalendarContract.Events.EVENT_TIMEZONE,
                    CalendarContract.Events.DTEND,
                    CalendarContract.Events.EVENT_END_TIMEZONE,
                    CalendarContract.Events.DURATION
            };
String selection = null;
String[] args = new String[0];
String sort = CalendarContract.Events.DTSTART + " ASC";
Cursor cursor = getContentResolver().query(CalendarContract.Events.CONTENT_URI, projection, selection, args, sort);

根据经常性事件的开发人员文档dtstart,并且duration是必需的,但是当我通过 Google 日历创建事件并稍后在我的代码中接收它时,我拥有dtend = 0duration = null.

Integer dtend = cursor.getLong(2);
String duration = cursor.getString(4);

为什么会发生?

4

1 回答 1

0

我的原始应用程序中的索引存在问题。CalendarContract.Events.DURATION专栏解决了这个问题。RFC2445它在格式上具有单个事件持续时间。我只需要解析它。

于 2016-10-25T10:28:42.627 回答