Unable to get signed in user's profile from google plus in android

349 views Asked by At

My code works for getting connected and retrieving user email ID :

 String account = Plus.AccountApi.getAccountName(mGoogleApiClient);

But when I am trying to get user profile, it contains null info.Here is my code.

mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_PROFILE).build();

@Override
public void onConnected(Bundle arg0) {

account = Plus.AccountApi.getAccountName(mGoogleApiClient);
        Plus.PeopleApi.loadVisible(mGoogleApiClient, null)
                .setResultCallback(this);

        String personName = "Unknown";
        if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
            Person currentPerson = Plus.PeopleApi
                    .getCurrentPerson(mGoogleApiClient);
            personName = currentPerson.getDisplayName();
        }
}

Here , Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) shows null.

Any help is appreciated..

0

There are 0 answers