Java多线程文件下载管理器
2018-07-20 来源:open-open
[Java]代码
String mUrl1 = "https://codeload.github.com/cheyiliu/android-multithread-downloader-lib/zip/master"; String mLocalPath1 = "/mnt/sdcard/android-multithread-downloader-lib.zip"; DownloadManager.from(this).download(mUrl1, mLocalPath1, new DownloadListener() { private long mProgress = 0; @Override public void onSucess() { Log.e("test1", this + "onSucess"); mFinshed[0] = true; if (mFinshed[0] && mFinshed[1] && mFinshed[2]) { mStartEndTime[1] = System.currentTimeMillis(); mHandler.sendEmptyMessage(4); } } @Override public void onProgress(long step, long max) { mProgress += step; Log.i("test1", this + "onProgress, " + mProgress + "/" + max); Message msg = mHandler.obtainMessage(1); msg.arg1 = (int) mProgress; msg.arg2 = (int) max; mHandler.sendMessage(msg); } @Override public void onFail(int reason) { Log.e("test1", this + "onFail, " + reason); } });
标签: 代码
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇:bash维护并行下载任务
最新资讯
热门推荐