如何使用 Volley 将 HttpPost( URI ) 与 StringRequest 传递?我需要通过 Request 传递 URI,比如 ,
HttpPost localHttpPost = new HttpPost(" some URI ");
如何使用 Volley 请求?
最佳答案
嗯,首先你需要一个requestQueue。
requestQueue = Volley.newRequestQueue(context);
然后,在代码的某个位置(一个全局变量)定义了这个 requestQueue,工作就是定义一个 Request。例如,它可以是一个 StringRequest。注意代码中的 Method.POST。
StringRequest req = new StringRequest(Method.POST, getBaseUrl() + POST_OPPORTUNITIES_URL, requestListener, new Response.ErrorListener(){
@Override
public void onErrorResponse(VolleyError volleyError) {
//Manage the error
}
});
最后将请求加入de Queue
requestQueue.add(req);
关于android - 如何通过 Volley Request 传递 HttpPost( URI )?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27499765/