Android volley gets callback when all requests end

I use a volley to queue for a series of requests. I show the progress dialog to the user when these requests occur. Is there a way to check when all these requests are complete. This is what I want.

//Show progress bar for(int i=0;i<size;i++) { //create request and add the request requestQueue.add(request); } // When last request finsihes dismiss progres bar 

Is there a solution to this problem.

+3
source share
1 answer

You can save the total number of queries in a member variable:

 int pendingRequests = 0; //... for(int i=0;i<size;i++) { requestQueue.add(request); pendingRequests++; } 

Then, each time the request ends, you decrease the counter, and if it reaches 0, you know that all the requests are complete.

+7
source

Source: https://habr.com/ru/post/971496/


All Articles