Downloader is a very lightweight and powerful fast download library, only about 50KB in size. For most applications, it is the most cost-effective download library. The API provided by Downloader is simpler and lightweight, and Downloader provides synchronous downloading, system notification of progress, etc. Function.
Support serial, multi-threaded parallel download
Support breakpoint resume download
Support chunked transfer
Support system notification progress
Support synchronous and asynchronous downloads
Support custom paths
Support adding request headers
Support timeout configuration
Provide simple API
Support redirected downloads
Support progress callback
Retry count configuration
Supports automatic installation after downloading the APK file
Supports operations such as pausing and resuming downloads
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, contentDisposition, mimetype, contentLength, extra); }@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