Hi I have the following code to add events on my calendar:
public String addCalendarEntry(CalendarDTO calendar) {
ContentValues event = new ContentValues();
ContentResolver cr = getContentResolver();
long startMillis = calendar.getStartDate().getTimeInMillis();
long endMillis = calendar.getEndDate().getTimeInMillis();
String timeZone = TimeZone.getDefault().getID();
event.put(CalendarContract.Events.CALENDAR_ID, calendar.getId());
event.put(CalendarContract.Events.TITLE, calendar.getTitle());
event.put(CalendarContract.Events.DESCRIPTION, calendar.getDescription());
event.put(CalendarContract.Events.EVENT_LOCATION, calendar.getLocation());
event.put(CalendarContract.Events.DTSTART, startMillis);
event.put(CalendarContract.Events.DTEND, endMillis);
event.put(CalendarContract.Events.ALL_DAY, Boolean.getBoolean(String.valueOf(calendar.isAllDay()))); // 0 for false, 1 for true
event.put(CalendarContract.Events.HAS_ALARM, 1); // 0 for false, 1 for true
event.put(CalendarContract.Events.EVENT_TIMEZONE, timeZone);
Uri uri = cr.insert(CalendarContract.Events.CONTENT_URI, event);
return uri.getLastPathSegment();
}
This code was working fine until the other day, and all of a sudden doesn't add any more events into my calendar. It doesn't error either, so I'm at loss here.
CalendarDTO is just a data transport class as such:
public class CalendarDTO {
int id;
String title;
String description;
String location;
Calendar startDate;
Calendar endDate;
boolean isAllDay;
// getters and setters removed for brevity
}
Any clues highly appreciated.