Google plus integrating: Unable to load visible ci

2019-04-08 21:29发布

问题:

I want to get list of people info from google plus in my app: friends profile image URL, visible name and id.

Here's an official google plus integrating tutorial. I make the test app by this tutorial and trapped on error:

Error requesting visible circles: Status{statusCode=NETWORK_ERROR, resolution=null}

Implementing the Google Api Client:

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

Here's onResult:

@Override
public void onResult(People.LoadPeopleResult loadPeopleResult) {

    if (loadPeopleResult.getStatus().getStatusCode() == CommonStatusCodes.SUCCESS) {
        PersonBuffer personBuffer = loadPeopleResult.getPersonBuffer();
        try {
            int count = personBuffer.getCount();
            for (int i = 0; i < count; i++) {
                Log.d("TEST", "Display name: " + personBuffer.get(i).getDisplayName());
            }
        } finally {
            personBuffer.close();
        }
    } else {
        Log.e("TEST", "Error requesting visible circles: " + loadPeopleResult.getStatus());
    }
}

And the permissions into AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />

Please help me, what I need to do?

回答1:

I've fixed it! My problem was: I do not have specify package correctly: like this com.example but correct way is com.example.moduledir