The following code snippet shows how to add event in Android calendar using intent method.

Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setData(CalendarContract.Events.CONTENT_URI)
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, eventDate.getTimeInMillis())
intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, eventDate.getTimeInMillis() + 60 * 60 * 1000)
intent.putExtra(CalendarContract.Events.TITLE, title)
intent.putExtra(CalendarContract.Events.DESCRIPTION, description)
intent.putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY);
context.startActivity(intent);

Toast.makeText(context, "Event added to calendar, Toast.LENGTH_SHORT).show(); 
Tagged in : #Android

Discussions

Please note: We reserve the right to delete comments that contains snarky remarks, offensive or off-topic. To know more read our comments policy.