I’m working on integrating Google Calendar API into my Android application and running into some trouble. I keep getting a deprecation warning when using the calendar.builder method, but I can’t figure out what the recommended replacement is.
Here’s what I’m currently using:
public static Calendar createCalendarService(GoogleCredential creds) {
HttpTransport httpTransport = AndroidHttp.newCompatibleTransport();
JsonFactory factory = new JacksonFactory();
com.google.api.services.calendar.Calendar calendarService;
calendarService = Calendar.builder(httpTransport, factory)
.setApplicationName("MyApp/2.0")
.setJsonHttpRequestInitializer(new JsonHttpRequestInitializer() {
@Override
public void initialize(JsonHttpRequest req) {
CalendarRequest calReq = (CalendarRequest) req;
calReq.setKey(API_KEY);
}
}).setHttpRequestInitializer(creds).build();
return calendarService;
}
What’s the modern way to handle this? Any help would be great!