如何实现 google play GAMES 登录?

How can I implement google play GAMES sign in?

我使用来自 this SignInActivity.java 的自定义 xml 布局让我的 google 登录正常工作(尽管它有时会给我 handleSignInResult: false),但是现在我需要用户可以登录到 Google Play Games,并可以选择选择要选择的电子邮件,我想要这种很多 android 游戏都在使用的风格,它有一个很好的还有动画:

哦,我在某处读到你不能将 Games.API 与 Auth.API 一起使用。

编辑:我按照 this documentation 正确实现了代码并且登录已经有 Google Play Games 动画,但现在我要解决的问题是:

您只需在 GoogleApiClient 初始化中添加这一行。 .addApi(Games.API).addScope(Games.SCOPE_GAMES)

它应该看起来像这样:

 mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .addApi(Games.API).addScope(Games.SCOPE_GAMES)
        .build();

实际上,它已经在您给定的文档中具体讨论过 Start the sign-in flow

In the activity's onClick method, handle sign-in button taps by creating a sign-in intent with the getSignInIntent method, and starting the intent with startActivityForResult.

private void signIn() {
    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
    startActivityForResult(signInIntent, RC_SIGN_IN);
}
SignInActivity.java

Starting the intent prompts the user to select a Google account to sign in with.

有关 intent 的更多信息,请参见 GoogleSignInApi

并且,关于各种 Google Play 游戏服务的设计规范,将用于添加一些样式和动画,请注意 Branding Guidelines

我通过再次链接同一个游戏来修复最后一个错误,因为您无法删除链接的应用程序并使用测试帐户。