Get Google Calendar Events Start and End Times with google-java-api-client in Android

前端 未结 1 518
失恋的感觉
失恋的感觉 2021-01-03 05:20

How would one go about parsing the start and end times of events in a users Google Calendar using the google-api-java-client?

After installing this sample android pr

相关标签:
1条回答
  • 2021-01-03 06:00

    You'll need to use the EventFeed and take a look at the EventEntry class

    http://code.google.com/p/google-api-java-client/source/browse/calendar-v2-atom-oauth-sample/src/com/google/api/client/sample/calendar/v2/model/EventEntry.java?repo=samples

    The Atom string returned containing the startTime / endTime will look like this :

    <gd:when startTime='2010-03-13T14:00Z' endTime='2010-03-13T14:30Z'/>
    

    It's modelled in the EventEntry class like this :

    @Key("gd:when")
    public When when;
    

    (a property for the When object, mapped using the @Key annotation)

    The When object, models the start/endTime attributes on the When object

    @Key("@startTime")
    public DateTime startTime;
    
    @Key("@endTime")
    public DateTime endTime;
    

    Client code when inteacting with the eventFeed will look like this :

    EventEntry event = eventFeed.get(0);
    DateTime start = event.when.startDate;
    
    0 讨论(0)
提交回复
热议问题