0
votes

I am trying to access google calendar in android .. I am using google java client api (gdata api not working in android.. tried a lot.. some issue with library ).. What i received were list of calendar, not events. So I want to access events within a specific date range.. say I want to retrieve all the events inbetween date range 3-march-2011 to 5 march 2011 Can anyone tell me how to do that ?

I am using the following example at http://code.google.com/p/google-api-java-client/source/browse/calendar-v2-atom-android-sample/?repo=samples&r=f1e31c6861e04679c450e36531cf7b3bcc96ed74

1
please help me to figure out itKiradev

1 Answers

1
votes

If you are using calendar-android-sample from google-api-java-client,

Here they have given the example for accessing the Calendars. If you want to access events then you need the calendar-id. To get that,

In your project src you will find a class named CalendarSampleActivity.java. In this there is a method called refreshView(). In which they have created the list of Calendars associated with that account by populating data as calendarInfo.summary. You can get id by calendarInfo.id.

Now there is a class named AsyncLoadCalendars.java. Copy it into same destination and name it as AsyncLoadEvents.java. In that just replace

CalendarList feed = client.calendarList().list().setFields(CalendarInfo.FEED_FIELDS).execute();
model.reset(feed.getItems());

by

Events events = client.events().list("calendar_id").execute(); //Pass calendar_id as parameter

Here you have to the pass calendar_id that we obtained previously. Now Call this method properly. You will get the list of all the events in JSON formate. Just parse it and get neccessary data.