1

我正在尝试在我的自定义布局中获取所有 facebook 朋友。我已经更新了所有的库和 jar 文件以及新的 FB sdk 版本.. 我仍然面临这个错误.. 有人可以帮忙解决这个问题.. 你会非常好心.. 我在这里只放置取朋友模块

private void showFriendList() {
    if (Session.getActiveSession() != null) {
        Session.openActiveSession(InviteFriendsActivity.this, true,
                new StatusCallback() {

                    @Override
                    public void call(Session session, SessionState state,
                            Exception exception) { // TODO Auto-generated
                                                    // method stub

                        List<String> permissions = session.getPermissions();
                        permissions.add("user_friends");

                        Session.NewPermissionsRequest request = new Session.NewPermissionsRequest(
                                getParent(), Arrays.asList("user_friends"));

                        session.requestNewReadPermissions(request);

                        Log.v("Invite Friends Request",
                                ">>>>>>>>>>>>>>>Request send"
                                        + permissions.toString());
                        Log.v("Request's Session state", ">>>>>>>>>>>>>>"
                                + session.isOpened());
                        Request friendsRequest = createRequest(session);

                        friendsRequest.setCallback(new Request.Callback() {

                            @Override
                            public void onCompleted(Response response) {
                                List<GraphUser> friends = getResults(response);
                                if (friends != null) {

                                    inviteBtn.setVisibility(View.VISIBLE);
                                    Log.v("fbbbbbb",
                                            "---------------------\n SIZE ="
                                                    + friends.size());
                                    for (int i = 0; i < friends.size(); i++) {

                                        JSONObject data = null;
                                        String imgUrl = null;
                                        try {
                                            data = friends
                                                    .get(i)
                                                    .getInnerJSONObject()
                                                    .getJSONObject(
                                                            "picture");

                                            Log.v("jsondata", "data ="
                                                    + data);

                                            JSONObject arrayFriend = data
                                                    .getJSONObject("data");
                                            Log.v("imgUrl", "imgUrl ="
                                                    + imgUrl);
                                            imgUrl = arrayFriend
                                                    .optString("url");
                                            Log.v("imgUrl", "imgUrl ="
                                                    + imgUrl);

                                        } catch (JSONException e) {
                                            e.printStackTrace();
                                        }

                                        final FriendDataBean fbList = new FriendDataBean();
                                        fbList.setId(friends.get(i).getId());
                                        fbList.setName(friends.get(i)
                                                .getName());
                                        fbList.setProfilePic(imgUrl);

                                        Log.v("For", "i =" + i);
                                        Log.v("User", "user " + i + ": "
                                                + friends.get(i).getName()
                                                + "\npath=" + data
                                                + "\nimgUrl:" + imgUrl);
                                        fbFriends.add(fbList);
                                    }
                                    progressDialog.cancel();
                                    adapter = new FbFriendListAdapter(
                                            InviteFriendsActivity.this,
                                            R.layout.invite_friends_list_item,
                                            fbFriends);
                                    listview.setAdapter(adapter);
                                }
                            }
                        });
                        friendsRequest.executeAsync();

                    }
                });
    } else {
        progressDialog.cancel();
        Log.v("TTTTTT", "no session");
        getFacebookData();
    }}

这是logcat..

12-02 01:28:01.044: E/AndroidRuntime(2838): FATAL EXCEPTION: main
12-02 01:28:01.044: E/AndroidRuntime(2838): Process: com.clubewinepro.youpin, PID: 2838
12-02 01:28:01.044: E/AndroidRuntime(2838): java.lang.UnsupportedOperationException
12-02 01:28:01.044: E/AndroidRuntime(2838):     at java.util.Collections$UnmodifiableCollection.add(Collections.java:928)
12-02 01:28:01.044: E/AndroidRuntime(2838):     at com.clubewinepro.youpin.InviteFriendsActivity$1.call(InviteFriendsActivity.java:147)
12-02 01:28:01.044: E/AndroidRuntime(2838):     at com.facebook.Session$4$1.run(Session.java:1545)
12-02 01:28:01.044: E/AndroidRuntime(2838):     at android.os.Handler.handleCallback(Handler.java:733)
12-02 01:28:01.044: E/AndroidRuntime(2838):     at android.os.Handler.dispatchMessage(Handler.java:95)
12-02 01:28:01.044: E/AndroidRuntime(2838):     at android.os.Looper.loop(Looper.java:136)
12-02 01:28:01.044: E/AndroidRuntime(2838):     at android.app.ActivityThread.main(ActivityThread.java:5017)
12-02 01:28:01.044: E/AndroidRuntime(2838):     at java.lang.reflect.Method.invokeNative(Native Method)
12-02 01:28:01.044: E/AndroidRuntime(2838):     at java.lang.reflect.Method.invoke(Method.java:515)
12-02 01:28:01.044: E/AndroidRuntime(2838):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
12-02 01:28:01.044: E/AndroidRuntime(2838):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
12-02 01:28:01.044: E/AndroidRuntime(2838):     at dalvik.system.NativeStart.main(Native Method)
4

0 回答 0