何时在Android游戏中调用onSignInSucceeded()方法?

时间:2014-07-15 07:48:23

标签: android login google-play-games

我正在尝试实施Google Play游戏服务登录功能。我使用此作为指南:https://developers.google.com/games/services/training/signin

我有一个继承自BaseGameActivity的Activity,因此在应用启动时会启动登录。这非常有效。但是我想知道什么时候完全执行。即它是在onCreate()或onStart()被调用后发生的吗?

如果我要添加game_helper.setMaxAutoSignInAttempts(0);在onCreate()中,它会在开始之前始终停止所有登录尝试吗?或者登录序列在启动后是否会停止?

谢谢。

1 个答案:

答案 0 :(得分:0)

onCreate()中完成设置,并在onStart()中执行登录。

完全阻止登录的最佳方法是在您的活动中设置game_helper.mConnectOnStart = false;' onCreate()

以下是onStart(GameHelper.java的一部分)中调用的代码:

public void onStart(Activity act) {
    mActivity = act;
    mAppContext = act.getApplicationContext();

    debugLog("onStart");
    assertConfigured("onStart");

    if (mConnectOnStart) {
        if (mGoogleApiClient.isConnected()) {
            Log.w(TAG,
                    "GameHelper: client was already connected on onStart()");
        } else {
            debugLog("Connecting client.");
            mConnecting = true;
            mGoogleApiClient.connect();
        }
    } else {
        debugLog("Not attempting to connect becase mConnectOnStart=false");
        debugLog("Instead, reporting a sign-in failure.");
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                notifyListener(false);
            }
        }, 1000);
    }
}