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);
                            
                         }
                     });

  • 相关阅读:
    Linux下安装Apache2.4.43踩坑记录
    网络代理条件下配置git
    docker存储驱动的选择
    Python列表排序
    解决apache无法启动No space left on device
    Flask匹配url使用正则表达式
    Web安全-客户端脚本安全
    springboot中的一些好用注解
    基于cdn方式的vue+element-ui的单页面架构
    干货网站
  • 原文地址:https://www.cnblogs.com/slgkaifa/p/6760097.html
Copyright © 2011-2022 走看看