For those coming to this question from search & google.
There is no reason to wait for an async request to finish, as it is asynchronous by design. If you want to achieve synchronous behaviour using Volley, you have to use so-called futures:
String url = "http://www.google.com/humans.txt";
RequestFuture<String> future = RequestFuture.newFuture();
StringRequest request = new StringRequest(Request.Method.GET, url, future, future)
mRequestQueue.add(request);
String result = future.get(); // this line will block
Keep in mind that you have to run blocking code in another thread, so wrap it into AsyncTask
(otherwise future.get()
will block forever).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…