A simplest way to add calendar events in Android
In this post, I am going to show you a simplest way to add events to the calendar application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun addReminder() { | |
val intent = Intent(Intent.ACTION_INSERT) | |
intent.type = "vnd.android.cursor.item/event" | |
intent.putExtra(Events.TITLE, "Booking") | |
intent.putExtra(Events.EVENT_LOCATION, "ADD YOUR EVENT LOCATION") | |
intent.putExtra(Events.DESCRIPTION, "ADD YOUR EVENT DESCRIPTION") | |
// Setting dates and must be in integer format only | |
val calDate = GregorianCalendar(YEAR,MONTH,YEAR) | |
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, | |
calDate.timeInMillis) | |
intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, | |
calDate.timeInMillis) | |
// make it a full day event | |
intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true) | |
// make it a recurring Event | |
//intent.putExtra(Events.RDATE, "FREQ=WEEKLY;COUNT=11;WKST=SU;BYDAY=TU,TH") | |
// Making it public | |
intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PUBLIC) | |
intent.putExtra(Events.AVAILABILITY, Events.ACCESS_PUBLIC) | |
activity!!.startActivity(intent) | |
} |
Thanks for uploading this
ReplyDelete