码迷,mamicode.com
首页 > 移动开发 > 详细

android 文件断点下载库使用

时间:2015-04-08 09:16:30      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:

类库地址:https://github.com/sungerk/android-downloader


1.首先加入连接网络权限

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

 2.文件读写操作权限

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

 3.使用方法如下:


 <span style="white-space:pre">	</span>String urlString = "url";
   <span style="white-space:pre">	</span>String localPath = Environment.getExternalStorageDirectory()
            .getAbsolutePath() + "/local";
    <span style="white-space:pre">	</span>downloader = new Downloader(this, urlString, localPath,
            "weibo_1790.apk", new OnDownloadListener() {

                @Override
                public void onFinish(String msg) {

                }

                @Override
                public void onError(String msg) {

                }

                @Override
                public void onProgress(int percent, int total,
                        int completeSize) {
                    mProgressBar.setProgress(percent);
                    tv_total.setText(completeSize + "/" + total);
                }

                @Override
                public void onSpeed(String speed) {
                    super.onSpeed(speed);
                    tv_speed.setText("下载速度" + speed);

                }

            });
        //开始下载
        #downloader.start();
        //暂停下载
            #downloader.pause();
        //删除下载
        #downloader.delete();
        //重新下载
        #downloader.reset();


android 文件断点下载库使用

标签:

原文地址:http://blog.csdn.net/s228245214/article/details/44927155

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!