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.
You can absolutely set default alerts for the Calendar app. Go to Settings > Calendar > Default Alert Times > You can choose alert times for Birthdays, Events and All-Day Events. Each event type has different choices for the default alert times. Enjoy your day!
In Google Calendar settings, go to Events from Gmail, and check the box next to Show events automatically created by Gmail in my calendar.
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+""});
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With