Thursday, February 16, 2012

Pulling data from Google Calendar on Android in JSON


I'm using Android SDK level 8, Java. I have an app with a WebView and I want to import JSON in it.



What I want to achieve is: Send HTTP requests to the Google Calendar API v3 and receive data in raw JSON, however, authenticating the request using the Android account manager. I've been looking at the GData Java Client, more specifically at the Calendar Android Sample , which authenticates properly, but I want to specifically avoid the following things:



  • Using the GData API - unacceptable since I want a raw JSON string.

  • Pulling the data directly through JavaScript in the WebView - unacceptable since I would want to implement a SyncProvider in Java to update the JSON string



I found some information about the issue, for example: http://code.google.com/p/google-api-java-client/wiki/AndroidAccountManager



com.google.gdata.client.GoogleService.setUserToken(android.accounts.AccountManager.getAuthToken(???))



However, all the examples are connected with GData. On the other hand, exploring the Google Calendar v3 API page, I could not figure out how to authenticate with an auth token from the Account Manager.



In summation: how to retrieve JSON through plain HTTP requests to the Calendar API v3, authenticating the user with the token from the account manager, in Java.

No comments:

Post a Comment