How can I make the Play Game Services not automatically sign in at the startup?

前端 未结 5 1633
予麋鹿
予麋鹿 2020-12-30 20:59

Google provides the BaseGameUtils library, and recommend us to extends its BaseGameActivity. However, this class makes the game automatically sign in whenever t

5条回答
  •  [愿得一人]
    2020-12-30 21:56

    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);
    

提交回复
热议问题