Android 未调用RequestBatch.Callback onBatchCompleted()
在发送一批请求时,在使用android的facebook graph API库时遇到问题 运行此代码时未获得回调:Android 未调用RequestBatch.Callback onBatchCompleted(),android,facebook,facebook-graph-api,Android,Facebook,Facebook Graph Api,在发送一批请求时,在使用android的facebook graph API库时遇到问题 运行此代码时未获得回调: RequestBatch requestBatch = new RequestBatch(requests); requestBatch.addCallback(new com.facebook.RequestBatch.Callback() { @Override public void onBatc
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);
}
meh,必须等待2天:(您如何从RequestBatch获得响应?