I have a special requirement for creating a calendar event that will occur on specific dates. This is not a scenario that will occur Weekly, monthly, annually, but may occur 13 days, 14 days, 15 days, etc. I have what dates this will happen, but have not set recurring dates. below is my code
ContentValues calEvent = new ContentValues();
calEvent.put(CalendarContract.Events.CALENDAR_ID, 1);
calEvent.put(CalendarContract.Events.TITLE, title);
calEvent.put(CalendarContract.Events.DTSTART, d.getTime());
calEvent.put(CalendarContract.Events.DTEND, d.getTime()
+ (2 * 60 * 60 * 1000));
calEvent.put(CalendarContract.Events.HAS_ALARM, 1);
calEvent.put(CalendarContract.Events.EVENT_TIMEZONE, TimeZone
.getDefault().getID());
calEvent.put(CalendarContract.Events.EVENT_LOCATION, location);
calEvent.put(CalendarContract.Events.DESCRIPTION, description);
calEvent.put(CalendarContract.Events.RDATE, sdf1.format(d)
+ "T033000Z");
Uri uri = contentResolver.insert(
CalendarContract.Events.CONTENT_URI, calEvent);
int id = Integer.parseInt(uri.getLastPathSegment());
eventId = eventId + (eventId.equalsIgnoreCase("") ? id : "," + id);
ContentValues calReminder = new ContentValues();
calReminder.put(CalendarContract.Reminders.MINUTES, minutes);
calReminder.put(CalendarContract.Reminders.EVENT_ID, id);
calReminder.put(Reminders.METHOD, Reminders.METHOD_ALERT);
Uri uri1 = contentResolver.insert(
CalendarContract.Reminders.CONTENT_URI, calReminder);
int id1 = Integer.parseInt(uri1.getLastPathSegment());
reminderId = reminderId
+ (reminderId.equalsIgnoreCase("") ? id1 : "," + id1);
When I use RDATE with comma-separated dates, provided there are startdate and enddate, an Event is generated for all dates between startdate and enddate.
source
share