1

我一直在尝试使用 android 中的 Google-API-Java-Client 在 Google 日历中获取事件的详细信息,例如位置详细信息、描述、开始时间和结束时间等。

我正在使用以下示例代码

http://code.google.com/p/google-api-java-client/source/browse?repo=samples#hg%2Fcalendar-v2-atom-android-sample

4

1 回答 1

0

I can answer your question only in the scope of When. This is my solution referenced from calendar-android-sample:

    List<EventEntry> events; //Don't forget to initialize
    //Get CalendarEntry from somewhere
    CalendarEntry calendar = getCalendar(); //this my function. Create your own.

    CalendarUrl eventUrl =
        new CalendarUrl(calendar.getEventFeedLink());
    // page through results
    while (true) {
      EventFeed eventFeed = client.eventFeed().list().execute(eventUrl);
      if (eventFeed.events != null) {
        events.addAll(eventFeed.events);
      }
      String nextLink = eventFeed.getNextLink();
      if (nextLink == null) {
        break;
      }
    }
    int numEvents = events.size();
    When[] times = new When[numEvents];
    for (int i = 0; i < numEvents; i++) {
      times[i] = events.get(i).when; //here you can get all events time. Manipulate as you wish.
    }
于 2011-11-22T16:03:32.847 回答