1
votes

I'd like to access the Google Calendar of a user after Login, since I want to mirror certain labeled events in my Apps event class.

I guess the Google Calendar API Java Library can't be simply used here, so I was sent to this Library by the Codename One Support.

Does anyone have experience or Code examples for this Library? How did you guys handle access to Google Calendar API if not with this library?

1

1 Answers

1
votes

I did some of the initial work on that but haven't kept up with the changes done by the other authors so I can't say I have actual experience with this library...

From the code something like this should work:

DeviceCalendar dc = DeviceCalendar.getInstance();
if(!dc.hasPermissions()) {
    // show message 
    return;
}
String calName = Preferences.get("selectedCalendar", null);
if(calName == null) {
    Collection<String> calendarNames = dc.getCalendars()
    calName = promptUserToPickCalendar(calendarNames);
    if(calName == null) {
       return;
    }
    Preferences.set("selectedCalendar", calName);
}
String calId = dc.openCalendar(calName, false);
Collection<EventInfo> events = dc.getEvents(calId, startDate, endDate);
// merge your events then use removeEvent/saveEvent respectively to apply your changes