Persist Google Play Services Login Between Activities
I thought this would be straightforward, but I've been going in circles trying to figure out how to keep a user logged in between Activities. I have a 'Main' and a 'Details' Acti
Solution 1:
The most simple way to do this is to have both activities create a separate instance of the api client. The state of the connection is shared between them internally, so you don't need worry about how to pass around the client and handle callbacks that may happen when an activity is not active, and the player will only log in on your main activity.
Extending your activity from BaseGameActivity really is not needed any longer (for an entertaining explanation watch: Death of BasegameActivity. What you do need to do is implement the two interfaces that handle initializing the GoogleAPIClient:
publicclassMainActivityextendsActivityimplementsGoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
}
To implement these, refer to the samples and the doc: https://developers.google.com/games/services/android/init
Post a Comment for "Persist Google Play Services Login Between Activities"