谷歌加号看起来像谷歌登录按钮安卓版。

3

我有一个项目想要使用Google Plus登录。按照Google的指南,需要在控制台中创建并开放Google Plus API。

https://developers.google.com/identity/sign-in/android/start-integrating

如下图所示:

<com.google.android.gms.common.SignInButton
            android:id="@+id/btn_signup_gmail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="2dp"
            />

并且也添加到我的登录类中

SignInButton signInButton = (SignInButton) findViewById(R.id.btn_signup_gmail);
    signInButton.setSize(SignInButton.SIZE_WIDE);
    signInButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            signIn();
        }
    });

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(Plus.API)
            .addScope(new Scope (Scopes.PLUS_LOGIN))
            .addScope(new Scope(Scopes.PLUS_ME))
            .build();

问题是谷歌加号按钮显示如下:enter image description here
1个回答

2
您可以使用以下内容代替:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestScopes(new Scope(Scopes.PLUS_LOGIN))                
                .requestEmail()
                .build();

那么,

SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button);
signInButton.setSize(SignInButton.SIZE_STANDARD);
signInButton.setScopes(gso.getScopeArray());

1
谢谢 :) 我花了一整天的时间来完成这个。 - Ahmed Elghandour
很高兴能够帮助到您 :) - BNK
请问您能否添加您获取该链接的来源? - Ahmed Elghandour
1
您可以在以下链接中的第67至78行读取注释内容:https://github.com/googlesamples/google-services/blob/master/android/signin/app/src/main/java/com/google/samples/quickstart/signin/SignInActivity.java - BNK

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接