0

I'm new in android studio and I'm trying to get my facebook friends list with their profile pictures and all of my result is just their names, could anyone of You help me to get it? Thanks for the reply :)

My code to get the list:

void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_friends_list);

    Intent intent = getIntent();
    String jsondata = intent.getStringExtra("jsondata");

    JSONArray friendslist;
    ArrayList<String> friends = new ArrayList<String>();
    try {
        friendslist = new JSONArray(jsondata);
        for (int l=0; l < friendslist.length(); l++) {
            friends.add(friendslist.getJSONObject(l).getString("name"));
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

    ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.activity_listview, friends);
    ListView listView = (ListView) findViewById(R.id.listView);
    listView.setAdapter(adapter);
}

my JSON structure :

public void onSuccess(LoginResult login_result){
    GraphRequestAsyncTask graphRequestAsyncTask = new GraphRequest(
    login_result.getAccessToken(),
    "/me/friends",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            Intent intent = new Intent(MainActivity.this,FriendsList.class);
            try {
                JSONArray rawName = response.getJSONObject().getJSONArray("data");
                intent.putExtra("jsondata", rawName.toString());
                startActivity(intent);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }).executeAsync();
}

0 Answers0