我有一个项目,我喜欢使用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();
答案 0 :(得分:1)
您可以改用以下内容:
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());