在执行executeMyFriendsRequestAsync时遇到问题

时间:2013-04-13 18:33:59

标签: android facebook

出于某种原因,即使我几乎完全从样本中复制了这段代码,我似乎也看不到任何朋友的信息。我只和几个朋友使用假帐户。有人能告诉我可能出现的问题吗?

Session.openActiveSession(this, true, new Session.StatusCallback() {
     @Override
     public void call(Session session, SessionState state, Exception exception) {
         if (session.isOpened()) {
         Request.executeMyFriendsRequestAsync(session, new Request.GraphUserListCallback() {
        @Override
    public void onCompleted(List<GraphUser> users, Response response) {
         Log.d("INFO", "on complete");
         Log.i("INFO", "" + users.toString());

1 个答案:

答案 0 :(得分:1)

final Runnable getFacebookUserInfo = new Runnable() {
    @Override
    public void run() {
        Request.executeMeRequestAsync(facebookConnector.getFacebook()
                .getSession(), new Request.GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user, Response response)
            {
                //...   
            }
        });

        Request.executeMyFriendsRequestAsync(facebookConnector.getFacebook()
                .getSession(), new Request.GraphUserListCallback() {
            @Override
            public void onCompleted(List<GraphUser> users, Response response) {
                if (users != null) {
                    List<String> friendsList = new ArrayList<String>();
                    for (GraphUser user : users) {
                        friendsList.add(user.getId());
                        //...
                    }
                }
            }
        });
}

};

我觉得它很有用。