如何在单个URL中使用此响应?

时间:2017-12-06 16:33:37

标签: android android-volley

HttpResponse<String> response = Unirest.get("https://aadhaarnews-fuel-price-api-india-v1.p.mashape.com/GetPetrolDieselPriceWithState?state=hp")
.header("X-Mashape-Key", "my key")
.header("Accept", "text/plain")
.as String();

1 个答案:

答案 0 :(得分:0)

考虑到它正在返回JSONArray,

JsonArrayRequest req = new JsonArrayRequest(url,
                new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {
                        Log.d(TAG, response.toString());        
                        pDialog.hide();             
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        VolleyLog.d(TAG, "Error: " + error.getMessage());
                        pDialog.hide();
                    }
                }){

    @Override
    public Map<String, String> getHeaders() throws AuthFailureError {
        Map<String, String>  params = new HashMap<String, String>();
        params.put("X-Mashape-Key", "my key");

        return params;
    };

// Adding request to request queue
AppController.getInstance().addToRequestQueue(req, tag_json_arry);