1 Star 5 Fork 1

xiexiang / GHDownload

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

GHDownload

一、How to use?

Step1:

String url = "http://gh-game.oss-cn-hangzhou.aliyuncs.com/1434794302961350.apk";
DownloadEntry entry = new DownloadEntry(url);
entry.name = "x三国.apk";

Step2: To start a downloading task:

DownloadManager.getInstance(MainActivity.this).add(entry);

To pausea downloading task:

DownloadManager.getInstance(MainActivity.this).pause(entry);

To resume downloading task:

DownloadManager.getInstance(MainActivity.this).resume(entry);

To resume cencel task:

DownloadManager.getInstance(MainActivity.this).cancel(entry);

Step3: If you want to receive process information of downloading task, you should add observer in current Class,for example, in MainActivity:

(1)Create a datawatcher to receive notification.

       private DataWatcher dataWatcher = new DataWatcher() {

		@Override
		public void onDataChanged(DownloadEntry data) {
			entry = data;
			showText.setText(entry.toString());
		}
	};

(2)Add observer.

    @Override
    protected void onResume() {
        super.onResume();
		DownloadManager.getInstance(this).addObserver(dataWatcher);
    }

(3)Remove observer.

    @Override
    protected void onPause() {
        super.onPause();
        DownloadManager.getInstance(this).removeObserver(dataWatcher);
    }

二、Set download config

In DownloadConfig.java You can set max downloading task and max downloading threads.

If you set max_download_threads to 1,it will use FileOutputStream instead of RandomAccessFile, which is faster. Otherwise, it will use RandomAccessFile.

private int max_download_tasks = 3;
private int max_download_threads = 3;
public static String DOWNLOAD_PATH = Environment.getExternalStorageDirectory() + File.separator +
    		"gh-download" + File.separator;

##备注: (1)该下载框架使用了ormlite框架

(2)如果使用生成的ghdownloadv1.2.jar作为引用的jar包,注意要把ormlite的jar包也一起引用

(3)在AndroidManifest.xml中要添加如下service:

<service android:name="com.gh.ghdownload.core.DownloadService" >

空文件

简介

android下载框架,支持单线程和多线程断点下载。 展开 收起
Java
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/DeWork.com/GHDownload.git
git@gitee.com:DeWork.com/GHDownload.git
DeWork.com
GHDownload
GHDownload
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891