我的JSONArrayRequest似乎没有从网址获得任何响应 这是URL =“http://susuonlinesegar.esy.es/track_pesanan.php?ID=P77997”
private void getCoordinate(){
URL_KOORDINAT += "?ID=" + idPesanan;
Log.e("URL", URL_KOORDINAT);
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(URL_KOORDINAT,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.e("Response",response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
jsonArrayRequest.setRetryPolicy(new DefaultRetryPolicy(0,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
AppController.getInstance().addToRequestQueue(jsonArrayRequest);
}
答案 0 :(得分:-2)
您可以按照以下代码获得回复
StringRequest sr = new StringRequest(Request.Method.POST,
"Your url here",
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Here from response u can get what u need
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
pDialog.hide();
VolleyLog.e("TAG", "Error: " + error.getMessage());
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("", "");
here in params send what parameters need to be send to get response if needed
return params;
}
};
AppController.getInstance().addToRequestQueue(sr);