0

ボレーJsonArrayRequestを使用してパラメータでGETリクエストを行いたいです。パラメータを指定して getParam() メソッドを呼び出しましたが、呼び出していません。

JsonArrayRequest jreq = new JsonArrayRequest(Request.Method.GET,"http://api.openchargemap.io/v2/poi/",null,
            new Response.Listener<JSONArray>() {

                @Override
                public void onResponse(JSONArray response) {

                    Log.d("TAG", "" + response.toString());
                    if(response.toString().length() > 1) {
                        parseJson(response.toString());
                    }
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.d("TAG",""+error.toString());
        }
    })

    {
        @Override
        protected Map<String, String> getParams() {
            Map<String,String> map = new HashMap<String,String>();
            map.put("output","json");
            map.put("countrycode","US");
            map.put("latitude","32.57933044");
            map.put("longitude","-110.8514633");
            map.put("maxresults","100");
            map.put("distance","10");
            map.put("distanceunit","KM");
            map.put("compact","true");
            map.put("verbose","false");
            return map;
        }
    };

    RequestQueue requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(jreq);

ボレーが getParam() を呼び出していないため、適切な応答が得られません。私はスタックオーバーフローについて多くのことを検索しましたが、正しい答えが得られず、ボレーのドキュメントは良くありません。それが私がここに私の質問を置いている理由です。ありがとう。

4

1 に答える 1