我刚开始使用Volley的库来进行http调用,我尝试将RequestFuture类用于同步请求,但是我尝试做出一个简单的请求失败了。我知道我做错了什么?
FileSystemWatcher
答案 0 :(得分:-2)
要发出一个简单的请求,只需使用StringRequest类。下面是一个小片段:
// Instantiate the RequestQueue.
RequestQueue queue = Volley.newRequestQueue(this);
StringRequest req = new StringRequest(Request.Method.POST, "your_url", new Response.Listener<String>() {
@Override
public void onResponse(String response) {
//handle response here.
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
//handle error here.
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
//return params(if any) to server here.
return super.getParams();
}
};
queue.add(req);