- Kdownloader can be used to download any type of files like image, video, pdf, apk and etc.
- This file downloader library supports pause and resume while downloading a file.
- Supports large file download.
- This downloader library has a simple interface to make download request.
- We can check if the status of downloading with the given download Id.
- Kdownloader gives callbacks for everything like onProgress, onCancel, onStart, onError and etc while downloading a file.
- Supports proper request canceling.
- Many requests can be made in parallel.
- All types of customization are possible.
Update your settings.gradle file with the following dependency.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // this one
}
}
Update your module level build.gradle file with the following dependency.
dependencies {
implementation 'com.github.varungulatii:Kdownloader:1.0.4'
}
Do not forget to add internet permission in manifest if already not present
<uses-permission android:name="android.permission.INTERNET" />
First of all, we need to create a Kdownloader instance
kDownloader = KDownloader.create(applicationContext)
Then use it like this anywhere:
val request = kDownloader
.newRequestBuilder(url, dirPath, fileName,)
.tag("TAG")
.build()
// Using all of these lambdas is not mandatory. for example - you can only use onStart or onProgress also
downloadId = kDownloader.enqueue(request,
onStart = {
},
onProgress = {
},
onCompleted = {
},
onError = {
},
onPause = {
}
)
kDownloader.pause(downloadId);
kDownloader.resume(downloadId);
// Cancel with the download id
kDownloader.cancel(downloadId);
// The tag can be set to any request and then can be used to cancel the request
kDownloader.cancel(TAG);
// Cancel all the requests
kDownloader.cancelAll();
// Method to clean up temporary resumed files which is older than the given day
kDownloader.cleanUp(days);
- Download notifications
Copyright (C) 2023 Varun Gulati
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.
All pull requests are welcome, make sure to follow the contribution guidelines when you submit pull request.