How to get the default Google+ button for an Android app

Hi, I'm trying to learn Google login features in Android. I did this and worked fine, as expected. I follow this guide. http://www.androidhive.info/2014/02/android-login-with-google-plus-account-1/

This displays the default Google login button instead of the red Google+ button.

<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"/>

default sign

Question How can I get the Google+ button as follows. goole plus sign in

+4
source share
1 answer

You can find the following inside this Google code example , from line number 67 to # 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]

So you can use the following:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestScopes(new Scope(Scopes.PLUS_LOGIN))                
                .requestEmail()
                .build();

, !

+1

Source: https://habr.com/ru/post/1624296/


All Articles