如何在Android日历中添加事件,每3天重复一次?

时间:2012-11-07 11:33:01

标签: android calendar

我想使用以下代码将事件添加到Android日历中:

cr = getContentResolver();
ContentValues values = new ContentValues();
values.put(Events.DTSTART, startMillis);
values.put(Events.DURATION, "P3600S");
values.put(Events.TITLE, "MyTestNew");
values.put(Events.DESCRIPTION, "Group workout");
values.put(Events.CALENDAR_ID, calID);
values.put(Events.EVENT_TIMEZONE, "India");
values.put(Events.ALL_DAY, 1);
values.put(Events.RRULE, "FREQ=WEEKLY;WKST=SU;BYDAY=SA");
uri = cr.insert(Events.CONTENT_URI, values);

但我希望添加此事件,该事件应该每三天重复一次,而不是我(Events.RRULE,参数中的更改。我怎么能这样做?

2 个答案:

答案 0 :(得分:2)

最后我找到了解决方案。

values.put(Events.DTSTART, startMillis);
values.put(Events.DURATION, "P1800S");
values.put(Events.TITLE, "MyTestNew");
values.put(Events.DESCRIPTION, "Group workout");
values.put(Events.CALENDAR_ID, calID);
values.put(Events.EVENT_TIMEZONE, "India");
values.put(Events.RRULE, "FREQ=DAILY;INTERVAL=3");
uri = cr.insert(Events.CONTENT_URI, values);

答案 1 :(得分:0)

This code start the default calender of android and you can add event on it.

String dtStart = "2012" + "" + "06-11-01T10:50:00Z";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
try {Date date = format.parse(dtStart);
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
//cal.setTime(date);

Intent intent = new Intent(Intent.ACTION_EDIT);                                        intent.setType("vnd.android.cursor.item/event");                     
intent.putExtra("beginTime", cal.getTimeInMillis());                            
intent.putExtra("allDay", false);                           
intent.putExtra("rrule", "FREQ=DAILY;COUNT=1");                         
intent.putExtra("endTime", cal.getTimeInMillis() + 60 * 60 * 1000);                     
intent.putExtra("title", "Booking Confirm Notification");                           
intent.putExtra("Description", "Please check details");                         
startActivity(intent);


Arun chandravanshi
Thanks.