Get Google Plus friends Android

2019-06-14 11:42发布

I am working with google + getting friends. I can successfully log in and get my credentials. But when I use mPlusClient.loadPeople(this, "me");, the return of

@Override
    public void onPeopleLoaded(ConnectionResult status, PersonBuffer personBuffer, String nextPageToken) {
        switch (status.getErrorCode()) {

        case ConnectionResult.SUCCESS:
            try {
                int count = personBuffer.getCount();
                Log.e("", "count : " + count);
                for (int i = 0; i < count; i++) {
                    Log.e("NAME", "" + personBuffer.get(i).getDisplayName());
                }
            } finally {
                personBuffer.close();
            }

            break;

        case ConnectionResult.SIGN_IN_REQUIRED:
            mPlusClient.disconnect();
            mPlusClient.connect();
            break;

        default:
            Log.e("TAG", "Error when listing people: " + status);
            break;
        }
    }

is only the details of the logged in user. Now what I what to achieve is to get the list of my friends. I tried using

mPlusClient.loadPeople(MainActivity.this, Person.Collection.Visible);

but it says "Collection cannot be resolved or is not a field". Any help would be highly appreciated. Thank you.

2条回答
淡お忘
2楼-- · 2019-06-14 12:07

This link somehow helped me to feftch the members of my circle in google plus.

mPlusClient.loadVisiblePeople(this, null);

solved the problem. People.Collection.VISIBLE is not already working. I do not know why.

查看更多
霸刀☆藐视天下
3楼-- · 2019-06-14 12:22

Looks like you're after the PlusClient.loadVisiblePeople method.

You can see an example of the response using Web API explorer.

查看更多
登录 后发表回答