My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Android  
Android environment.
Updated Mar 19, 2012 by rmis...@google.com

Session Presentation | Session Notes

READ THIS FIRST: Android development instructions (from google-http-java-client)

Authentication

The best practice on Android (since the 2.0 SDK) is to use the AccountManager for identity management and authentication storage.

OAuth 2.0

Please read the details of the OAuth 2.0 flow on Android here.

ClientLogin

Older Google APIs that support ClientLogin are well supported on Android. You 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 partial response protocol that allows you to specify which fields should be returned to you in the HTTP response. This significantly reduces the size of the response and therefore reduces network usage, parsing response time, and memory usage. It works with both JSON and XML. Here's a snippet of code that demonstrates how to use from the Google+ Sample:

    Plus.Activities.List listActivities = plus.activities().list("me", "public");
    listActivities.setMaxResults(5L);
    // Pro tip: Use partial responses to improve response time considerably
    listActivities.setFields("nextPageToken,items(id,url,object/content)");
    ActivityFeed feed = listActivities.execute();

Samples

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. Finally, there is an example at picasa-android-sample which uses the XML-based data model.

Powered by Google Project Hosting