KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I try to add a calendar by the following code. The event created can be read by calendar apps on my phone, but just sync to online Google Calendar. Can any one give me some hits to solve the issue? here are some remark 1. Code was run on my real phone (Galaxy Nexus 4.1.1) 2. All other calendar events can sync to Google Calendar, just the program-added cannot be sync. ---update--- When I change the follow code values.put(CalendarContract.Events.SYNC_EVENTS,1); values.put(CalendarContract.Events.VISIBLE, 1); -- I get the error java.lang.IllegalArgumentException: Only the provider may write to sync_events public void addEvent() { long startMillis = 0; long endMillis = 0; Log.v("LOG", "entered addEvent"); //Calendar beginTime = Calendar.getInstance(); //beginTime.set(2012, 8, 11, 22, 0); //startMillis = beginTime.getTimeInMillis(); startMillis = System.currentTimeMillis() + (3600 * 1000)*4; //Calendar endTime = Calendar.getInstance(); //endTime.set(2012, 8, 11, 23, 0); //endMillis = endTime.getTimeInMillis(); endMillis = System.currentTimeMillis() + (3600 * 1000)*5; ContentResolver cr = getContentResolver(); ContentValues values = new ContentValues(); values.put(CalendarContract.Events.DTSTART, startMillis); values.put(CalendarContract.Events.DTEND, endMillis); values.put(CalendarContract.Events.TITLE, "Dog"); values.put(CalendarContract.Events.DESCRIPTION, "DogInDESCRIPTION"); values.put(CalendarContract.Events.CALENDAR_ID, 1); values.put(CalendarContract.Events.EVENT_TIMEZONE, "eventTimezone"); values.put(CalendarContract.Events.SYNC_EVENTS,0); cr.insert(CalendarContract.Events.CONTENT_URI, values); }
Tags (comma-separated)
Save Edits
Cancel