Downloader
5.0.4
Downloader 是一個非常輕巧以及功能強大快速下載庫,只有50KB 左右大小,對於大多數應用來說,性價比最高的一個下載庫, Downloader 提供的API更簡單、輕量且Downloader提供同步下載,系統通知進度等功能。
支援串行,多執行緒並行下載
支持斷點續傳
支援分塊傳輸
支援系統通知進度
支援同步,非同步下載
支持自義定路徑
支援添加請求頭
支援超時配置
提供簡易的Api
支援重定向下載
支援進度回調
重試次數配置
支援下載APK檔案完成後自動安裝
支援暫停,恢復下載等操作
allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
Support
implementation 'com.github.Justson:Downloader:v5.0.4'
Androidx
implementation 'com.github.Justson:Downloader:v5.0.4-androidx'
File file = DownloadImpl.getInstance(getApplicationContext()) .url("http://shouji.360tpcdn.com/170918/93d1695d87df5a0c0002058afc0361f1/com.ss.android.article.news_636.apk") .get();
DownloadImpl.getInstance(getApplicationContext()) .url("http://shouji.360tpcdn.com/170918/f7aa8587561e4031553316ada312ab38/com.tencent.qqlive_13049.apk") .enqueue();
DownloadImpl.getInstance(getApplicationContext()) .target(new File(this.getExternalCacheDir(), "com.ss.android.article.news_636.apk")) .setUniquePath(false) .setForceDownload(true) .url("http://shouji.360tpcdn.com/170918/93d1695d87df5a0c0002058afc0361f1/com.ss.android.article.news_636.apk") .enqueue(new DownloadListenerAdapter() {@Overridepublic void onStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength, Extra extra) {super.onStart(url, userAgent, contentLength, Extra extra) {super。 }@Overridepublic void onProgress(String url, long downloaded, long length, long usedTime) {super.onProgress(url, downloaded, length, usedTime);Log.i(TAG, " progress:" + downloaded + " url:" + url); }@Overridepublic boolean onResult(Throwable throwable, Uri path, String url, Extra extra) {Log.i(TAG, " path:" + path + " url:" + url + " length:" + new File(path.getPath ()).length());return super.onResult(throwable, path, url, extra); } });
/data/data/com.download.sample(packagename)/cache/download/private/filename.jpg /data/data/com.download.sample(packagename)/cache/download/public/filename.jpg