Just copy and paste your HttpPost
code into the AsyncTask
's doInBackground
method. You can notify the UI for progress updates using onProgressUpdate
, and you can notify the UI when the task is completed in onPostExecute
.
See this post for more information on how to implement the request (the code in the post performs an HttpGet
request, so translating the code to use a HttpPost
request instead should be simple).
And by the way, you should still use an AsyncTask
to perform these kinds of requests on pre-HoneyComb devices. A lot of tutorials online do this incorrectly... just remember that you should always perform lengthy operations on a separate Thread
, and network connections should always be considered to be potentially long-running operations (since you never know how long they will take).