本文介绍了发送JSONArray POST请求与Android凌空库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我会发送和recive JSON数组与截击。现在我可以recive阵列和它的确定。但我不知道如何发送一个请求(例如:用post方法);
JsonArrayRequest arrayReq =新JsonArrayRequest(URL,
新的监听器和LT; JSONArray>(){
}
解决方案
Android的凌空队,之后可能会添加。但现在,你可以这样做: 创造你的类并扩展 JsonArrayRequest
那么你应该在此改变:
@覆盖
保护地图<字符串,字符串> getParams()方法抛出AuthFailureError {
HashMap的<字符串,字符串> PARAMS =新的HashMap<字符串,字符串>();
params.put(名,价值);
返回PARAMS;
}
然后作出新的构造:
公共PostJsonArrayRequest(字符串URL,Response.Listener< JSONArray>听者,Response.ErrorListener errorListener){
超(Method.POST,网址,空,监听器,errorListener);
}
I would to send and recive json Array with volley.Now I can recive the array and it's ok.but I don't know how to send an request (For example : with post method ) ;
JsonArrayRequest arrayReq = new JsonArrayRequest(URL,
new Listener<JSONArray>() {
}
解决方案
the android volley team maybe add it later . but for now you can do this : creat your class and extends JsonArrayRequest
then you should overide :
@Override
protected Map<String, String> getParams() throws AuthFailureError {
HashMap<String, String> params = new HashMap<String, String>();
params.put("name", "value");
return params;
}
then make new constructor :
public PostJsonArrayRequest(String url, Response.Listener<JSONArray> listener, Response.ErrorListener errorListener) {
super(Method.POST, url, null, listener, errorListener);
}
这篇关于发送JSONArray POST请求与Android凌空库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!