In my app I need to download files from url locations. I want to display progress of the download in a dialogbox (or optionally in the notification area). I\'ve come across
Have your button call AsyncTask.cancel(true) and then check isCancelled() from inside doInBackground(Params... params). In this manner, you can communicate to the background thread that the download should be cancelled, and you can take the appropriate steps to stop it.