A J
A J

Reputation: 4632

Google Calendar get event not from primary calendar

I try to get the events which are not in the primary calendar (Meeting only).

enter image description here

I am wiring it in Java (Android). What I did:

// List the next 10 events from the primary calendar.
        List<EventDetail> eventDetails = new ArrayList<>();
        Events events = mService.events().list("primary")
                .setMaxResults(10)
                .setTimeMin(now)
                .setTimeMax(end)
                .setOrderBy("startTime")
                .setSingleEvents(true)
                .execute();

Upvotes: 2

Views: 785

Answers (2)

A J
A J

Reputation: 4632

I found the solution -

        CalendarList calendarList = mService.calendarList().list().execute();
        List<CalendarListEntry> list = calendarList.getItems();

        for (CalendarListEntry calendarListEntry : list) {
            System.out.println(calendarListEntry.getSummary());
            Log.d(TAG, "Calender Id: " + calendarListEntry.getId());
        }

Upvotes: 3

albeee
albeee

Reputation: 1472

Basically you have to go through all the calendars for the particular account and decide which one you would like to get the events from. Then pass the particular calendar Id to the events table or instance table to obtain events.

Calendars Contract

Events Contract

As from your picture, one account may have more than one calendars.

Upvotes: 1

Related Questions