i creating event in android calendar have recurrence rule. code follows:-
public long createevents_usertimelineview() { contentresolver cr = getcontentresolver(); calendar calendar = calendar.getinstance(locale.getdefault()); long calid = 11; long startmillis = 0; long endmillis = 0; string startdate_arr[]= {"2015", "05", "12"}; string starttime_arr[]={"14", "00", "00"}; calendar.set(integer.parseint(startdate_arr[0]),integer.parseint(startdate_arr[1])-1, integer.parseint(startdate_arr[2]),integer.parseint(starttime_arr[0]), integer.parseint(starttime_arr[1]),integer.parseint(starttime_arr[2])); // start time: 00, 01,59 startmillis = calendar.gettimeinmillis(); string startdate_arr1[]= {"2015", "05", "12"}; string starttime_arr1[]= {"15", "30", "00"}; calendar.set(integer.parseint(startdate_arr1[0]),integer.parseint(startdate_arr1[1])-1, integer.parseint(startdate_arr1[2]),integer.parseint(starttime_arr1[0]), integer.parseint(starttime_arr1[1]),integer.parseint(starttime_arr1[2])); //end time: 23, 58,00 endmillis = calendar.gettimeinmillis(); calendar calendar2=calendar.getinstance(locale.getdefault()); calendar2.settimeinmillis(startmillis-endmillis); contentvalues values = new contentvalues(); values.put(calendarcontract.events.dtstart, startmillis); values.put(calendarcontract.events.dtend, endmillis); values.put(calendarcontract.events.title, "my grand demo event"); values.put(calendarcontract.events.description, ""); values.put(calendarcontract.events.calendar_id, calid); values.put(calendarcontract.events.event_timezone,timezone.getdefault().getid()); values.put(calendarcontract.events.all_day, 0); values.put(calendarcontract.events.availability, "usertimelinedata"); timezone timezone = timezone.getdefault(); values.put(calendarcontract.events.event_timezone, timezone.getid()); values.put(calendarcontract.events.rrule,"freq=weekly;count=16;byday=tu"); values.put(calendarcontract.events.has_alarm,0); values.put(calendarcontract.events.organizer,""); values.put(calendarcontract.events.event_location,""); uri uri = cr.insert(calendarcontract.events.content_uri, values); long eventid = long.parselong(uri.getlastpathsegment()); log.e("","event generate id.. "+eventid); return eventid; }
now, event created fine. problem is, in android calendar event showing few weeks , after weeks not view in calendar while according rrule should show 16 times. start date of event 12 may 2015 , never end. same issue occurring events having rrule. htc desire device showing events in perfect manner while issue coming in moto g , samsung device. please sort out problem...!
when swipe calendar event no more..
try set event duration instead of dtend. comment line values.put(calendarcontract.events.dtend, endmillis); add line values.put(calendarcontract.events.duration, "pt1h"); pt1h means 1 hour . rfc 545 formats.
Comments
Post a Comment