与Android谷歌日历API

与Android谷歌日历API

本文介绍了与Android谷歌日历API - 删除事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从与followoing code日历删除事件:

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

有什么不对?

我开始从这个基地打造我的模型(日历-V2原子的OAuth的样品):
<一href=\"http://$c$c.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\" rel=\"nofollow\">http://$c$c.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

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

推荐答案

添加到了EventEntry.java:

Added this to EventEntry.java:

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

添加到了CalendarClient.java:

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

这篇关于与Android谷歌日历API - 删除事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 19:00