Google 提供 BaseGameUtils
库和 recommend us to extends its BaseGameActivity
.但是,这个类使游戏在游戏开始时自动登录。如果玩家不想或无法连接到他的 Google 帐户,那么在游戏开始时这可能非常耗时。
所以我不想要这个功能。相反,我想提供一个登录按钮。玩家只有在点击该按钮时才会连接。 从那时起,每次玩家开始游戏时,他都会自动连接到他的 Google 帐户,而无需点击任何按钮。我该怎么做?
最佳答案
好的,我想通了,默认情况下,最大自动登录次数是3次,也就是说如果用户取消了3次,那么应用程序将永远不会再次(除非你清除应用程序的数据)自动登录。它存储在 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;
并且它还提供了设置这个最大数量的功能
public void setMaxAutoSignInAttempts(int max) {
mMaxAutoSignInAttempts = max;
}
因此,如果您根本不想要任何自动登录尝试,只需调用此函数即可
这是如果你不想扩展 BaseGameActivity
gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
gameHelper.enableDebugLog(true);
gameHelper.setup(this);
gameHelper.setMaxAutoSignInAttempts(0);
或者如果你扩展 BaseGameActivity
getGameHelper().setMaxAutoSignInAttempts(0);
关于android - 如何让 Play 游戏服务在启动时不自动登录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22046530/