0

我想從與followoing代碼日曆刪除事件:與Android谷歌日曆API - 刪除事件

//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(); 
    } " 

有什麼不對?

我開始從這個「基地」(歷-V2-原子OAuth的樣品)建立我的模型: 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

+0

http://code.google.com/p/android-calendar-provider-tests /source/browse/trunk/src/com/androidbook/androidcalendar/CalendarActivity.java –

回答

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(); 
    }