lingochamp /FileDownloader
Multitask、MultiThread(MultiConnection)、Breakpoint-resume、High-concurrency、Simple to use、Single/NotSingle-process
★ 11,129⑂ 2,200
+0
Daily
-2
Weekly
+1
Monthly
11,129
stars
2,200
forks
–
watchers
–
prs
–
issues
–
releases
README
FileDownloader
Android multi-task file download engine.
[![Download][bintray_svg]][bintray_url]
![][file_downloader_svg]
[![Build Status][build_status_svg]][build_status_link]
[![][filedownloader_snapshot_svg]](https://oss.sonatype.org/content/repositories/snapshots/com/liulishuo/filedownloader/)
中文文档
FileDownloader2
Now, FileDownloader2-OkDownload is released, okdownload will contain all advantage on the FileDownloader and beyond.
Because of FileDownloader unit-test coverage is very low, so all farther features and enhances will be achieved on the okdownload instead of FileDownloader, and FileDownloader will only focuses on bug fixes.
DEMO
![][single_demo_gif]
![][chunked_demo_gif]
![][serial_tasks_demo_gif]
![][parallel_tasks_demo_gif]
![][tasks_manager_demo_gif]
![][hybrid_test_demo_gif]
![][avoid_drop_frames_1_gif]
![][avoid_drop_frames_2_gif]
Installation
FileDownloader is installed by adding the following dependency to your build.gradle file:
groovy
dependencies {
implementation 'com.liulishuo.filedownloader:library:1.7.7'
}
Snapshots of the development version are available in Sonatype's snapshots repository, you can include on your gradle project through:
groovy
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
Open customize component
From now on, FileDownloader support following components to be customized by yourself:
| Name | Interface | Default Impl
| --- | --- | ---
| Connection | [FileDownloadConnection][FileDownloadConnection-java-link] | [FileDownloadUrlConnection][FileDownloadUrlConnection-java-link]
| OutputStream | [FileDownloadOutputStream][FileDownloadOutputStream-java-link] | [FileDownloadRandomAccessFile][FileDownloadRandomAccessFile-java-link]
| Database | [FileDownloadDatabase][FileDownloadDatabase-java-link] | [RemitDatabase][RemitDatabase-java-link]
| ConnectionCountAdapter | [ConnectionCountAdapter][ConnectionCountAdapter-java-link] | [DefaultConnectionCountAdapter][DefaultConnectionCountAdapter-java-link]
| IdGenerator | [IdGenerator][IdGenerator-java-link] | [DefaultIdGenerator][DefaultIdGenerator-java-link]
| ForegroundServiceConfig | [ForegroundServiceConfig][ForegroundServiceConfig-java-link] | [ForegroundServiceConfig][ForegroundServiceConfig-java-link]
- If you want to use okhttp as your connection component, the simplest way is this repo.
- If you don't want to use any database on FileDownloader(the database on FileDownloader is used for persist tasks' breakpoint info) just using NoDatabaseImpl.java
How to valid it?
Just create your own DownloadMgrInitialParams.InitCustomMaker and put those customized component to it, finally init the FileDownloader with it: FileDownloaderinit
Adaptation
Adapt to Android 8.0
The restriction of background service has been tightened since Android 8.0, for more details, please refer to here.
So, after Android 8.0, the download service will be a foreground service when start downloading during app is