Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create calendar event from my app without default reminders

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.

like image 568
Karthik Andhamil Avatar asked Sep 26 '13 05:09

Karthik Andhamil


People also ask

How do I change the default calendar alert on my Iphone?

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!

How do I automatically add events to my calendar?

In Google Calendar settings, go to Events from Gmail, and check the box next to Show events automatically created by Gmail in my calendar.


2 Answers

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+""});
like image 140
Andrew T. Avatar answered Sep 20 '22 07:09

Andrew T.


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

like image 33
Leonardo Avatar answered Sep 18 '22 07:09

Leonardo