javaandroidkotlingoogle-calendar-recurring-events

Android - How can i create recurring event with "until" date in rrule?


I can add recurring event in google calendar wihtout "until" date in rrule, if i set the "until" date in rrule it doesn't created event at google calendar. How to solve it??

My ContentValue is "description=Test title=Monthly Event allDay=0 dtend=1572593453011 dtstart=1572591653011 calendar_id=2 eventLocation=null rrule=FREQ=MONTHLY;BYMONTHDAY=1;UNTIL=1580452756479"

If i don't give until value in rrule it is being saved to google calendar otherwise don't save

val values = ContentValues().apply {
            put(CalendarContract.Events.DTSTART, entity.dateTime.startsOn)

                put(CalendarContract.Events.DTEND, entity.dateTime.endsOn)


        put(CalendarContract.Events.ALL_DAY, if (entity.dateTime.isAllDay) 1 else 0)
        put(CalendarContract.Events.TITLE, entity.title.name)
        put(CalendarContract.Events.DESCRIPTION, entity.note.content)
        put(CalendarContract.Events.CALENDAR_ID, getPrimaryCalendarId())
        put(CalendarContract.Events.EVENT_TIMEZONE, Locale.getDefault().toString())
        put(CalendarContract.Events.EVENT_LOCATION, entity.location.address)
       put(CalendarContract.Events.RRULE,
                getRRule())

 }
  val uri: Uri = activity!!.contentResolver.insert(CalendarContract.Events.CONTENT_URI, values)!!
        eventID = uri.lastPathSegment!!.toLong()
        print("Event Id $eventID")

Solution

  • Finally found the solution which is UNTIL accepts a value in date format of yyyyMMdd'T'HHmmss'Z', e.g. ā€œ20191105T000000Zā€.

    The content value is "description=Test title=Monthly Event allDay=0 dtend=1572593453011 dtstart=1572591653011 calendar_id=2 eventLocation=null rrule=FREQ=MONTHLY;BYMONTHDAY=1;UNTIL=20191113T000000Z".