im testing android calendar recurrence event. Im have setted an event to android calendar and add a rrule, code like this:
public static int addCalendarEvent(Context context, CalendarEvent calendarEvent) {
checkContextNull(context);
long calID = obtainCalendarAccountID(context);
Uri uri1 = CalendarContract.Events.CONTENT_URI;
Uri eventUri;
Uri uri2 = CalendarContract.Reminders.CONTENT_URI;
Uri reminderUri;
ContentValues event = new ContentValues();
event.put(CalendarContract.Events.CALENDAR_ID, calID);
setupEvent(calendarEvent, event);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (PackageManager.PERMISSION_GRANTED == context.checkSelfPermission(
"android.permission.WRITE_CALENDAR")) {
eventUri = context.getContentResolver().insert(uri1, event);
} else {
return -2;
}
} else {
eventUri = context.getContentResolver().insert(uri1, event);
}
if (null == eventUri) {
return -1;
}
long eventID = ContentUris.parseId(eventUri);
ContentValues reminders = new ContentValues();
reminders.put(CalendarContract.Reminders.EVENT_ID, eventID);
reminders.put(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT);
reminderUri = context.getContentResolver().insert(uri2, reminders);
if (null == reminderUri) {
return -1;
}
return 0;
}
the setUpEvent code:
private static void setupEvent(CalendarEvent calendarEvent, ContentValues event) {
event.put(CalendarContract.Events.DTSTART, calendarEvent.getStart());
event.put(CalendarContract.Events.DTEND, calendarEvent.getEnd());
event.put(CalendarContract.Events.TITLE, calendarEvent.getTitle());
event.put(CalendarContract.Events.DESCRIPTION, calendarEvent.getDescription());
event.put(CalendarContract.Events.EVENT_LOCATION, calendarEvent.getEventLocation());
event.put(CalendarContract.Events.EVENT_TIMEZONE, TimeZone.getDefault().getID());
event.put(CalendarContract.Events.ACCESS_LEVEL, CalendarContract.Events.ACCESS_DEFAULT);
event.put(CalendarContract.Events.STATUS, 0);
event.put(CalendarContract.Events.HAS_ALARM, 1);
event.put(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY);
final String repeatRRule = getFullRRuleForRRule(calendarEvent);
if (!TextUtils.isEmpty(repeatRRule)) {
event.put(CalendarContract.Events.RRULE, repeatRRule);
}
}
the final rrule:
"FREQ=MONTHLY;INTERVAL=1;UNTIL=20260801T160000Z;BYMONTHDAY=10"
Im try to set monthly repeat event, after setup only three month has events. Then i changed the rrule like:
"FREQ=MONTHLY;INTERVAL=1;COUNT=100;BYMONTHDAY=10"
It still the same result.I dont know where is wrong.Can someone help me... Any helps will be appreciated.