谷歌日历api与android - 删除事件

时间:2011-07-15 12:07:18

标签: android google-api google-calendar-api google-api-java-client

我想从日历中删除一个包含以下代码的事件:

//insertedEntry: I want to delete it.

"client.executeDelete(insertedEntry);" 

in the Class CalendarClient: 
"  public void executeDelete(Entry entry) throws IOException { 
    HttpRequest request = requestFactory.buildDeleteRequest(new GenericUrl(entry.getEditLink())); 
    request.execute().ignore(); 
   } "

怎么了?

我开始从这个“基础”(calendar-v2-atom-oauth-sample)构建我的模型: http://code.google.com/p/google-api-java-client/source/browse/?repo=samples#hg%2Fcalendar-v2-atom-oauth-sample%2Fsrc%2Fcom%2Fgoogle%2Fapi%2Fclient%2Fsample%2Fcalendar%2Fv2%2Fmodel

2 个答案:

答案 0 :(得分:1)

将此添加到EventEntry.java:

@Key("@gd:etag")
public String etag;

将此添加到CalendarClient.java:

   public void executeDelete(Entry entry) throws IOException {
        HttpRequest request = requestFactory.buildDeleteRequest(new GenericUrl(entry.getEditLink()));
        if (entry instanceof EventEntry) {
            request.headers.ifMatch = ((EventEntry) entry).etag;
        }
        request.execute().ignore();
    }

答案 1 :(得分:0)

我刚刚遇到这个以及403 Forbidden错误。

有趣的是CalendarClient.executeDelete适用于CalendarEntry,如下例所示:

http://samples.google-api-java-client.googlecode.com/hg/calendar-v2-atom-android-sample/src/com/google/api/client/sample/calendar/android/CalendarAndroidSample.java

必须继续挖掘以找到删除事件解决方案。