我创建了一个自定义齐射请求,该请求接受JSONObject作为参数。
CustomJsonArrayRequest.java
public class CustomJsonArrayRequest extends JsonRequest<JSONArray> { public CustomJsonArrayRequest(int method, String url, JSonObject jsonRequest, Listener<JSONArray> listener, ErrorListener errorListener) { super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener, errorListener); } @Override protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) { try { String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET)); return Response.success(new JSonArray(jsonString), HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (JSonException je) { return Response.error(new ParseError(je)); } } }如何使用?
JSonObject body = new JSonObject();// Your pre, e.g. body.put(key, value);CustomJsonArrayRequest req = new CustomJsonArrayRequest(Request.Method.POST, url, body, success, error);



