2016-07-21 98 views
-1

我查看了文檔並在網上搜索了一些教程,然後看到了一些使用BaseGameActivity.java和其他地方的地方,但現在我從來沒有更困惑過,所以我會列出我的問題,希望有人能夠澄清我的問題(請不要僅以文檔鏈接回覆)。如何設置Google Play遊戲登錄?

我需要的是玩家在開始時自動登錄。

1)我的遊戲是否必須發佈,或者是否必須在某處插入一些ID?(我的遊戲在開發者控制檯上準備發佈)。

2)我必須爲登錄功能編寫的實際代碼是什麼?

回答

0

請按照Google Play Games Services docs已經爲您指定的步驟操作。

步驟1.登錄到谷歌Play開發者控制檯

步驟2將您的遊戲到谷歌Play開發者控制檯

第3步:生成一個OAuth 2.0客戶端ID

檢查GPGS Android Samples in Github

我必須爲登錄功能編寫的實際代碼是什麼?

如何Implement Sign-in在您的Android遊戲

private static int RC_SIGN_IN = 9001; 
private boolean mResolvingConnectionFailure = false; 
private boolean mAutoStartSignInflow = true; 
private boolean mSignInClicked = false; 

// ... 

@Override 
public void onConnectionFailed(ConnectionResult connectionResult) { 
    if (mResolvingConnectionFailure) { 
     // Already resolving 
     return; 
    } 

    // If the sign in button was clicked or if auto sign-in is enabled, 
    // launch the sign-in flow 
    if (mSignInClicked || mAutoStartSignInFlow) { 
     mAutoStartSignInFlow = false; 
     mSignInClicked = false; 
     mResolvingConnectionFailure = true; 

     // Attempt to resolve the connection failure using BaseGameUtils. 
     // The R.string.signin_other_error value should reference a generic 
     // error string in your strings.xml file, such as "There was 
     // an issue with sign in, please try again later." 
     if (!BaseGameUtils.resolveConnectionFailure(this, 
       mGoogleApiClient, connectionResult, 
       RC_SIGN_IN, R.string.signin_other_error)) { 
      mResolvingConnectionFailure = false; 
     } 
    } 

    // Put code here to display the sign-in button 
} 
+0

我得到這個錯誤: –

+0

java.lang.NoSuchMethodError:沒有直接的方法。它指向mGoogleApiClient.connect()的主類;是 –

相關問題