var fileType = ".apk";
if (true){
const rootPath = jsb.fileUtils.getWritablePath();
const filtPath = rootPath + fileName + fileType;
var downloader = new jsb.Downloader();
cclog(TAG,"downloadAPK downloader"+downloader);
downloader.setOnFileTaskSuccess(function(){
cclog(TAG,"downloadAPK 下载成功");
});
downloader.setOnTaskProgress(function(task, bytesReceived, totalBytesReceived, totalBytesExpected){
cclog(TAG,"downloadAPK 已完成大小 = "+bytesReceived);
cclog(TAG,"downloadAPK 总大小 "+totalBytesReceived);
cclog(TAG,"downloadAPK 预期大小 "+totalBytesExpected);
});
downloader.setOnTaskError(function(){
cclog(TAG,"downloadAPK 下载失败");
});
downloader.createDownloadFileTask(url, filtPath,"");//创建下载任务
return;
}
下载文件就会下载一半失败,(文件稍大会出现 比如大于5M)