3

Through this example I am able to integrate Google+ with android and to fetch my information like user id, url, profile name and profile picture.
I want also to fetch the list of all my friends and to show it.
How can I do this and which class is useful?

Kara
  • 6,115
  • 16
  • 50
  • 57
Ronak Mehta
  • 5,971
  • 5
  • 42
  • 69

2 Answers2

6

This can be done using google plus api. Though you can not get full profile information of every friend in one request, it will give you at least following information

  • id
  • displayName
  • image
  • objectType
  • url

To get profile information further you have to fetch each friend's profile information separately.

Given below is the code to fetch friends list

       mPlusClient.loadPeople(new OnPeopleLoadedListener()
        {

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

                if ( ConnectionResult.SUCCESS == status.getErrorCode() )
                {
                    Log.v(TAG, "Fetched the list of friends");
                    for ( Person p : personBuffer )
                    {
                        Log.v(TAG, p.getDisplayName());
                    }
                }
            }
        }, Person.Collection.VISIBLE); // VISIBLE=0
    }

"for-loop" in the callback is there to iterate over each "Person" object.

Now to get further profile information you can use following snippet of code

     mPlusClient.loadPerson(new OnPersonLoadedListener()
        {

            @Override
            public void onPersonLoaded(ConnectionResult status, Person person)
            {
                if ( ConnectionResult.SUCCESS == status.getErrorCode()) 
                {
                    Log.v(TAG, person.toString());
                }

            }
        }, "me"); // Instead of "me" use id of the user whose profile information you are willing to get.

For further clarity please take a look at this link https://developers.google.com/+/mobile/android/people

ujwalendu
  • 79
  • 1
  • 6
1

There is not currently an API method exposed to list friends of a G+ user.

You can learn more about what methods are exposed here: https://developers.google.com/+/api/

Jason Hall
  • 20,632
  • 4
  • 50
  • 57
  • @ArpitGarg It is still not listed in the API methods at https://developers.google.com/+/api/ so no, this is still not possible. – Jason Hall Nov 02 '12 at 13:41