As Morrison said , the syntax ... is for a variable-length argument list ( urls contains more than one URL ).
This is usually used to allow AsyncTask users to do things such as (in your case) pass more than one URL that will be selected in the background. If you have only one URL, you should use your DownloadFilesTask as follows:
DownloadFilesTask worker = new DownloadFilesTask(); worker.execute(new URL("http://google.com"));
or with multiple urls, do the following:
worker.execute(new URL[]{ new URL("http://google.com"), new URL("http://stackoverflow.com") });
onProgressUpdate() used to cause the background task to report progress to the user interface. Since the background task may include multiple tasks (one for each URL parameter), it may be advisable to publish separate progress values ββ(for example, from 0 to 100%) for each task. You donβt have to. Your background task, of course, could calculate the total progress value and pass that single value to onProgressUpdate() .
The onPostExecute() method is slightly different. It processes the result of single , from a set of operations performed in doInBackground() . For example, if you download multiple URLs, you can return a failure code if any of them failed. The input parameter to onPostExecute() will be any value that you return from doInBackground() . Therefore, in this case both values ββare Long .
If doInBackground() returns totalSize , then this value will be passed to onPostExecute() , where it can be used to inform the user about what happened, or any other post-processing that you like.
If you really need to convey several results as a result of a background task, you can, of course, change the general Long parameter to something other than Long (for example, some kind of collection).
Nate
source share