Question

As past when use AsyncTask we have two method doInBackground() to do all work and onPostExecute() to make change when all data back completed, so I can stop all code until the right data come back, then do what I need with this data.

But when I try to move to Volley library, when call request I just have the onResponse() method, but there is problem that I need to do some code depend on back data but there is no way to hold code at this point.

So is there Any way To hold Volley request until the response Completed ?

*I know we can override the onResponse() to do what we need when the full data come back,but this well be a lot of Nested coding and method.

Thanks for all who can help.

Was it helpful?

Solution

If you are looking to synchronously perform a request you could use a RequestFuture to wait until the response has been returned. This should not be done on the main thread, as it will cause your UI to lock up.

This has been answered as well here: https://stackoverflow.com/a/18541806

OTHER TIPS

This is possible after setting a callback functionality as answered here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top