Reputation: 19695
I'm trying to get basic info of Google+ user to login in my app.
I can connect and get the account name :
String email = mPlusClient.getAccountName(); // This works, gives me the email
Then I try to get more info with :
mPlusClient.loadVisiblePeople(new OnPeopleLoadedListener() {
@Override
public void onPeopleLoaded(ConnectionResult status,
PersonBuffer personBuffer, String nextPageToken) {
Log.i("", "persons loaded result = " + status.toString()
+ ", personsCount = " + personBuffer.getCount()
+ ", token = " + nextPageToken);
if (status.isSuccess()) {
Iterator<Person> itP = personBuffer.iterator();
while (itP.hasNext()) {
Person person = itP.next();
Toast.makeText(getApplicationContext(), person.getNickname(), 5).show();
}
}
}
}, null);
I can get friends info
persons loaded result = ConnectionResult{statusCode=SUCCESS, resolution=null}, personsCount = 15, token = null
But if I can't find how to get personal info...
When I try :
Person p = mPlusClient.getCurrentPerson();
p is null,
when I try:
mPlusClient.loadPerson(this, "me");
loadPerson is not recognized
So I don't know how to do it....
Any help would be appreciated!
Upvotes: 1
Views: 1953
Reputation: 1287
May be your Signature is diffrent??
May be , you are using CUSTOM.keystore(Release Keystore) SHA1 . So i suggest you should use DEBUG SHA1 for google console. Just Add DEBUG keystore SHA1 on google console. It will work as it did for me
Upvotes: 2
Reputation: 1210
you can try below code to get profile information of current user:
mGoogleApiClient = new GoogleApiClient.Builder(MainActivity.this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.build();
if(mGoogleApiClient != null && mGoogleApiClient.isConnected()){
if(Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null){
Person mCurrentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
String displayName = mCurrentPerson.getDisplayName();
int mUserIdOfCurrentUser = mCurrentPerson.getId();
Log.d(Constants.LOG_TAG_LOAD_VISIBLE_PEOPLE, "DisplayName: "+displayName);
Log.d(Constants.LOG_TAG_LOAD_VISIBLE_PEOPLE,"Id: "+ mCurrentPerson.getId());
Log.d(Constants.LOG_TAG_LOAD_VISIBLE_PEOPLE,"Image: "+mCurrentPerson.getImage().getUrl());
Log.d(Constants.LOG_TAG_LOAD_VISIBLE_PEOPLE,"List of Urls: "+mCurrentPerson.getUrls());
Log.d(Constants.LOG_TAG_LOAD_VISIBLE_PEOPLE,"Current Url: "+mCurrentPerson.getUrl());
Log.d(Constants.LOG_TAG_LOAD_VISIBLE_PEOPLE,"Cover: "+mCurrentPerson.getCover());
Log.d(Constants.LOG_TAG_LOAD_VISIBLE_PEOPLE,"Object type: "+mCurrentPerson.getObjectType());
Log.d(Constants.LOG_TAG_LOAD_VISIBLE_PEOPLE,"User Id : "+mUserIdOfCurrentUser);
}
Upvotes: 4