FileDownloader README

The project's README from github.com/lingochamp/FileDownloader. As one markdown file: README.md.

FileDownloader

Android multi-task file download engine.

Download Build Status

中文文档

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

Installation

FileDownloader is installed by adding the following dependency to your build.gradle file:

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:

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 FileDownloadUrlConnection
OutputStream FileDownloadOutputStream FileDownloadRandomAccessFile
Database FileDownloadDatabase RemitDatabase
ConnectionCountAdapter ConnectionCountAdapter DefaultConnectionCountAdapter
IdGenerator IdGenerator DefaultIdGenerator
ForegroundServiceConfig ForegroundServiceConfig ForegroundServiceConfig
  • 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: FileDownloader#init

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 in background and you will see a notification with a title named "FileDownloader" start from FileDownloader 1.7.6. You can refer to here to custom the notification.

Adapt to Android 9.0

Starting with Android 9.0 (API level 28), cleartext support is disabled by default, you can have a look at here to know about more details. FileDownloader demo has handled this problem start with 1.7.6.

According to the migration notes, the FOREGROUND_SERVICE permission has been added to the library manifest since FileDownloader 1.7.6.

Welcome PR

If you can improve the unit test for this project would be great.

Usage

By default, the FileDownloadService runs on the separate process, if you want to run it on the main process, just configure on the filedownloader.properties, and you can use FileDownloadUtils.isDownloaderProcess(Context) to check whether the FileDownloadService can run on the current process.

For more readable, Moved to Wiki.

LICENSE

Copyright (c) 2015 LingoChamp Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

FileDownloader (lingochamp/FileDownloader)

Searching Database…

这是什么?FileDownloader 是一个 Android 库,用于构建多任务文件下载,支持断点续传、每个任务的多线程(多连接)下载,并支持高并发。
这是要添加到我应用里的库,还是一个独立的应用?它是一个通过 Gradle 集成的 Android 库,下载工作由内部的 FileDownloadService 运行,而不是独立的应用。
我该如何把它添加到我的 Android 项目中?在 build.gradle 文件中添加 FileDownloader 依赖;也可以通过 Sonatype 的 snapshots 仓库获取开发快照版本。
这个项目还在积极开发吗?基本已经停止维护,实际上已被弃用:作者已将新功能转移到 FileDownloader2-OkDownload,这里只提供错误修复,主要原因是该项目的单元测试覆盖率非常低。
我可以自定义它使用的网络连接、存储或数据库吗?可以。FileDownloader 允许通过传给 FileDownloader#init 的 DownloadMgrInitParams.InitCustomMaker,为 Connection、OutputStream、Database、ConnectionCountAdapter、IdGenerator 和 ForegroundServiceConfig 接入自定义实现。
它会自动处理 Android 8 和 9 的限制吗?从 1.7.6 版本开始,在 Android 8 及以上系统中,下载服务以带通知的前台服务方式运行,清单文件中包含 FOREGROUND_SERVICE 权限;自带的示例还处理了 Android 9 默认禁用明文流量的问题。
下载服务是否运行在独立的进程中?默认是的,FileDownloadService 运行在单独的进程中;你可以通过 filedownloader.properties 将其切换到主进程,并使用 FileDownloadUtils.isDownloaderProcess(Context) 进行检查。
它与普通的下载管理器有何不同?它结合了多任务、每个任务的多线程/多连接下载,以及高并发的断点续传,同时力求在功能丰富的情况下依然简单易用。
Creator
lingochamp
Size
39.8 MB
Stars
11.1K
Age
10y
Commits · 90 Days