Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Facebook Friends list in android application

I want to get Facebook friends list in my android application (friend picker not required).I have followed the the procedure describe on Facebook application development

I have also run the samples , but confused to get the friends list. your suggestions will be appreciated.

like image 235
M.ArslanKhan Avatar asked Dec 29 '25 16:12

M.ArslanKhan


1 Answers

you can get friend list with this code

 String returnString = null;
            JSONObject json_data = null;

            try
            {
                JSONObject response = Util.parseJson(facebook.request("me/friends"));
                JSONArray jArray = response.getJSONArray("data");

                json_data = jArray.getJSONObject(0);




                for(int i=0;i<jArray.length();i++){

                        Log.i("log_tag","User Name: "+json_data.getString("name")+
                                ", user_id: "+json_data.getString("id"));

                                returnString += "\n\t" + jArray.getJSONObject(i);

                };


                flist.setText(returnString);
                progressDialog.dismiss();
            }
            catch (MalformedURLException e)
            {
                e.printStackTrace();
            }
            catch (JSONException e)
            {
                e.printStackTrace();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            catch (FacebookError e)
            {
                e.printStackTrace();
            }

I get just name and id , if you want get different things,

like image 118
Ersin Gülbahar Avatar answered Dec 31 '25 07:12

Ersin Gülbahar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!