GithubHelp home page GithubHelp logo

hhy5277 / androiddownloader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ixuea/android-downloader

0.0 1.0 0.0 3.15 MB

An powerful download library for Android.

License: Apache License 2.0

Shell 3.67% Java 96.33%

androiddownloader's Introduction

AndroidDownloader

English | δΈ­ζ–‡

License

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.

Download

You can download a jar from GitHub's releases page.

Or use Gradle:

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Add the dependency:

dependencies {
  compile 'com.ixuea:AndroidDownloader:latest'
}

For info on using the bleeding edge, see the Snapshots wiki page.

ProGuard

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

How do I use Android Downloader?

For more information on GitHub wiki and Javadocs.

0.Add network network permissions()

<uses-permission android:name="android.permission.INTERNET" />

1.Configuration download service

<service android:name="com.ixuea.android.downloader.DownloadService">
  <intent-filter>
    <action android:name="com.ixuea.android.downloader.DOWNLOAD_SERVICE" />
  </intent-filter>
</service>

2.Create a DownloadManager instance

downloadManager = DownloadService.getDownloadManager(context.getApplicationContext());

Simple use as follows

3.Download a file

//create download info set download uri and save path.
final DownloadInfo downloadInfo = new DownloadInfo.Builder().setUrl("http://example.com/a.apk")
    .setPath("/sdcard/a.apk")
    .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) {
    e.printStackTrace();
    tv_download_info.setText("Download fail:" + e.getMessage());
  }
});

//submit download info to download manager.
downloadManager.download(downloadInfo);

Compatibility

  • Android SDK: Android Downloader requires a minimum API level of 10.

Build

Samples

Follow the steps in the Build section to setup the project and then:

./gradlew :samples:run

You may also find precompiled APKs on the releases page.

More

See the example code.

Author

Smile - @ixueadev on GitHub, Email is [email protected], See more ixuea(http://www.ixuea.com)

Android development QQ group: 702321063.

androiddownloader's People

Contributors

carlerisk avatar ixueadev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.