Android Calendar API - 在定期系列中编辑/删除一个事件

时间:2012-01-17 00:23:34

标签: android android-calendar recurring-events

我可以添加和删除新的定期活动,但如何使用新的Android日历API在定期活动中编辑/删除一个活动?如果可以,我如何更新一个事件的提醒?

问丹尼尔

1 个答案:

答案 0 :(得分:0)

也许这会有所帮助:

// First retrieve the instances from the API.
Events instances = service.events().instances("primary", "recurringEventId").execute();

// Select the instance to edit
Event instance = instances.getItems().get(0);

if(youWantToCancel) {
     instance.setStatus("canceled");
     instance.setReminders(yourReminders);
     Event updatedInstance = service.events().update("primary", instance.getId(),   instance).execute();
}

if(youWantToDelete){
    instance.setId("ToBeDeleted")
    service.events().delete("primary", instance.getId()).execute();
}

如果要在重复中删除多个事件,只需将id设置为某些明显的字符串,如“ToBeDeleted”,然后执行:service.events().delete("primary", "ToBeDeleted").execute();docs