In my app, the users can add special events to their Google Calendar. I want that the events will be added without any alarm/reminder/notification. Some of the users' calendars have default settings for the reminders, as "A day before the event, at 9:00".
How can I add the events so they will not have any alarm at all despite the default settings?
ContentValues eventValues = new ContentValues();
eventValues.put("calendar_id", calendarId);
eventValues.put("title",title);
eventValues.put("allDay", 1);
eventValues.put("dtstart", dtstart);
eventValues.put("dtend", dtend );
eventValues.put("hasAlarm", 1); // I tried both 0 and 1, none of them solved the problem!
eventValues.put("hasAttendeeData", 1);
eventValues.put("availability",1);
Edit: It seems that the reminders were added only after the events were synchronized with Google's services, some minutes after, not immediately. How can I prevent it?
You can set a BroadCastReceiver
on CalendarProvider
. It will fired when any changes happen in provider:
<receiver android:name="CalendarChangeReceiver">
<intent-filter>
<action android:name="android.intent.action.PROVIDER_CHANGED" />
<data android:scheme="content" />
<data android:host="com.android.calendar" />
</intent-filter> </receiver>
So when reminders are added to events, this will fired. You can save your inserted events ids in SharedPreferences
and then delete reminders in onReceive()
:
context.getContentResolver().delete(CalendarContract.Reminders.CONTENT_URI, CalendarContract.Reminders.EVENT_ID + "=?", new String[]{Long.toString(eventId)});
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