【发布时间】:2016-05-15 11:57:46
【问题描述】:
我正在使用 volley singleton 并将所有 volley 请求添加到它。
将凌空请求添加到队列的示例代码
MyApplication.getInstance().addToReqQueue(jsObjRequest, "jreq1");
我有一个 onclick 功能。
buttonId.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for(int i=0;i<4;i++){
//....... here i call for asycn volley requests which get added to the queue of volleysingleton
}
// ******how to ensure all my volley requests are completed before i move to next step here.*****
//calling for new intent
Intent m = new Intent(PlaceActivity.this, Myplanshow.class);
m.putExtra("table_name", myplansLists.get(myplansLists.size() - 1).table_name);
m.putExtra("table_name_without_plan_number", myplansLists.get(myplansLists.size() - 1).place_url_name);
m.putExtra("changed", "no");
m.putExtra("plannumber", myplansLists.size());
//moving to new intent;
v.getContext().startActivity(m);
}
});
在 onclick 内部我有一个 for 循环,它将执行多个 volley 请求。
在for循环之后,它将通过intent开始一个新的活动。
但是为了显示我的新活动,我需要之前完成 for 循环中所有凌空请求的数据,它会离开此活动并进入新活动。
【问题讨论】:
标签: android-volley