When you queue something with the DownloadManager, the enqueue call returns immediately (thus it appears that your task has completed).
There are two potential fixes:
- The preferred way to use DownloadManager is to implement a broadcast receiver to receive a broadcast when the download completes. As Merlevede points out, then you don't even use an AsyncTask.
- If you really need to keep your async task or don't want to implement the broadcast receiver, you could loop in your doInBackground and query the download manager to check status, hopefully sleeping some time between checks. Given the necessity of polling and sleeping this really shouldn't be a preferred option (and, theoretically, your task could get killed by the O/S if the app is put in the background, so you're not guaranteed to get the result).