How to get today's calendar events using ContentProvider

953 views Asked by At

I have the following code to get every event in my Google Calendar using ContentProvider. (Link here)

CalendarProvider calendarProvider = new CalendarProvider(context);

    List<Calendar> calendars = calendarProvider.getCalendars().getList();

    for (Calendar calendar : calendars) {
        List<Event> events = calendarProvider.getEvents(calendar.id).getList();
        for (Event event : events) {
            System.out.println("EVENT: " + event.title);
        }
    }

This will return all of the title's for event calendar event. My question is how do I filter the results returned to me to only show today's calendar events (i.e The events that go on at some point today)

I have experimented with things such as:

event.rDate
event.lastDate
event.eventExDate

But I can't seem to make any sense out of the results.

Thanks in advance :)

1

There are 1 answers

0
Anthony Cannon On BEST ANSWER

This could be a duplicate question, but nevertheless this can be solved by using the answer: https://stackoverflow.com/a/15331996/7403656

Within the answer you will have to set variables: stTime and enTime to today's date.