怎么判断volley多次请求完成
1个回答
展开全部
int frequency;
String errorStr;
for (int i = 0; i < 5; i++) {
StringRequest request = new StringRequest(url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
postMessage();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
postMessage();
errorStr = errorStr + erreor.getMessage();
}
});
VolleyController.addToRequestQueue(request, mContext.getApplicationContext());
}
private void postMessage(){
frequency++;
if(frequency == 5){
发送一条广播,弹出errorStr错误,如果errorStr不为空则全部执行成功
}
String errorStr;
for (int i = 0; i < 5; i++) {
StringRequest request = new StringRequest(url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
postMessage();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
postMessage();
errorStr = errorStr + erreor.getMessage();
}
});
VolleyController.addToRequestQueue(request, mContext.getApplicationContext());
}
private void postMessage(){
frequency++;
if(frequency == 5){
发送一条广播,弹出errorStr错误,如果errorStr不为空则全部执行成功
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询