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);
I figured it out, the RRULE string shouldn't contain the word 'RRULE' itself.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With