-1

Hello all i have posted this question two times now i am posting it again

How to get user's gender and date of birth by using googleapi client in android?

How to integrate google+ sign in my android app?

how can i get person's gender and date of birth using google + sign-in android my code is given below but what is happening is that i am only getting google sign in information but not of google + login. If there is some one how has done this google + integration in android please help me it will be really really helpful for me.

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

    mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
            .enableAutoManage(getActivity(), this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .addApi(Plus.API)
            .build();
Community
  • 1
  • 1
aman verma
  • 732
  • 1
  • 8
  • 26

1 Answers1

0

Firstly, while creating mGoogleApiClient, you have to add permissions to access google plus profile. Add this

mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
        .enableAutoManage(getActivity(), this)
        .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
        .addApi(Plus.API)
        .addScope(new Scope(Scopes.PROFILE))
        .build();

Once authentication is succesful and user has made his gender public. Use this to get user's gender.

gender = Plus.plusClient.getCurrentPerson(mGoogleApiClient).getGender();
kartikmaji
  • 946
  • 7
  • 22