Access google plus client from multiple activities

Managing a separate instance of GoogleApiClient in each activity will not result in the user being asked to sign in multiple times.

Google+ Sign-in (ie. GoogleApiClient) provides an interface to the Google accounts on the device and the Google Play services core service – it doesn’t have state per GoogleApiClient instance. So once a device account has been authenticated for your app, new instances of GoogleApiClient will access the same state. GoogleApiClient is specifically designed to be a lightweight way to access the central state managed by Google Play services.

You’re in luck regarding access tokens! Google Play services takes care of all token management for you. So although access tokens only last for one hour, as you say, if you try to use your PlusClient to access a Google API and your access token has expired, Google Play services will transparently request a new access token for you and complete the call.

Take a look at the first part of this Google I/O talk for more details:

http://www.youtube.com/watch?v=_KBHf1EODuk

Leave a Comment