Is there Any way To hold Volley request until the response Completed
Asked Answered
T

2

5

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.

Tape answered 12/3, 2014 at 17:57 Comment(3)
I think the whole point of volley is being asynchronous, seems like what you are looking for is a regular request call...Nylanylghau
I'm trying to take advantage of volley features, and go away from asynckTask problemTape
makes sence, you should try forcing the thread to wait, a good understanding of Thread mechanism would help you get away with it...Nylanylghau
E
8

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

Etoile answered 12/3, 2014 at 19:34 Comment(0)
C
0

This is possible after setting a callback functionality as answered here

Canova answered 20/1, 2016 at 7:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.