How to get Google+ friends on Android

Through this example, I can integrate Google+ with Android and retrieve my information such as user ID, URL, profile name and profile picture.
I also want to get a list of all my friends and show it.
How can I do this and which class is helpful?

+3


source to share


2 answers


This can be done using the google plus api. While you cannot get complete information about every other with a single request, it will provide you with at least the following information.

  • ID
  • DISPLAYNAME
  • Picture
  • OBJECTTYPE
  • Url

To get more information about a profile, you will need to separately receive information about all of your friends' profiles.

Below is the code to select the 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
    }

      



The "for-loop" in the callback is the iteration over each Person object.

Now, to get more information about the profile, you can use the following code snippet

     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 more clarity, please take a look at this link https://developers.google.com/+/mobile/android/people

+6


source


There is currently no API method that shows up in G +'s friend list.



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

+1


source







All Articles