在发送一批请求时,无法为Android使用Facebook Graph API库。
运行此代码时未获取回调:

        RequestBatch requestBatch = new RequestBatch(requests);
        requestBatch.addCallback(new com.facebook.RequestBatch.Callback() {
            @Override
            public void onBatchCompleted(RequestBatch batch) {
                Log.e(LOG_TAG, "onBatchCompleted()");
            }
        });
        requestBatch.executeAsync();

最佳答案

找到了答案。
您需要为每个单独的请求设置回调以获取与批处理相关的回调,因为在调用所有每个请求回调之后将调用onBatchCompleted回调。

        for (String friend : friends) {
            MyLog.d(LOG_TAG, "Adding request for " + friend.getInterestFbId());
            String graphPath = friend + "/feed";
            Request request = new Request(session, graphPath, null, HttpMethod.GET);
            Bundle params = new Bundle();
            params.putString("fields",
                             "id,"+
                             "name,"+
                             "username,"+
                             "feed,");
            request.setParameters(params);


            // THIS IS VITAL OR THE BATCH CALLBACK WILL NEVER ARRIVE
            request.setCallback(new com.facebook.Request.Callback() {
                @Override
                public void onCompleted(Response response) {}
            });


            requests.add(request);

        }

10-07 20:01