5
votes

I am developing an app that creates, updates and deletes events in native Google's calendar. I am creating an event by following code:

ContentValues cvEvent = new ContentValues();
cvEvent.put(Events.DTSTART, startMillis);
cvEvent.put(Events.DTEND, endMillis);
cvEvent.put(Events.TITLE, strJobName);
cvEvent.put(Events.CALENDAR_ID, mlCalendarID);
cvEvent.put(Events.EVENT_TIMEZONE, "America/Los_Angeles");
Uri uriEvent = crEvent.insert(Events.CONTENT_URI, cvEvent);

But the problem is that this event creates a default reminder as set by the user within his calendar (Google).

I am also allowing users to add reminders within my app. So, when he adds a reminder, I am inserting reminders into the default Google Calendar. That has no issues. But when user is not adding any reminder in my app, the default google calendar creates default reminder. Can anyone tell me how to solve this issue?

P.S: I am not using Sync Adapters. I am creating and deleting events and reminders through my own logic.

I tried using

values.put(Events.HAS_ALARM, 0);

But, it is of no use.

2

2 Answers

4
votes

How about deleting the reminders programmatically using the event ID that you got after inserting the event?

ContentValues cvEvent = new ContentValues();
cvEvent.put(Events.DTSTART, startMillis);
cvEvent.put(Events.DTEND, endMillis);
cvEvent.put(Events.TITLE, strJobName);
cvEvent.put(Events.CALENDAR_ID, mlCalendarID);
cvEvent.put(Events.EVENT_TIMEZONE, "America/Los_Angeles");
Uri uriEvent = crEvent.insert(Events.CONTENT_URI, cvEvent);

//added code
long eventID = Long.parseLong(uri.getLastPathSegment());
ContentResolver cr = getContentResolver();
cr.delete(Reminders.CONTENT_URI, Reminders.EVENT_ID+"=?", new String[]{eventID+""});
1
votes

Not sure how to do this in Android, but if you look at Google's documentation there is a field called reminders.useDefault on the POST used to insert a event into a calendar.

Property name: reminders.useDefault
Value: boolean
Description: Whether the default reminders of the calendar apply to the event.
Notes: writable

https://developers.google.com/google-apps/calendar/v3/reference/events/insert