2

I am new in Facebook integration with android. I've logged in to Facebook by using facebook-android-SDK. Now I want to get all friends details and display in ListView. How can I do this?

Please help me

Thanks in advance

Krishna Suthar
  • 3,071
  • 6
  • 31
  • 37

3 Answers3

6

Go with following code to get frends list :

Bundle params = new Bundle();
        params.putString("fields", "name, picture");
        JSONObject jsonFrends = Util.parseJson(facebook.request("me/friends", params));
P Srinivas Goud
  • 886
  • 1
  • 12
  • 30
3

I would recommend following the tutorial on Fetching User Data and then instead of executing

    ...
if (state.isOpened()) {
    userInfoTextView.setVisibility(View.VISIBLE);

    // Request user data and show the results
    Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {

        @Override
        public void onCompleted(GraphUser user, Response response) {
            if (user != null) {
                // Display the parsed user info
                userInfoTextView.setText(buildUserInfoDisplay(user));
            }
        }
    });
}
...

use Request.executeMyFriendsRequestAsync which is part of the Request class.

EDIT: Which also has the advantage of using the Facebook Android SDK to parse the response.

LordParsley
  • 3,808
  • 2
  • 30
  • 41
0

You can do by this way :

Using the graph API: https://graph.facebook.com/me/friends?access_token="your access_token"
Mehul Ranpara
  • 4,245
  • 2
  • 26
  • 39