我是Android工作室的新手,我正试图通过他们的个人资料图片获取我的facebook朋友列表,我的所有结果都只是他们的名字,你能帮助我得到它吗?谢谢你的回复:)
获取列表的代码:
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);
}
我的JSON结构:
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();
}