I tried to add the event to the calendar using the code below. It works fine with all devices except Nexus 6 (OS 6.0.1). Its Log mapping is similar to added event: content://com.android.calendar/events/1598in Logcat. But this event does not appear on my calendar.
the code:
private void addEvents() {
ContentValues values = new ContentValues();
values.put("calendar_id", 1);
values.put("title", "event Name");
values.put("allDay", 0);
values.put("dtstart", myCalendar.getTimeInMillis() + 11*60*1000);
values.put("dtend", myCalendar.getTimeInMillis()+60*60*1000);
values.put("description", "event desc");
values.put("hasAlarm", 1);
values.put(CalendarContract.Events.EVENT_TIMEZONE,TimeZone.getDefault().getID());
ContentResolver resolver=getApplicationContext().getContentResolver();
Uri event = resolver.insert(CalendarContract.Events.CONTENT_URI, values);
Log.d("added event",event.toString());
}
source
share