使用自定义 Volley POST 不会 return 任何东西

Using custom Volley POST doesn't return anything

我正在尝试使用扩展 JsonRequest class 的自定义 Class 来使用 POST 和一个参数发送 JSONArrayRequest。

public class MethodJsonArrayRequest extends JsonRequest<JSONArray> {
    public MethodJsonArrayRequest(int method, String url, JSONObject params, com.android.volley.Response.Listener<org.json.JSONArray> listener, ErrorListener errorListener) {
        super(method, url, params.toString(), listener, errorListener);
        Log.d("method", Integer.toString(method));
        Log.d("jsonRequest", params.toString());
    }

    @Override
    protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
        try {
            String jsonString = new String(response.data,
                    HttpHeaderParser.parseCharset(response.headers));
            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));
        }
    }
}

我的日志return这个:

D/method﹕ 1
D/jsonRequest﹕ {"idShow":"219"}

我正在使用此代码段将此信息传递给我的自定义 class:

...
        JSONObject params = new JSONObject();
        try {
            params.put("idShow", idShow);
        }
        catch (JSONException e) {Log.d("JSON e", e.getMessage()); }

        MethodJsonArrayRequest episodeRequest = new MethodJsonArrayRequest(Request.Method.POST, episodeURL, params, new Response.Listener<JSONArray>() {
        @Override
        public void onResponse(JSONArray myResponse) {
            try {
                Log.d("myResponse", myResponse.toString());
...

我的响应日志:

D/myResponse﹕ []

但无论出于何种原因,它没有 return 任何东西,我觉得我可能没有为 paramas 传递正确的东西,但我不确定,非常感谢任何帮助!让我知道是否有我未包含在此处的内容可能有帮助。

user98239820 回答 here 非常有用。他没有扩展 JsonRequest<JSONArray> class,而是扩展了 Request class。我还必须将他的 new JSONObject 更改为 new JSONArray 以满足我的需要,但通过指向 class 可以完美地工作。