android - 如何通过 Volley Request 传递 HttpPost( URI )?

标签 android android-volley

如何使用 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/

相关文章:

java - 关于将文件保存到android中的外部存储

java - 为什么动态加载 dex jar 时会出现 java.lang.NoSuchMethodError 错误?

android - 补丁请求 Android Volley

android - 使用 Android Volley 发出 HTTPS 请求

android - com.android.volley.AuthFailureError 向 django 服务器发出基本的 volley POST 请求

android - 以编程方式向表中添加列

android - AutoCompleteTextView 不识别空格

android - ListView 下面的 TextView 不显示。为什么?

java - Jetty - 9 BAD REQUEST ERROR with Volley 服务器

android - 如何使用 android volley 库将位图图像上传到服务器?