I am testing a game to publish on the play store. Everything seems to be working fine, except I have a node that logs into Google Play Games every time the main menu is opened. I didn't think it'd actually LOG IN, show that green window with the controller, and everything every single time.
I know there must be a way to do this, but I just don't know how. I need something to connect to Google Play Games before the first level is opened. Anybody done this before mind helping a noob?
It will still depend on your implementation.
If your game activity calls connect() in onStart(), the GoogleApiClient will attempt to sign in silently. If the user signed in successfully before and has not signed out, the system calls the onConnected() method. If sign in fails, the system calls the onConnectionFailed() method.
You can check the Signing the player in at startup :
After users sign in successfully for the first time in your game, your game should sign them in automatically whenever they start the game again, until they explicitly sign out.
To add automatic sign-in, implement the following behavior in the
onStart()
callback.
boolean mExplicitSignOut = false;
boolean mInSignInFlow = false; // set to true when you're in the middle of the
// sign in flow, to know you should not attempt
// to connect in onStart()
GoogleApiClient mGoogleApiClient; // initialized in onCreate
@Override
protected void onStart() {
super.onStart();
if (!mInSignInFlow && !mExplicitSignOut) {
// auto sign in
mGoogleApiClient.connect();
}
}
@Override
public void onClick (View view) {
if (view.getId() == R.id.sign_out_button) {
// user explicitly signed out, so turn off auto sign in
mExplicitSignOut = true;
if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
Games.signOut(mGoogleApiClient);
mGoogleApiClient.disconnect();
}
}
// ...
}
Hope this helps.