Google provides the BaseGameUtils
library, and recommend us to extends its BaseGameActivity
. However, this class makes the game automatically sign in whenever the game is started. If the player does not want to or cannot connect to his Google account, this can be very time consuming at the beginning of the game.
So I dont' want this feature. Instead, I want to provide a sign in button. The player is connected only when he click that button. And from that point on, every time the player starts the game, he is automatically connected to his Google account without clicking any button. How can I do this?
OK, I have figured it out, by default, the maximum auto sign-in times is 3, which means if the user cancels 3 times, then the app will never again (unless you clear the app's data) automatically sign in. It's stored in GameHelper.java
// Should we start the flow to sign the user in automatically on startup? If so, up to
// how many times in the life of the application?
static final int DEFAULT_MAX_SIGN_IN_ATTEMPTS = 3;
int mMaxAutoSignInAttempts = DEFAULT_MAX_SIGN_IN_ATTEMPTS;
And it also provides a function to set this maximum number
public void setMaxAutoSignInAttempts(int max) {
mMaxAutoSignInAttempts = max;
}
So if you don't want any automatic signing-in attempt at all, just call this function
This is if you don't want to extends BaseGameActivity
gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
gameHelper.enableDebugLog(true);
gameHelper.setup(this);
gameHelper.setMaxAutoSignInAttempts(0);
Or if you extends BaseGameActivity
getGameHelper().setMaxAutoSignInAttempts(0);