Since Volley is asynchronous, therefore IMO, you should not put requests inside the for-loop, like code in your question. Please refer to the following code sample and then apply its logic to your application. Hope this helps!
public class MainActivity extends AppCompatActivity { private int num = 0; private JsonArrayRequest jsonArrayRequest; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final RequestQueue requestQueue = Volley.newRequestQueue(this); String url = "http://..."; jsonArrayRequest = new JsonArrayRequest(url, new Response.Listener<JSONArray>() { @Override public void onResponse(JSONArray response) { Log.i("Num", String.valueOf(num)); Log.i("Response", response.toString()); if (num < 8) { num++; requestQueue.add(jsonArrayRequest); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("Error", error.toString()); } }); num++; requestQueue.add(jsonArrayRequest); } }
Logcat output as below:
03-28 13:14:29.885 13262-13262/com.example.googlevolley I/Num: 1 03-28 13:14:29.885 13262-13262/com.example.googlevolley I/Response: [{"id":"1","name":"Information Technology"},{"id":"2","name":"Human Resources"},{"id":"3","name":"Marketing and PR"},{"id":"4","name":"Research and Developement"}] 03-28 13:14:29.935 13262-13262/com.example.googlevolley I/Num: 2 03-28 13:14:29.955 13262-13262/com.example.googlevolley I/Response: [{"id":"1","name":"Information Technology"},{"id":"2","name":"Human Resources"},{"id":"3","name":"Marketing and PR"},{"id":"4","name":"Research and Developement"}] 03-28 13:14:30.085 13262-13262/com.example.googlevolley I/Num: 3 03-28 13:14:30.085 13262-13262/com.example.googlevolley I/Response: [{"id":"1","name":"Information Technology"},{"id":"2","name":"Human Resources"},{"id":"3","name":"Marketing and PR"},{"id":"4","name":"Research and Developement"}] 03-28 13:14:30.245 13262-13262/com.example.googlevolley I/Num: 4 03-28 13:14:30.245 13262-13262/com.example.googlevolley I/Response: [{"id":"1","name":"Information Technology"},{"id":"2","name":"Human Resources"},{"id":"3","name":"Marketing and PR"},{"id":"4","name":"Research and Developement"}] 03-28 13:14:30.266 13262-13262/com.example.googlevolley I/Num: 5 03-28 13:14:30.266 13262-13262/com.example.googlevolley I/Response: [{"id":"1","name":"Information Technology"},{"id":"2","name":"Human Resources"},{"id":"3","name":"Marketing and PR"},{"id":"4","name":"Research and Developement"}] 03-28 13:14:30.296 13262-13262/com.example.googlevolley I/Num: 6 03-28 13:14:30.296 13262-13262/com.example.googlevolley I/Response: [{"id":"1","name":"Information Technology"},{"id":"2","name":"Human Resources"},{"id":"3","name":"Marketing and PR"},{"id":"4","name":"Research and Developement"}] 03-28 13:14:30.306 13262-13262/com.example.googlevolley I/Num: 7 03-28 13:14:30.306 13262-13262/com.example.googlevolley I/Response: [{"id":"1","name":"Information Technology"},{"id":"2","name":"Human Resources"},{"id":"3","name":"Marketing and PR"},{"id":"4","name":"Research and Developement"}] 03-28 13:14:30.316 13262-13262/com.example.googlevolley I/Num: 8 03-28 13:14:30.316 13262-13262/com.example.googlevolley I/Response: [{"id":"1","name":"Information Technology"},{"id":"2","name":"Human Resources"},{"id":"3","name":"Marketing and PR"},{"id":"4","name":"Research and Developement"}]