I try to implement one way synchronization with android calendar events (I need original events - not event instances). So, I have the following query:
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);
According to developer docs for recurrent events dtstart
and duration
are required but when I create event through Google calendar and receive it later in my code I have dtend = 0
and duration = null
.
Integer dtend = cursor.getLong(2);
String duration = cursor.getString(4);
Why it may happen?
I have an issue with indexes in my original application. CalendarContract.Events.DURATION
column solves the problem. It has single event duration in RFC2445
format. I just need to parse it.
来源:https://stackoverflow.com/questions/40221843/why-duration-is-null-for-recurrent-event-in-android