I am using the new Facebook-sdk and using the hackbook example to get the list of friends using FriendsList.java file. The Friendlist Activit
Following code work better for me. This code provide friend list.
public JSONObject getFrienList(String token)
{
InputStream is = null;
String result = "";
JSONObject jArray = null;
try
{
HttpClient httpclient = new DefaultHttpClient();
HttpGet httppost = new HttpGet("https://graph.facebook.com/me/friends? access_token=" + token);
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}
catch(Exception e)
{
Log.e("ERROR", "Error in http connection "+e.toString());
}
//convert response to string
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is),8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
is.close();
result=sb.toString();
Log.i("RESULT",result);
}
catch(Exception e)
{
Log.e("ERROR", "Error converting result "+e.toString());
}
//try parse the string to a JSON object
try
{
jArray = new JSONObject(result);
Log.i("RESULT","JSON ARRAY"+jArray.toString());
}
catch(JSONException e)
{
Log.e("ERROR", "Error parsing data "+e.toString());
}
return jArray;
}