Reputation: 19572
I was looking into Volley. It seems that the onResponse
is called on the UI thread.
So I have the following case:
1) I need to do a network call to get a list of addresses where my data to show in the UI reside.
2) Then I need to go over this list of addresses and do network calls to actually show the data in the UI.
It seems that for (1) I can not use Volley unless I start spawning background threads when I get the onResponse
. Is it possible to do this efficiently without mixing threads and http clients?
Upvotes: 1
Views: 99
Reputation: 16761
When using Volley, it's allowed to submit new requests on the UI thread, since when you do this, the request isn't actually performed at that moment. The request is appended in a queue and executed at a later stage by Volley, considering other requests which are still pending (if any).
Example:
mVolleyRequestQueue.add(myRequest); // request is added to the queue, but not performed instantly. The execution is deferred to a background thread.
Hope this helps.
Upvotes: 1