Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/430.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript FileOpener2导致在Android 6.0或更高版本上尝试调用cordova.js文件中的虚拟方法_Javascript_Java_Android_Cordova_Fileopener2 - Fatal编程技术网

Javascript FileOpener2导致在Android 6.0或更高版本上尝试调用cordova.js文件中的虚拟方法

Javascript FileOpener2导致在Android 6.0或更高版本上尝试调用cordova.js文件中的虚拟方法,javascript,java,android,cordova,fileopener2,Javascript,Java,Android,Cordova,Fileopener2,我们使用用于cordova的FileOpener2插件从服务器打开下载的.apk文件。最近,我们发现Android 6.0或更高版本的设备仅在文件打开过程中抛出异常。我们能够将其追溯到cordova.js文件,在该文件中发生了发布的异常。我们还没有找到原因或解决办法,但已经找到了解决办法。这方面的任何信息都会让人惊讶,因此我们可以在所有Android设备上保持应用程序内的自我更新过程 代码(在Android上工作) // we need to access LocalFileSystem

我们使用用于cordova的FileOpener2插件从服务器打开下载的.apk文件。最近,我们发现Android 6.0或更高版本的设备仅在文件打开过程中抛出异常。我们能够将其追溯到cordova.js文件,在该文件中发生了发布的异常。我们还没有找到原因或解决办法,但已经找到了解决办法。这方面的任何信息都会让人惊讶,因此我们可以在所有Android设备上保持应用程序内的自我更新过程

代码(在Android上工作)
// we need to access LocalFileSystem
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 5 * 1024 * 1024, function (fs) {
        //Show user that download is occurring
        $("#toast").dxToast({
            message: "Downloading please wait..",
            type: "warning",
            visible: true,
            displayTime: 20000
        });

        // we will save file in .. Download/OURAPPNAME.apk
        var filePath = cordova.file.externalRootDirectory + '/Download/' + "OURAPPNAME.apk";
        var fileTransfer = new FileTransfer();
        var uri = encodeURI(appDownloadURL);

        fileTransfer.download(uri, filePath, function (entry) {
            //Show user that download is occurring/show user install is about to happen
            $("#toast").dxToast({
                message: "Download complete! Launching...",
                type: "success",
                visible: true,
                displayTime: 2000
            });

            ////Use pwlin's fileOpener2 plugin to let the system open the .apk
            cordova.plugins.fileOpener2.open(
                entry.toURL(),
                'application/vnd.android.package-archive',
                {
                    error: function (e) {
                        window.open(appDownloadURL, "_system");
                    },
                    success: function () { console.log('file opened successfully'); }
                }
            );
        },
        function (error) {
            //Show user that download had an error
            $("#toast").dxToast({
                message: error.message,
                type: "error",
                displayTime: 5000
            });
        },
        false);
    })
var msgs = nativeApiProvider.get().exec(bridgeSecret, service, action, callbackId, argsJson);
// If argsJson was received by Java as null, try again with the PROMPT bridge mode.
// This happens in rare circumstances, such as when certain Unicode characters are passed over the bridge on a Galaxy S2.  See CB-2666.
if (jsToNativeBridgeMode == jsToNativeModes.JS_OBJECT && msgs === "@Null arguments.") {
    androidExec.setJsToNativeBridgeMode(jsToNativeModes.PROMPT);
    androidExec(success, fail, service, action, args);
    androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
} else if (msgs) {
    messagesFromNative.push(msgs);
    // Always process async to avoid exceptions messing up stack.
    nextTick(processMessages);
}