Android Google Plus getCurrentPerson returns null

When I call plusClient.getCurrentPerson() , I get NULL.

The onConnected(Bundle...) method is called after a successful login:

 @Override public void onConnected(Bundle bundle) { if (plusClient.getCurrentPerson() == null) { Log.e("DD", "Person is null !"); } } 

I added SHA1 directly from eclipse (Window-> Preferences-> Android-> Build). I do not know what I am doing wrong!

Eclipse ADT SHA1 fingerprint SHA1 fingerprint from Eclipse ADT

Client ID for installed applications Client ID for installed applications

Easy API Access Simple API access

+6
source share
5 answers

I just found out that you need to pass in several areas when creating the PlusClient object:

 PlusClient plusClient = new PlusClient.Builder(this, this, this).setScopes(Scopes.PLUS_LOGIN, Scopes.PLUS_PROFILE ,"https://www.googleapis.com/auth/userinfo.email").build(); 
+2
source

In my case, I forgot to enable permission for google-plus

Hope this works ... Any doubt let me know

Check from scratch:

Sometimes information about a person can be zero

check: PERMISSIONS

Important actions :

Enable Google+ API

Enable Google Maps API for Android

If you check locally , add the sha1 key in the options eclipse -> window -> preference -> Android -> Build

OR

You can generate the SHA1 key through the command line

keytool -list -v -keystore "C: \ Users \ User.android \ debug.keystore" -alias androiddebugkey -storepass android -keypass android

If you publish the application in the play-store , you need to change the SHA1 key in the google console

because in the local SHA1 key is different. After the signedApk SHA1 command differs from

When creating a signed apk -> on the last screen -> you can see SHA1

After adding to the Google console, you will get an API key

Add this key to the manifest file

enter image description here

+5
source
  1. I came across this today. This is an old post, but I think others should know how I fixed it in Android Studio and what caused the problem.
    I spent the last 6 hours with this, and the problem was that a week ago I changed the package name using Refactoring from Android Studio, but something should have turned out wrong, since it would always return me zero, although I reorganized the project back to him with the original package.
    I fixed this by creating a new project without closing the original, but using the same package name and the same input code from the original project, and, to my surprise, it worked. The name of the new project was different, but I named the package the same as the old one, and it had only a button and code to control the connection and nothing more.
    The new project will read the data as it should, and now the old project somehow got on its feet and began to read the current user.
    I closed the project using the "Close Project" option in the "File" menu.

Yours faithfully!

+2
source

Check the telephone network. you can use these codes below to check:

 Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this); @Override public void onResult(LoadPeopleResult result) { Log.d(TAG, "result.getStatus():" + result.getStatus()); } 

if the result is a network error. the current person will be empty.

I am in China, since you know if we want to connect to google service, sometimes we need a good agent.

+1
source

This seems like a permission issue. I added the payment details to the Google API Console and it magically started working.

0
source

All Articles