English | 中文
Report an issue, iOS and macOS use CocoaDownloader.
Android Downloader is a open source multithread and mulitask downloadInfo framework for Android.
Try out the sample application on the Apk file.
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency:
dependencies {
implementation 'com.ixuea:android-downloader:latest'
}
For info on using the bleeding edge, see the Snapshots wiki page.
If your project uses ProGuard, you need to add the following configuration to your project proguard-rules.pro file
-keep public class * implements com.ixuea.android.downloader.db.DownloadDBController
For more information on GitHub wiki and Javadocs.
<uses-permission android:name="android.permission.INTERNET" />
downloadManager = DownloadService.getDownloadManager(context.getApplicationContext());
Simple use as follows
//create download info set download uri and save path.
File targetFile = new File(getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), "a.apk");
final DownloadInfo downloadInfo = new DownloadInfo.Builder().setUrl("http://example.com/a.apk")
.setPath(targetFile.getAbsolutePath())
.build();
//set download callback.
downloadInfo.setDownloadListener(new DownloadListener() {
@Override
public void onStart() {
tv_download_info.setText("Prepare downloading");
}
@Override
public void onWaited() {
tv_download_info.setText("Waiting");
bt_download_button.setText("Pause");
}
@Override
public void onPaused() {
bt_download_button.setText("Continue");
tv_download_info.setText("Paused");
}
@Override
public void onDownloading(long progress, long size) {
tv_download_info
.setText(FileUtil.formatFileSize(progress) + "/" + FileUtil
.formatFileSize(size));
bt_download_button.setText("Pause");
}
@Override
public void onRemoved() {
bt_download_button.setText("Download");
tv_download_info.setText("");
downloadInfo = null;
}
@Override
public void onDownloadSuccess() {
bt_download_button.setText("Delete");
tv_download_info.setText("Download success");
}
@Override
public void onDownloadFailed(DownloadException e) {
bt_download_button.setText("Continue");
tv_download_info.setText("Download fail:" + e.getMessage());
}
});
//submit download info to download manager.
downloadManager.download(downloadInfo);
- Android SDK: Android Downloader requires a minimum API level of 21.
Follow the steps in the Build section to setup the project and then:
./gradlew :app:run
You may also find precompiled APKs on the releases page.
See the example code.
Smile - @ixueadev on GitHub, Email is ixueadev@163.com, See more ixuea(http://www.ixuea.com)
Android development QQ group: 702321063.