I just want to check if I understood well the way asynchronous Http request work on Android.
Suppose I make such a request and set a ResponseHandler<String> responseHandler to handle the response. By doing this is it possible to have the UI thread blocked waiting for the response ? The implication being that the code in the function:
public String handleResponse(HttpResponse response)
is also executed on the UI thread or is there silently spawned a thread that waits for the response and calls the handleResponse(HttpResponse response) function when the response arrives ?
Calling
execute()with or without aResponseHandlerwill block that thread until the HTTP request has been processed. If you callexecute()on the main application thread, you will block the UI. This is not a good thing — useAsyncTasktoexecute()on a separate thread, then use youronPostExecute()implementation to update your UI with the results of the request.