Home » Android » android – Is there a way to add reminders to a new calendar event using Intents?

android – Is there a way to add reminders to a new calendar event using Intents?

Posted by: admin May 14, 2020 Leave a comment

Questions:

I need to support Android 2.1 and up. I know that CalendarContract isn’t available in Android 2.1, so I’ve done the following workaround.

Intent intent = new Intent(Intent.ACTION_EDIT)
                        .setType("vnd.android.cursor.item/event")
                        .putExtra("beginTime", beginTime.getTimeInMillis())
                        .putExtra("title", title)
                        .putExtra("description", description)
                        .putExtra("eventLocation", location)
                        .putExtra("allDay", allDay)
                        .putExtra(Intent.EXTRA_EMAIL, email );
                if(!allDay) {
                    intent.putExtra("endTime", endTime.getTimeInMillis());
                }

               startActivity(intent);

This works very well so far. I’ve tested on 2.1 through 4.1.

I’d like to add reminders, too, but I can’t find any documentation on how to do it using Intents. Does anyone have an example? I want to avoid adding more permissions to my manifest for writing to the calendar, so if you have a suggestion that requires that, I won’t be able to use it.

How to&Answers:

If you check the stock android Calendar source code, reminders cannot be added using intent.

Instead of this calendar has a setting to set the default reminder. But some OEMs could have implemented this. So even if you find it, it will not work on all phones.