Android google calendar sync event

im trying to add events to android calendar which will synchronize these events automatically with google calendar but its not working !! manually added events synchronize, but events added from my code appear on the calendar but do not synchronize with the google calendar, why ???

this is my add event code

Calendar cal = Calendar.getInstance(); ContentValues event = new ContentValues(); event.put("calendar_id", 2); // 2 is the id of the google calendar in my phone event.put("title", "Test Event2"); event.put("description", "Hiii Buddy"); long startTime = cal.getTimeInMillis(); long endTime = cal.getTimeInMillis() + 60 * 60 * 1000; event.put("dtstart", startTime); event.put("dtend", endTime); event.put("allDay", 0); event.put("eventStatus", 1);// tentative 0, confirmed 1 canceled 2 event.put("visibility", 3);// default 0 confidential 1 private 2 // public 3 event.put("transparency", 0);// opaque 0 transparent 1 event.put("hasAlarm", 1); // 0 false, 1 true Uri eventsUri = getCalendarURI(true); Uri url = getContentResolver().insert(eventsUri, event); 
+4
source share
1 answer

You must enable synchronization in: Settings β†’ Accounts and synchronization β†’ Account management β†’ Calendar synchronization
In the Calendar app: Menu β†’ Advanced β†’ Calendars so you can sync your Google account.

+1
source

Source: https://habr.com/ru/post/1392361/


All Articles