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.
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.
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