如何让Play游戏服务不会在启动时自动登录? [英] How can I make the Play Game Services not automatically sign in at the startup?

查看:210
本文介绍了如何让Play游戏服务不会在启动时自动登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google提供 BaseGameUtils 图书馆,向我们推荐扩展它的 BaseGameActivity 。但是,每当游戏开始时,该课程都会自动登录游戏。如果玩家不想或无法连接到他的Google帐户,那么在游戏开始时这可能非常耗时。



所以我不'想要这个功能。相反,我想提供登录按钮。只有当他点击该按钮时才连接播放器。从那时起,每次玩家开始游戏时,他都会自动连接到他的Google帐户,而无需点击任何按钮。我怎样才能做到这一点?

解决方案

好的,我弄明白了,默认情况下,如果用户取消3次,那么应用程序将永远不会再次(除非您清除应用程序的数据)自动登录。它存储在 GameHelper.java 中, code>

  //我们是否应该启动流程以在启动时自动签署用户?如果是这样,高达
//在应用程序的生命周期中多少次?
static final int DEFAULT_MAX_SIGN_IN_ATTEMPTS = 3;
int mMaxAutoSignInAttempts = DEFAULT_MAX_SIGN_IN_ATTEMPTS;

它还提供了一个函数来设置这个最大数量

  public void setMaxAutoSignInAttempts(int max){
mMaxAutoSignInAttempts = max;

因此,如果您不希望进行任何自动登录尝试如果你不想扩展BaseGameActivity



,只需调用这个函数

pre> gameHelper = new GameHelper(this,GameHelper.CLIENT_GAMES);
gameHelper.enableDebugLog(true);
gameHelper.setup(this);
gameHelper.setMaxAutoSignInAttempts(0);

或者如果您扩展了BaseGameActivity

  getGameHelper()setMaxAutoSignInAttempts(0)。 


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

这篇关于如何让Play游戏服务不会在启动时自动登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆