zoukankan      html  css  js  c++  java
  • xUtils工具实现下载功能

    private String download_url="http://192.168.2.8:80/DownZip/*****.zip";//下载的路径
    public  String SDPATH = Environment.getExternalStorageDirectory().toString();
    String target = SDPATH+"/DownZip/********.zip";//保存路径必须包含有完整的文件名。


    HttpUtils http = new HttpUtils();

             HttpHandler handler = http.download(download_url,target, true, // 假设目标文件存在。接着未完毕的部分继续下载。server不支持RANGE时将从新下载。


                     true, // 假设从请求返回信息中获取到文件名称。下载完毕后自己主动重命名。
                     new RequestCallBack<File>() {


                         @Override
                         public void onStart() {
                         }


                         @Override
                         public void onLoading(long total, long current,
                                 boolean isUploading) {
                              
                        update_bt.setVisibility(View.VISIBLE);
                        update_bt.setText("更新进度 " + (current * 100 / total)
                                     + "%");
                         }


                         @Override
                         public void onSuccess(ResponseInfo<File> responseInfo) {
    //                         File f = responseInfo.result;
    //                         installApk(f);
                            


                         }


                         @Override
                         public void onFailure(HttpException error, String msg) {
                             Log.e(TAG, msg);
                            
                         }
                     });

  • 相关阅读:
    非科班学习路线
    非科班秋招面试总结
    招银网络Java面经
    派分糖果
    修改CentOS7网卡名称为传统名称eth0格式
    浅谈$* 和$@的区别
    Cobbler无人值守安装
    使用kickstart + pxe 部署无人值守安装
    CentOS 7 忘记root密码解决方法
    linux系统开机流程详解
  • 原文地址:https://www.cnblogs.com/slgkaifa/p/6760097.html
Copyright © 2011-2022 走看看