AsyncTask is an Android mechanism created to help handle long operations that need to report to the UI thread. To take advantage of this class, we need to create a new subclass of AsyncTask and implement the doInBackground(), onProgressUpdate(), and onPostExecute() methods. In other words, we are going to fill in the blanks for what to do in the background, what to do when there’s some progress, and what to do when the task completes.
doInBackground()执行在 非UI线程 。
用AsyncTask下载文件
参考DownloadTesting工程
创建一个AsyncTask的子类,实现下载工作
启动task
dtask = new DownAFileTask();
dtask.execute(URI.create(uristr));