With Play services 8.4, the method getCurrentPerson is deprecated and I was using the PeopleApi to get user's first name, last name and gender.
Can anyone tell me how to get the signed in user's info using another method?
With Play services 8.4, the method getCurrentPerson is deprecated and I was using the PeopleApi to get user's first name, last name and gender.
Can anyone tell me how to get the signed in user's info using another method?
Update: Check Isabella's answer. This answer uses deprecated stuff.
I found the solution myself so I'm posting it here if anyone else faces the same problem.
Although I was looking for a solution for using GoogleSignInApi to get user's info, I couldn't find that and I think we need to use the Plus Api to get info like gender.
HandleSignInResult
Just to add to Hardy's answer above, which guided me in the right direction.
I ended up using two calls to GoogleApiClient as I couldn't get what Hardy has above to work.
My first call is to the GoogleSignInApi
This then give me the first part through the onActivityResult, the same as Hardy. However then I use the call to the GoogleApiClient.Builder again
Now I can access the Plus.PeopleApi via the onConnected callback
With appropriate disconnects and revokes.
You may notice my code uses the same callbacks, which I need to tidy up, but the principal is there.
Hello I have found an alternative way for the latest Google Plus login, use the method below:
And on Activity result use the code below:
Finally your onClick will be:
The first thing to do is follow the google orientation at Add Google Sign-In to Your Android App.
Then you have to change the GoogleSignInOptions to:
If you need to add another scopes you can do it like this:
And at 'onActivityResult' inside 'if (result.isSuccess()) {' insert this:
and create this method:
Using this you can use the methods inside 'Person meProfile' to get other info, but you can only the get the public info of the user otherwise it will be null.
Google Sign-In API can already provide you with first / last / display name, email and profile picture url. If you need other profile information like gender, use it in conjunction with new People API
Then write sign-in code,
When handling sign-in result:
Use People Api to retrieve detailed person info.
Take a look at JavaDoc to see what other profile information you can get.