[英]google calendar api with android - delete event
I would like to delete an event from a calendar with the followoing code:我想使用以下代码从日历中删除一个事件:
//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();
} "
What's wrong?怎么了?
I'm started to build my model from this "base" (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我开始从这个“基础”(calendar-v2-atom-oauth-sample)构建我的 model: 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
Added this to EventEntry.java:将此添加到 EventEntry.java:
@Key("@gd:etag")
public String etag;
Added this to CalendarClient.java:将此添加到 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();
}
I've just encountered this as well getting a 403 Forbidden error.我刚刚也遇到了 403 Forbidden 错误。
Interesting that CalendarClient.executeDelete works for a CalendarEntry as shown in this example:有趣的是,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 http://samples.google-api-java-client.googlecode.com/hg/calendar-v2-atom-android-sample/src/com/google/api/client/sample/calendar/android/CalendarAndroidSample.java
Gonna have to keep digging to find the delete event solution.将不得不继续挖掘以找到删除事件的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.