如何将默认 Google+ 按钮设置为 android 应用
How to get default Google+ button to android app
您好,我正在尝试学习 android 中的 Google 登录功能。我按照 expected.I 按照本教程进行操作并正常工作。 http://www.androidhive.info/2014/02/android-login-with-google-plus-account-1/
这里显示的是默认的 Google 登录按钮,而不是 Google+ 红色按钮。
<com.google.android.gms.common.SignInButton
android:id="@+id/btn_sign_in"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"/>
问题
我怎样才能得到 Google+ 按钮如下。
您可以在 this Google's sample code 中找到以下内容,从第 67 行到第 78 行
// [START customize_button]
// Customize sign-in button. The sign-in button can be displayed in
// multiple sizes and color schemes. It can also be contextually
// rendered based on the requested scopes. For example. a red button may
// be displayed when Google+ scopes are requested, but a white button
// may be displayed when only basic profile is requested. Try adding the
// Scopes.PLUS_LOGIN scope to the GoogleSignInOptions to see the
// difference.
SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button);
signInButton.setSize(SignInButton.SIZE_STANDARD);
signInButton.setScopes(gso.getScopeArray());
// [END customize_button]
因此,您可以使用以下内容:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(new Scope(Scopes.PLUS_LOGIN))
.requestEmail()
.build();
希望对您有所帮助!
您好,我正在尝试学习 android 中的 Google 登录功能。我按照 expected.I 按照本教程进行操作并正常工作。 http://www.androidhive.info/2014/02/android-login-with-google-plus-account-1/
这里显示的是默认的 Google 登录按钮,而不是 Google+ 红色按钮。
<com.google.android.gms.common.SignInButton
android:id="@+id/btn_sign_in"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"/>
问题
我怎样才能得到 Google+ 按钮如下。
您可以在 this Google's sample code 中找到以下内容,从第 67 行到第 78 行
// [START customize_button]
// Customize sign-in button. The sign-in button can be displayed in
// multiple sizes and color schemes. It can also be contextually
// rendered based on the requested scopes. For example. a red button may
// be displayed when Google+ scopes are requested, but a white button
// may be displayed when only basic profile is requested. Try adding the
// Scopes.PLUS_LOGIN scope to the GoogleSignInOptions to see the
// difference.
SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button);
signInButton.setSize(SignInButton.SIZE_STANDARD);
signInButton.setScopes(gso.getScopeArray());
// [END customize_button]
因此,您可以使用以下内容:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(new Scope(Scopes.PLUS_LOGIN))
.requestEmail()
.build();
希望对您有所帮助!