Android日历指定多个日期,在Android中的特定日期创建日历事件?

我有一个特定的要求来创建将在特定日期发生的日历事件.这不是每周,每月,每年都会发生的情况,但它可能会持续13天,14天,15天等.我有哪些日期会发生,但没有设定经常性日期.下面是我的代码

ContentValues calEvent = new ContentValues();

calEvent.put(CalendarContract.Events.CALENDAR_ID, 1);

calEvent.put(CalendarContract.Events.TITLE, title);

calEvent.put(CalendarContract.Events.DTSTART, d.getTime());

calEvent.put(CalendarContract.Events.DTEND, d.getTime()

+ (2 * 60 * 60 * 1000));

calEvent.put(CalendarContract.Events.HAS_ALARM, 1);

calEvent.put(CalendarContract.Events.EVENT_TIMEZONE, TimeZone

.getDefault().getID());

calEvent.put(CalendarContract.Events.EVENT_LOCATION, location);

calEvent.put(CalendarContract.Events.DESCRIPTION, description);

calEvent.put(CalendarContract.Events.RDATE, sdf1.format(d)

+ "T033000Z");

// calEvent.put(CalendarContract.Reminders.RRULE, value);

Uri uri = contentResolver.insert(

CalendarContract.Events.CONTENT_URI, calEvent);

// The returned Uri contains the content-retriever URI for the

// newly-inserted event, including its id

int id = Integer.parseInt(uri.getLastPathSegment());

// Toast.makeText(ctx, "Created Calendar Event " + id,

// Toast.LENGTH_SHORT).show();

eventId = eventId + (eventId.equalsIgnoreCase("") ? id : "," + id);

ContentValues calReminder = new ContentValues();

calReminder.put(CalendarContract.Reminders.MINUTES, minutes);

calReminder.put(CalendarContract.Reminders.EVENT_ID, id);

// calReminder.put(CalendarContract.Reminders.HAS_ALARM, 1);

calReminder.put(Reminders.METHOD, Reminders.METHOD_ALERT);

Uri uri1 = contentResolver.insert(

CalendarContract.Reminders.CONTENT_URI, calReminder);

// The returned Uri contains the content-retriever URI for the

// newly-inserted event, including its id

int id1 = Integer.parseInt(uri1.getLastPathSegment());

// Toast.makeText(ctx, "Created Calendar Reminder " + id1,

// Toast.LENGTH_SHORT).show();

reminderId = reminderId

+ (reminderId.equalsIgnoreCase("") ? id1 : "," + id1);

当我使用带有逗号分隔的日期值的RDATE时,因为有startdate&提供enddate,事件创建到startdate和amp;之间的所有日期.结束日期.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值