appcan uexDownloaderMgr 下载文件状态

这次我躺过了appcan uexDownloaderMgr 插件的血坑 花费了半天的时间废话不多说,直接说问题

需知:uexDownloaderMgr 需要先创建下载对象uexDownloaderMgr.createDownloader(id),后再做下载的行为,其中两次出现id,个人癖好爱用时间搓代替,发现程序运行不了,后面发现是id长度应<=10 ( 又是一道小坑)

问题:没有回调下载状态监听

错误代码:

function downloadInfo(messageBodyString){

            id='1'
            
            var serverURL= messageBody.remotePath;

            savePath ="wgt://data/down/"+ messageBody.displayName;

            uexDownloaderMgr.createDownloader(time); 
            
            uexDownloaderMgr.download(id, serverURL,savePath,'1');
            
        }

错误原因:uexDownloaderMgr.download(time, serverURL,savePath,'1') 应放置 创建下载对象成功中执行

正确代码:

 var cText = 0;
        var cJson = 1;
        var cInt = 2;
        uexDownloaderMgr.cbCreateDownloader = function(opCode,dataType,data){           
              switch(dataType){
                case cText:
                  alert("uex.cText");
                  break;
                case cJson:
                  alert("uex.cJson");
                  break;
                case cInt:
                    if(data == 0){
                     alert("文件一创建成功");
                        id='1'
                        var serverURL= messageBody.remotePath;
            
                        savePath ="wgt://data/down/"+ messageBody.displayName;
            
                        uexDownloaderMgr.createDownloader(time); 
                        
                        uexDownloaderMgr.download(id, serverURL,savePath,'1');    
                                          
                    }else{
                         alert("文件创建失败");
                    }
                    break;
                default:
                    alert("error");
               }      
          }
        });



你可能感兴趣的:(appcan uexDownloaderMgr 下载文件状态)