Java 截击请求跟踪
我正在使用volley库使用Restful API上传图像 我提出了多个图像上传请求,并将所有这些添加到请求队列中。 当请求完成时,我希望根据请求执行本地db操作,但 现在的问题是如何跟踪每个请求的进度 我如何知道哪个请求已完成 如何标记请求? 有办法吗 代码:Java 截击请求跟踪,java,android,android-volley,Java,Android,Android Volley,我正在使用volley库使用Restful API上传图像 我提出了多个图像上传请求,并将所有这些添加到请求队列中。 当请求完成时,我希望根据请求执行本地db操作,但 现在的问题是如何跟踪每个请求的进度 我如何知道哪个请求已完成 如何标记请求? 有办法吗 代码: StringRequest stringRequest = new StringRequest (Request.Method.POST, Constants.IMAGE_UPLOAD_URL, new
StringRequest stringRequest = new StringRequest (Request.Method.POST, Constants.IMAGE_UPLOAD_URL,
new Response.Listener<String> ( ) {
@Override
public void onResponse(String s) {
Log.e (TAG, s.toString ( ));
}
},
new Response.ErrorListener ( ) {
@Override
public void onErrorResponse(VolleyError volleyError) {
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
//Creating parameters
Map<String, String> params = new Hashtable<String, String> ( );
//Adding parameters
params.put ("file_contents", imageString);// image string
params.put ("file_name", filenameString);//profile image in name
return params;
}
};
stringRequest.setRetryPolicy (new DefaultRetryPolicy (DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
//Adding request to the queue
if (requestQueue==null)
requestQueue= Volley.newRequestQueue (this);
requestQueue.add (stringRequest);
}
StringRequest StringRequest=新的StringRequest(Request.Method.POST,Constants.IMAGE\u UPLOAD\u URL,
新的Response.Listener(){
@凌驾
公共void onResponse(字符串s){
Log.e(TAG,s.toString());
}
},
新建Response.ErrorListener(){
@凌驾
公共错误响应(截击错误截击错误){
}
}) {
@凌驾
受保护的映射getParams()引发AuthFailureError{
//创建参数
Map params=newhashtable();
//添加参数
params.put(“文件内容”,imageString);//图像字符串
params.put(“file_name”,filenameString);//名称中的配置文件图像
返回参数;
}
};
stringRequest.setRetryPolicy(新的DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS*2,DefaultRetryPolicy.DEFAULT_MAX_RETRIES,DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
//将请求添加到队列
if(requestQueue==null)
requestQueue=Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
RequestFilter
,根据响应的返回值查找下一项我没有执行任何长操作,只是执行多个小操作,请求过滤?上传图像被视为长操作