如何在Phonegap中使用Java脚本在Android WebBrowser中查看PDF文件?

如何在Phonegap中使用Java脚本在Android WebBrowser中查看PDF文件?,android,cordova,pdf-viewer,Android,Cordova,Pdf Viewer,我必须使用phonegap在android中打开pdf文件。 我已经在iOS上试过了,它工作得很好,但在android设备上的代码不一样 以下是在iOS上运行良好的代码 function Application() { } Application.prototype.Run = function() { if (device.uuid == "e0101010d38bde8e6740011221af335301010333" || device.uuid == "e0908060g38b

我必须使用phonegap在android中打开pdf文件。 我已经在iOS上试过了,它工作得很好,但在android设备上的代码不一样

以下是在iOS上运行良好的代码

function Application() {
}
Application.prototype.Run = function() {
    if (device.uuid == "e0101010d38bde8e6740011221af335301010333" || device.uuid == "e0908060g38bde8e6740011221af335301010333") {
        alert("Not Supported in Simulator.");
    }
    else {
        var infoDiv = document.getElementById("infoField");
        var path = this.getWorkingFolder().replace('http://', 'file://') + "sample.pdf";
        infoDiv.innerText = path;

        if (device.platform === 'Android') {
            window.open(path, '_system');
        }
        else {
            window.open(path, '_blank');
        }
    }
}

Application.prototype.getWorkingFolder = function() {
    var path = window.location.href.replace('index.html', '');
    return path;
}
function onDeviceReady() {
    alert('OnDevice Ready called');
    //navigator.splashscreen.hide();
    document.getElementById('btnOpenPDF').onclick = function() {
        var app = new Application();
        app.Run();
    }
}
document.addEventListener("deviceready", onDeviceReady, false);

你能发布代码吗?这可能会对你有所帮助-它的工作原理与我的代码相同,但在Android WebView中不起作用,你不能直接加载pdf文件。您必须使用第三个应用程序来查看pdf文件,或者使用lib来支持该操作