gpt4 book ai didi

android - RequestBatch.Callback onBatchCompleted() 未调用

转载 作者:太空狗 更新时间:2023-10-29 12:47:33 25 4
gpt4 key购买 nike

在发送一批请求时,使用适用于 Android 的 facebook 图形 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 回调将在调用所有 per-Request 回调后调用..

        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);

}

关于android - RequestBatch.Callback onBatchCompleted() 未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16354590/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com