以下代码用于从Facebook获取好友列表,我在另一个类中有会话但是会话数据正确地在这个类中出现。但在请求从Facebook获取好友列表之后。我得到graphObject {data:[]就像这样......之后得到JArry Null ..
//Class For Getting FacebookUserdata
private void getFacebookUserData() {
Log.d(Utilities.logg, "getFacebookUserData");
//Getting Session information
Log.d(Utilities.logg, "session=" + session);
Request requests;
//Making request for getting Friend list
requests = new Request(session, "me/friends", null, HttpMethod.GET,
new Request.Callback() {
//On Complete Request
public void onCompleted(Response response) {
// threadForUI();
GraphObject graphObject = response.getGraphObject();
FacebookUserDataClass userData = null;
try {
JSONObject json = graphObject.getInnerJSONObject();
//Exit from Dailog
if (json != null) {
if (mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
mrootInnerInviteFriendsInitiateWars
.setVisibility(RelativeLayout.VISIBLE);
mrootInnerInitiateWars
.setVisibility(RelativeLayout.INVISIBLE);
}
}
//Array for getting data
JSONArray JArray = json.getJSONArray("data");
for (int i = 0; i < JArray.length(); i++) {
if (i == 10) {
mtvFriendLoadingInviteFriend
.setVisibility(TextView.GONE);
setListAdapte(mChoose);
}
//Set Json Object for getting all friends
JSONObject innerObject1 = JArray.getJSONObject(i);
//.get(i);
//Geting Pojo Class
userData = new FacebookUserDataClass();
userData.setUserId((String) innerObject1
.getString("id"));
userData.setUserName((String) innerObject1
.getString("name"));
mFacebookUserDataListFull.add(userData);
}
placeFcaebookList();
mtvFriendLoadingInviteFriend
.setVisibility(TextView.GONE);
// if(Utilities.getSharedPref(Utilities.API_regId,
// "").isEmpty())
// {
// getSelfFacebookProfile();
// }
//Storing data into local database
Utilities.database
.insertIntoFacebookFriendListTable(mFacebookUserDataListFull);
mckbCheckAll.setChecked(true);
checkUncheckAll(mChoose, true);
mbtnRefreshInviteFriend.setEnabled(true);
Utilities.foolFlag = false;
Utilities.saveFriendListOnServer(
mFacebookUserDataListFull,
Utilities.FACEBOOK);
} catch (JSONException e) {
// TODO Auto-generated catch block
Log.e(logg,
"getUserData EXCEPTION1 " + e.toString());
e.printStackTrace();
} catch (NullPointerException e) {
// TODO Auto-generated catch block
Log.e(logg,
"getUserData EXCEPTION2 " + e.toString());
e.printStackTrace();
if (mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
Utilities.errorFlag = true;
// onClickFacebookButton();
}
}
});
pendingRequest = false;
requests.executeAsync();
// Utilities.database
// .insertIntoFacebookFriendListTable(mFacebookUserDataListFull);
// Utilities.foolFlag = false;
// Utilities.saveFriendListOnServer(mFacebookUserDataListFull,
// Utilities.FACEBOOK);
// Log.d(logg, "frnds loding done");
// getFacebookImages();
//Getting Image from the Image Class
new GetFacebookImagesUrl().execute();
}