繁体   English   中英

如何在Android上编辑Google日历活动?

[英]How to edit google calendar event on Android?

我想使用Google Calendar API编辑活动。 在示例中,有一个代码可以编辑日历:

Entry executePatchRelativeToOriginal(Entry updated, Entry original) throws IOException {
   AtomPatchRelativeToOriginalContent content = new AtomPatchRelativeToOriginalContent();
   content.namespaceDictionary = DICTIONARY;
   content.originalEntry = original;
   content.patchedEntry = updated;
   HttpRequest request =
      requestFactory.buildPatchRequest(new GenericUrl(updated.getEditLink()), content);
   return request.execute().parseAs(updated.getClass());

如果我要编辑日历,它可以工作,但不能与编辑事件一起工作:我有例外:

09-11 17:29:13.516: WARN/System.err(15787): com.google.api.client.http.HttpResponseException: 403 Forbidden

我当然有编辑事件的权利。 此外,删除日历的方法与删除日历相同。 删除功能:

public void executeDelete(Entry entry) throws IOException {
    HttpRequest request = requestFactory.buildDeleteRequest(new GenericUrl(entry.getEditLink()));
    request.execute().ignore();
}

有任何想法吗?

问题解决了! 我在Atom中使用HTTP PUT而不是HTTP PATCH,并修改了原始事件,而不是创建该对象的另一个实例。

这是一个工作代码:

public EventEntry executePutUpdateEvent(EventEntry updated) throws IOException {
AtomContent content = new AtomContent();
content.namespaceDictionary = DICTIONARY;
content.entry = updated;
HttpRequest request =
    requestFactory.buildPutRequest(new GenericUrl(updated.getEditLink()), content);
return request.execute().parseAs(updated.getClass());}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM