phonegap を使用してファイルをダウンロードしているときに、インターネットがオフになると、アプリケーションがハングしてクラッシュします。次のエラーが表示されます。
* UNCOUGHT EXCENCTIONによるアプリの終了「NSINVALIDARGUMENTEXCEPTION」、理由: ' - [__ NSCFDictionAry SetObject:forkey:]:inl value(key:body)' ' first show call stack:(0x35b4c88f 0x33770259 0x35b4c789 0x35b4450x44444c78988f 0x34ef56a3 0x34f9ddfb 0x3189dcb5 0x318034b7 0x318031a3 0x318030d9 0x35b20ad3 0x35b20335 0x35b1f045 0x35aa24a5 0x35aa236d 0x3383d439 0x3327acd5 0x28d9f 0x28d60) terminate called throwing an exception(lldb)
ファイルのロジックをダウンロードしています:
if(isOnline){
// alert("DEVICE is ONLINE" + isOnline);
try{
filePath = globalPathNew + "/" +name+ "."+fExt;
// alert("SAVING VIDEO AT ------> " + filePath);
document.getElementById('PB'+name).style.display = 'block';
document.getElementById('P'+name+'L').innerHTML = '';
document.getElementById('P'+name+'L').innerHTML = 'Downloading...';
ftv.onprogress = function(progressEvent) {
console.log("In Progress video"+progressEvent.lengthComputable);
if (progressEvent.lengthComputable) {
//downloadcompleteStatus = Math.round(100 * (progressEvent.loaded / progressEvent.total));
$("#P" + name + "Progress").text(Math.round(100 * (progressEvent.loaded / progressEvent.total)) + "%");
console.log("------progressEvent if video------->%"+Math.round(100 * (progressEvent.loaded / progressEvent.total)));
} else {
console.log("------progressEvent else------->%"+Math.round(100 * (progressEvent.loaded / progressEvent.total)));
}
};
fileObjAbort = ftv;
//alert("Video FileObj"+JSON.stringify(fileObjAbort));
ftv.download(
url,
filePath,
function(entry) {
// alert("download complete: " + entry.fullPath);
// console.log('video entry.fullPath------'+entry.fullPath);
// console.log('video filePath ----'+filePath);
changeIsdownloadStatus(filePath, name, 'video');
if(currElementId != '' && currElementId != '' && currElementId != ''){
detailPageView(currElementId,currElementtype,currElementcountNum);
}
var index = -1;
$.each(downloadList, function(key,tempItem){
if(tempItem.elementId == elementId){
index = key;
}
});
// alert("dw list"+JSON.stringify(downloadList));
if(index != -1){
delete downloadList[index];
downloadList.splice(index,1);
}
//alert("dw list after Video Splice \n"+JSON.stringify(downloadList));
findNextDownloadItem(name);
// alert("DOWNLOADED ------> ");
if(currDownload == elementId){
//changeIsdownloadStatus(filePath,name, 'delete');
if(currElementId != '' && currElementId != '' && currElementId != ''){
detailPageView(currElementId,currElementtype,currElementcountNum);
}
}
console.log('*********************Video******************************');
console.log('-->delete element id:'+elementId);
console.log('deleteProgressindex Position:'+index);
console.log('-->before delete Length Array :'+downloadList.length);
console.log('-->before delete Length Array :'+downloadList.length);
console.log('***************************************************');
// playMedia(filePath, name,'video');
// Code added
//bhavya getFileSystemRefForWriting(jsonData);
deleteProgress(name,elementTitle,isDownloadedFlag,elementAudio,val,filePath);
// Code added
// getFileSystemRefForWriting(jsonData);
},
function(error) {
if(error.code != 4 || error.code != '4'){
//alert("Download Error");
jAlert('Download was not completed due to lost internet connection. Please connect to the Internet and re-download.', 'TT');
console.log("download error" + error.source);
// console.log("download error source " + error.source);
// console.log("download error target " + error.target);
// console.log("upload error code" + error.code);
}
}
);
}
catch(error)
{
var txt="There was an error on this page.\n\n";
txt+="Error description: " + err.message + "\n\n";
txt+="Click OK to continue.\n\n";
console.log('in catch block of video------>>>>'+txt);
}
}else{
jAlert('Please go online to download file.', 'TT');
}
インターネットから切断すると、次のエラーが表示されます。インターネット接続が失われたため、ダウンロードは完了しませんでした。インターネットに接続して、再度ダウンロードしてください。
インターネットがオフになると、objective-c への切り替えがmain.mファイルで行われ、次の行でスタックします。
retVal が 0 であり、NSLog 行を実行しません。
#import <UIKit/UIKit.h>
int main(int argc, char* argv[])
{
@autoreleasepool {
**int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");**
NSLog(@"RETURN VALUE ----->: %d ", retVal);
return retVal;
}
}
誰かがこれの考えられる理由を提案できますか?
ありがとう、アンキット・タンナ