2

I try to read recurring events on ICS, the startTime of the recurring events are ok, but the endTime is 0 (milliseconds). But just on the recurring events there is the duration not "null". I read on a test event the duration of "P9000S". It is in RFC2445 Format, therefore it is not the duration of a single event, its the duration from first to last event. RRULE gives my following: FREQ=MONTHLY;COUNT=3;BYMONTHDAY=3. How get I the end time of the single events? Thanks a lot in advance! This is my projection:

                final String[] projection = new String[]
                { CalendarContract.Events.TITLE, CalendarContract.Events.DTSTART, CalendarContract.Events.DTEND, CalendarContract.Events.RRULE, CalendarContract.Events.ALL_DAY, CalendarContract.Events.DURATION};

EDIT:

                final String[] projection = new String[]
                { CalendarContract.Events.TITLE, CalendarContract.Events.DTSTART, CalendarContract.Events.DTEND, CalendarContract.Events.DURATION, CalendarContract.Events.ALL_DAY, CalendarContract.Events.RRULE};

                // Construct the query with the desired date range.
                Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
                ContentUris.appendId(builder, now - DateUtils.DAY_IN_MILLIS);
                ContentUris.appendId(builder, now + DateUtils.DAY_IN_MILLIS);

                eventCursor =   getContentResolver().query(
                        builder.build(), projection, Instances.CALENDAR_ID  + " = ?",
                        new String[]{""+calendarID}, CalendarContract.Events.DTEND +" ASC");
Rudi Visser
  • 21,350
  • 5
  • 71
  • 97
user1390816
  • 623
  • 2
  • 13
  • 34
  • 1
    No, it's the duration of each individual event, P9000S is a period of 9000 seconds, i.e. 150 minutes. The end time is calculated individually by adding the duration to the start time. – Jens Oct 03 '12 at 09:01
  • I have problems to convert the 2445 format into milliseconds. I tried: "Time time = new Time();" and "time.parse(durationStr);" but I get an exception that the string is too short. Have you any idea? – user1390816 Oct 03 '12 at 10:14
  • 1
    Yeah, that's not going to work. Copy & use the [Duration](http://source-android.frandroid.com/packages/apps/Calendar/src/com/android/calendar/Duration.java) class instead. – Jens Oct 03 '12 at 10:19
  • One more question, it shows me just the start time of the first event, and the duration. Do I have to analyse the RRULE to find all events, or is there a easier way? – user1390816 Oct 04 '12 at 13:58
  • 1
    If you want to just get instances of a recurring event you should probably be querying [Instances](http://developer.android.com/reference/android/provider/CalendarContract.Instances.html). For a "normal" event you'll just find a single instance - a recurring event will return several rows with the same `EVENT_ID` value. – Jens Oct 04 '12 at 14:05
  • I want to read events from a specifuíc calendar ID. I just want to read all events from the whole aktual day. I edited my post with the code I use now. How can I make this? – user1390816 Oct 04 '12 at 14:35
  • How can I do that with querying Instances? Please help me, thanks a lot! – user1390816 Oct 04 '12 at 19:57
  • Hm, spontaneously your edit doesn't seem wrong. Are you getting an error from this or just an empty Cursor? – Jens Oct 04 '12 at 20:55
  • No error, I just get for a recurring event the times from the first event of the series. If I create a monthly event on Sep 3. and read it on Oct 3. I get back the Sep 3. Start time. – user1390816 Oct 05 '12 at 06:15
  • By the look of it I have to analyse RRULE combined with the start time from the first event and the duration to get each event ... – user1390816 Oct 06 '12 at 17:45

0 Answers0