Reputation: 15078
I want to know how that is there any library or code that create small chunks of file to achieve multiple download & multithreading with Pause, Resume functionality
Suppose in play store you can find many download manager app like below
https://play.google.com/store/apps/details?id=com.dv.adm
i have find many library in Github but still did not achieved as I have showed in above image
https://github.com/majidgolshadi/Android-Download-Manager-Pro
https://github.com/Aspsine/MultiThreadDownload
Upvotes: 1
Views: 618
Reputation: 594
I don't really know if any of this is correct, but from what I can read here you have to use HEAD
and RANGE
http headers to do something like this. You calculate the filesize and then divide into chunks of the same byte size, then generate threads to download them.
Upvotes: 1
Reputation: 607
You can use ThreadPoolExecutor to easily manage multiple threads and work distribution. The ThreadPoolExecutor manages thread creation and termination as needed.
It can look quite intimidating at first glance but it really is rather simple when you take 10 minutes to read about it.
Custom pool constructor looks something like this:
Executor executor = new ThreadPoolExecutor(
int corePoolSize,
int maximumPoolSize,
long keepAliveTime, TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory,
RejectedExecutionHandler handler
);
And then:
executor.execute(runnable);
You can also use built-in executors.
You can read more about it here: ThreadPoolExecutor on the Android developers site
Upvotes: 0