My favorites | Sign in
Project Home Downloads Wiki Issues Source
Using the Google APIs Client Library for Java on Android
Updated Aug 26 (6 days ago) by

Android is one of the supported Java environments for the Google APIs Client Library for Java.


Getting Started

Begin by reading the Android development instructions in the Google HTTP Client Library for Java documentation.

Best-Practices Video

In the following hour-long video from Google I/O 2011, Yaniv Inbar describes best practices for accessing Google APIs on Android.


As described in the Android development instructions, the best practice on Android (since the 2.1 SDK) is to use the AccountManager class (@Beta) for centralized identity management and credential token storage.

OAuth 2.0

For information about the OAuth 2.0 flow, see the OAuth 2.0 instructions for Android.


ClientLogin is a deprecated authentication protocol used by older Google APIs. For new applications, we encourage you to use the more secure OAuth 2.0 protocol. Support for ClientLogin in the Google APIs Client Library for Java will be removed.

Older Google APIs that support ClientLogin are well supported on Android. To get an auth token, call AccountManager.getAuthToken() with the appropriate authTokenType for the Google API you are using, for example cl for the Google Calendar Data API.

Partial Response and Update

Google APIs support a partial-response protocol that allows you to specify which fields should be returned to you in the HTTP response. This can significantly reduce the size of the response, thereby reducing network usage, parsing response time, and memory usage. It works with both JSON and XML.

The following snippet of code drawn from the Google+ Sample demonstrates how to use the partial-response protocol:

Plus.Activities.List listActivities = plus.activities().list("me", "public");
// Pro tip: Use partial responses to improve response time considerably
ActivityFeed feed = listActivities.execute();


A good example that uses the generated service-specific library is tasks-android-sample. Another example can be found in calendar-android-sample, which mixes ClientLogin with the service-specific library.

Powered by Google Project Hosting