├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── activity_main.xml │ │ │ │ └── activity_download.xml │ │ │ ├── drawable │ │ │ │ ├── progressbar_bg.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── yang │ │ │ │ └── download │ │ │ │ ├── MainActivity.kt │ │ │ │ ├── download │ │ │ │ ├── DownloadResponseHandler.java │ │ │ │ ├── DownloadInfo.java │ │ │ │ ├── ResponseProgressBody.java │ │ │ │ ├── SpTool.java │ │ │ │ └── DownloadManager.java │ │ │ │ └── DownLoadActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── yang │ │ │ └── download │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── yang │ │ └── download │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── caches │ └── build_file_checksums.ser ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml ├── codeStyles │ └── Project.xml └── misc.xml ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | DownLoadManager 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cleveryang/DownLoadManager/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cleveryang/DownLoadManager/HEAD/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cleveryang/DownLoadManager/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cleveryang/DownLoadManager/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cleveryang/DownLoadManager/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cleveryang/DownLoadManager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cleveryang/DownLoadManager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cleveryang/DownLoadManager/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cleveryang/DownLoadManager/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cleveryang/DownLoadManager/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cleveryang/DownLoadManager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cleveryang/DownLoadManager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Sep 14 14:28:14 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/yang/download/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.yang.download 2 | 3 | import android.support.v7.app.AppCompatActivity 4 | import android.os.Bundle 5 | 6 | class MainActivity : AppCompatActivity() { 7 | 8 | override fun onCreate(savedInstanceState: Bundle?) { 9 | super.onCreate(savedInstanceState) 10 | setContentView(R.layout.activity_main) 11 | 12 | DownLoadActivity.startActivity(this) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/yang/download/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.yang.download 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/yang/download/download/DownloadResponseHandler.java: -------------------------------------------------------------------------------- 1 | package com.yang.download.download; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * 下载回调 7 | * Created by yang on 18/6/29. 8 | */ 9 | public abstract class DownloadResponseHandler { 10 | 11 | public abstract void onProgress(long currentBytes, long totalBytes); 12 | public abstract void onFinish(File download_file); 13 | public abstract void onPause(DownloadInfo downloadInfo); 14 | public abstract void onCancle(DownloadInfo downloadInfo); 15 | public abstract void onFailure(String error_msg); 16 | } 17 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/yang/download/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.yang.download 2 | 3 | import android.support.test.InstrumentationRegistry 4 | import android.support.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("com.yang.download", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/progressbar_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 26 9 | defaultConfig { 10 | applicationId "com.yang.download" 11 | minSdkVersion 14 12 | targetSdkVersion 26 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar']) 27 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 28 | implementation 'com.android.support:appcompat-v7:26.1.0' 29 | implementation 'com.android.support.constraint:constraint-layout:1.1.2' 30 | testImplementation 'junit:junit:4.12' 31 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 32 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 33 | 34 | //OKHttp 35 | implementation 'com.squareup.okhttp3:okhttp:3.10.0' 36 | //BindView 37 | implementation 'com.jakewharton:butterknife:8.8.1' 38 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' 39 | //eventbus 40 | implementation 'org.greenrobot:eventbus:3.1.1' 41 | //fastjson 42 | implementation 'com.alibaba:fastjson:1.2.34' 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/yang/download/download/DownloadInfo.java: -------------------------------------------------------------------------------- 1 | package com.yang.download.download; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by yang on 2018/6/21. 7 | * 下载信息 8 | */ 9 | 10 | public class DownloadInfo implements Serializable{ 11 | private String url;//下载路径 12 | private String targetUrl;//存储路径 13 | private long total;//总大小 14 | private long progress;//当前进度 15 | private String fileName;//名称 16 | private int downloadState;//下载状态 17 | 18 | public DownloadInfo(String url) { 19 | this.url = url; 20 | } 21 | 22 | public String getUrl() { 23 | return url; 24 | } 25 | 26 | public String getFileName() { 27 | return fileName; 28 | } 29 | 30 | public void setFileName(String fileName) { 31 | this.fileName = fileName; 32 | } 33 | 34 | public long getTotal() { 35 | return total; 36 | } 37 | 38 | public void setTotal(long total) { 39 | this.total = total; 40 | } 41 | 42 | public long getProgress() { 43 | return progress; 44 | } 45 | 46 | public void setProgress(long progress) { 47 | this.progress = progress; 48 | } 49 | 50 | public String getTargetUrl() { 51 | return targetUrl; 52 | } 53 | 54 | public void setTargetUrl(String targetUrl) { 55 | this.targetUrl = targetUrl; 56 | } 57 | 58 | public void setDownloadState(int downloadState) { 59 | this.downloadState = downloadState; 60 | } 61 | 62 | public int getDownloadState() { 63 | return downloadState; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DownloadManager 2 | ## Android下载管理器 3 | 4 | 1、可实现下载、暂停、取消、完成、失败、队列等待等状态的监听 5 | 6 | 2、可断点续传 7 | 8 | 3、基于okhttp的下载管理器,可实现单个页面的进度回调,也可实现所有下载进度的监听. 9 | 10 | 4、可获取下载队列里和已完成下载的所有任务 11 | 12 | 5、可设置最大同时下载线程数 13 | 14 | ## 使用方法 15 | 下载方式有三种: 16 | 17 | /** 18 | * 添加下载任务 19 | * 20 | * @param url 下载请求的网址 21 | * @param targetUrl 下载保存的位置 22 | */ 23 | DownLoadManager.getInstance(this).download(String url, String targetUrl); 24 | 25 | /** 26 | * 添加下载任务 27 | * 28 | * @param url 下载请求的网址 29 | * @param targetUrl 下载保存的位置 30 | * @param downloadResponseHandler 用来回调的接口 31 | */ 32 | DownLoadManager.getInstance(this).download(String url, String targetUrl, final DownloadResponseHandler downloadResponseHandler); 33 | 34 | /** 35 | * 添加下载任务 36 | * 37 | * @param downloadInfo 下载类 38 | * @param downloadResponseHandler 用来回调的接口 39 | */ 40 | DownLoadManager.getInstance(this).download(DownloadInfo downloadInfo, final DownloadResponseHandler downloadResponseHandler) 41 | 42 | 监听下载进度 43 | 44 | 单个任务监听 45 | 46 | DownloadResponseHandler回调 47 | 48 | 全局监听(eventbus实现,也可用广播等) 49 | 50 | @Subscribe(threadMode = ThreadMode.BACKGROUND) 51 | public void onMessageEvent(DownloadInfo info){ 52 | //返回info对象(这是在子线程) 53 | } 54 | 55 | 取消下载 56 | 57 | DownLoadManager.getInstance(this).cancel(url); 58 | 59 | 取消全部下载 60 | 61 | DownLoadManager.getInstance(this).cancelAll(); 62 | 63 | 64 | 暂停下载 65 | 66 | DownLoadManager.getInstance(this).pause(url); 67 | 68 | 暂停全部下载 69 | 70 | DownLoadManager.getInstance(this).pauseAll(); 71 | 72 | 设置同时下载请求数(默认为1) 73 | 74 | DownLoadManager.getInstance(this).setMaxRequests(1); 75 | 76 | 得到下载队列(等待中,下载中和暂停的任务) 77 | 78 | DownloadManager.getInstance(this).getDownloadInfos(); 79 | 80 | 得到已完成队列(不校验文件是否存在或完整,如用户手动删除了源文件) 81 | 82 | DownloadManager.getInstance(this).getCompleteInfos(); 83 | 84 | ## 说明介绍 85 | 86 | DownloadInfo类 87 | 88 | private String url;//下载路径 89 | private String targetUrl;//存储路径 90 | private long total;//总大小 91 | private long progress;//当前进度 92 | private String fileName;//名称 93 | private int downloadState;//下载状态 94 | 95 | 各个下载状态 96 | 97 | public static final int DOWNLOAD_STATE_WAITING = 0x00;//等待 98 | public static final int DOWNLOAD_STATE_DOWNLOADING = 0x01;//下载中 99 | public static final int DOWNLOAD_STATE_PAUSE = 0x02;//暂停 100 | public static final int DOWNLOAD_STATE_CANCLE = 0x03;//取消 101 | public static final int DOWNLOAD_STATE_FINISH = 0x04;//完成 102 | public static final int DOWNLOAD_STATE_FAIL = 0x05;//失败 103 | public static final int DOWNLOAD_STATE_RESTART = 0x06;//重新下载 104 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_download.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 22 |