- Support add, pause, resume and delete of download task.
- Support continue downloading from where interrupted.
- All tasks will be recorded in sqlite db.
- Multi downloading threads.
- Auto retry on fail.
Module tugcore is the library for downloading, and app is a demo.
// initialization
int logLevel = BuildConfig.DEBUG ? Log.VERBOSE : Log.INFO;
Tug tug = new Tug.Builder(this)
.setNeedLog(true)
.setLogLevel(logLevel)
.setThreads(2)
.build();
Tug.setInstance(tug);
Tug.getInstance().start();
// add task to download
String url = "http://..."; // file url to download
String filePath = "/sdcard/..."; // local file path to save
DownloadListener downloadListener = ...; // download listener to receive callback events
Tug.getInstance().addTask(url, TugTask.FileType.FILE, filePath, downloadListener);
If you are building with Gradle, simply add the following line to the dependencies
section of your build.gradle
file:
compile 'me.chatgame.mobilecg:tugcore:1.1.1'
And add mavenCentral()
to repositories
section in build.gradle