xUtils文件下载
//程序检查更新时,从服务器下载最新apkprivatevoiddownload(finalContextcontext){//FilesdCardFile=newFile(Environment.getExternalStorageDirectory().getAbsolutePath());finalFilefile=newFile(Environment.getExternalStorageDirectory().getAbsolutePath(),"/11AXP_PACKET_LastVer_dev.apk");HttpUtilshttp=newHttpUtils();HttpHandlerhandler=http.download("http://update.axpapp.com/appUpdate/downloadFile?filename=AXP_PACKET_LastVer_dev.apk",file.getAbsolutePath(),true,//如果目标文件存在,接着未完成的部分继续下载。服务器不支持RANGE时将从新下载。false,//如果从请求返回信息中获取到文件名,下载完成后自动重命名。***这个比较重要,newRequestCallBack<File>(){@OverridepublicvoidonStart(){Log.v("updateAPK","conn...");UpdateAppDialog.showDialog(SplashActivity.this,"正在更新程序","正在更新程序","",null);}@OverridepublicvoidonLoading(longtotal,longcurrent,booleanisUploading){Log.v("updateAPK",current+"/"+total);UpdateAppDialog.updateProgress((int)total/1024,(int)current/1024);}@OverridepublicvoidonSuccess(ResponseInfo<File>responseInfo){Log.v("updateAPK",responseInfo.result.getPath());UpdateAppDialog.dissDialog();CommandTools.install(file,context);}@OverridepublicvoidonFailure(HttpExceptionerror,Stringmsg){Log.v("updateAPK",msg);}});}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。