Skip to content

Task start and cancel

Jacksgong edited this page Apr 4, 2018 · 1 revision

Start a task

task = new DownloadTask.Builder(url, parentFile)
         .setFilename(filename)
         // the minimal interval millisecond for callback progress
         .setMinIntervalMillisCallbackProcess(30)
         // do re-download even if the task has already been completed in the past.
         .setPassIfAlreadyCompleted(false)
         .build();

task.enqueue(listener);

// cancel
task.cancel();

Start tasks

// This method is optimize specially for bunch of tasks
DownloadTask.enqueue(tasks, listener);

// cancel, this method is also optmize specially for bunch of tasks
DownloadTask.cancel(tasks);
Clone this wiki locally