4

I'm following rfc2445 spec and insert a recurrent event to cal, but always get invalid recurrence error.

Invalid recurrence rule: RRULE:FREQ=WEEKLY;UNTIL=20141007T000000Z;WKST=SU;BYDAY=TU,TH

This is my code, note I return the above constant rrule string to make sure I don't violate the specs, I just change the year from 1997 to 2014. Any idea why it doesn't work? thanks

ContentResolver cr = getContentResolver();
        ContentValues values = new ContentValues();
        values.put(CalendarContract.Events.DTSTART, model.getStartTime().toMillis(false));
        values.put(CalendarContract.Events.DTEND, model.getEndTime().toMillis(false));
        values.put(CalendarContract.Events.EVENT_TIMEZONE, timezone);
        values.put(CalendarContract.Events.TITLE, model.getTitle());
        values.put(CalendarContract.Events.EVENT_LOCATION, model.getLocation().getName());
        values.put(CalendarContract.Events.DESCRIPTION, model.getDescription());
        values.put(CalendarContract.Events.CALENDAR_ID, calId);
        String recurString ="RRULE:FREQ=WEEKLY;UNTIL=20141007T000000Z;WKST=SU;BYDAY=TU,TH"
        
        values.put(CalendarContract.Events.RRULE, recurString);
        
       
        Uri uri = cr.insert(CalendarContract.Events.CONTENT_URI, values);
Community
  • 1
  • 1
EyeQ Tech
  • 7,198
  • 18
  • 72
  • 126
  • check this issue: http://stackoverflow.com/questions/28871921/add-weekly-event-to-calendar – Sun Mar 12 '15 at 12:34

2 Answers2

6

I figured it out, the RRULE string shouldn't contain the word 'RRULE' itself.

EyeQ Tech
  • 7,198
  • 18
  • 72
  • 126
4

If you are using Android standard CalendarContract, please use DURATION field instead of DTEND, otherwise, your events won't recurring.

Refer to the following link: http://developer.android.com/reference/android/provider/CalendarContract.Events.html

  • dtend if the event is non-recurring
  • duration if the event is recurring
  • rrule or rdate if the event is recurring
LabLu
  • 83
  • 8