rafavinu rafavinu - 1 year ago 151
JSON Question

Android Volley | Extract json from multiple urls

I am currently using Volley to extract json contents using the following code.

JsonArrayRequest servicesStatus = new JsonArrayRequest(url1,
new Response.Listener<JSONArray>() {
public void onResponse(JSONArray response) {
Log.d(TAG, response.toString());

// Parsing json
for (int i = 0; i < response.length(); i++) {
try {

JSONObject obj = response.getJSONObject(i);
// Having obj to process further
} catch (JSONException e) {
// notifying list adapter about data changes
// so that it renders the list view with updated data
}, new Response.ErrorListener() {
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());


Now, I want one more json handler for the new url and the dialog to be closed once it has successfully downloaded from both the urls.

I tried to copy paste the above thing with url1 replaced by url2 and different jsonarrayrequest name. And added the hideDialog() in the second one. But the second one is not being called at all.

Can anyone please guide how to accomplish this.


If you want make mutiple request then you will have to add your Request to Queue. You can do it like this:

   RequestQueue request =  Volley.newRequestQueue(Context);

This should help you to add multiple request in Volley. I hope this was helpful. ThankYou