带有参数的jsonarray请求


jsonarray request with parameters

我有一个php Web服务,它使用json_encode(array("moviemakers"=>$rows)).返回一个json数组。我需要从android发出带有参数的json数组请求。

我看到这个:

public JsonArrayRequest(int method, String url, JSONObject jsonRequest,
        Listener<JSONArray> listener, ErrorListener errorListener) {
        super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), 
        listener, errorListener);
}

当我在代码中使用它时,它会生成一个错误
有人能指导我把上面的代码段放在哪里吗?

这里是JsonObjectRequest的一个例子:

 private void volleyRequest(String url){
        final JsonObjectRequest request = new JsonObjectRequest(url, null, new Response.Listener<JSONObject>(){
            @Override
            public void onResponse(JSONObject response) {
                try {
                    Log.i(LOG_FLAG, response.toString(4));
                    //parseJSON
                }catch (JSONException e){
                    //handle exception
                }
            }
        },new Response.ErrorListener(){
            @Override
            public void onErrorResponse(VolleyError volleyError) {
                //handle error
            }
        });
        //adding request into the queue
        ApplicationClass.getInstance().addToRequestQueue(request,"someTag");
    }

在这里,你可以找到一个关于截击的非常好的教程:Android中使用Volley 的异步HTTP请求