Is there a way to stop the execution of HttpClient in AsyncTask?

I have an AsyncTask that handles a fairly long download using HttpClient. I would like to stop executing this request if the user completes an action that launches it. How can I achieve this?

So, I started AsyncTask, the HttpClient is in execute (), processing the GET request, is there any way to abort this?

+5
source share
2 answers

The Async task has a canceled call, which you can cancel. You can get from your HttpClient and close the stream.

+4
source
  • Call AsyncTask#cancelto cancel a pending task.
  • HttpClient, HttpUriRequest#abort() http

1,4.

HTTP - , . , -. HTTP-, HttpClient, , HttpUriRequest # abort(). . HTTP- , , -, , InterruptedIOException

+5

All Articles