Cordova 带有条形码扫描仪的Phonegap出现屏幕旋转问题

Cordova 带有条形码扫描仪的Phonegap出现屏幕旋转问题,cordova,barcode,barcode-scanner,screen-rotation,Cordova,Barcode,Barcode Scanner,Screen Rotation,我正在使用PhoneGap 2.2.0和条形码插件(版本2.0.0) 以下是index.html: <!DOCTYPE HTML> <html> <head> <title>Cordova</title> <link rel="stylesheet" type="text/css" href="kkstyle.css" /> <script type="text/javascript"

我正在使用PhoneGap 2.2.0和条形码插件(版本2.0.0)

以下是index.html:

<!DOCTYPE HTML>
    <html>
    <head>
    <title>Cordova</title>
    <link rel="stylesheet" type="text/css" href="kkstyle.css" />
<script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"></script>
<script type="text/javascript" charset="utf-8" src="barcodescanner.js"></script>

<script type="text/javascript" charset="utf-8">
    document.addEventListener("deviceready", onDeviceReady, onDeviceReadyFailed);

    function onDeviceReady() {

    }

    function onDeviceReadyFailed() {
        alert("device not ready");
    }

    function scanIt() {

        window.plugins.barcodeScanner.scan(function(result) {
            alert("We got a barcode\n" + "Result: " + result.text + "\n"
                    + "Format: " + result.format + "\n" + "Cancelled: "
                    + result.cancelled);
            navigator.app.loadUrl("http://m.kelkoo.com/fr/search/"
                    + result.text);
            //http://m.kelkoo.com/fr/search/9782092610954
            //window.location.href = "http://www.kelkoo.fr/ss-"+ result.text +".html";
        }, function(error) {
            alert("Scanning failed: " + error);
        });

    }
</script>

</head>
<body>
    <div data-role="page">
        <br><br><br>
        <div id="camera">
            <button class="camera-control" onclick="scanIt();">Scan</button>
            <div style="text-align: center; margin: 20px;">
                <img id="cameraPic" src="" style="width: auto; height: 120px;"></img>
            </div>
        </div>
    </div>
</body>
</html>

科尔多瓦
文件。添加的监听器(“deviceready”,onDeviceReady,onDeviceReadyFailed);
函数ondevicerady(){
}
函数OnDeviceradyFailed(){
警报(“设备未就绪”);
}
函数scanIt(){
window.plugins.barcodeScanner.scan(函数(结果){
警报(“我们得到了一个条形码\n”+”结果:“+Result.text+”\n”
+格式:“+result.Format+”\n“+”已取消:
+结果(已取消);
navigator.app.loadUrl(“http://m.kelkoo.com/fr/search/"
+结果(文本);
//http://m.kelkoo.com/fr/search/9782092610954
//window.location.href=”http://www.kelkoo.fr/ss-“+result.text+”.html”;
},函数(错误){
警报(“扫描失败:+错误”);
});
}



扫描
当我在手机上以横向模式启动此代码(4.1.1下的Galaxy S3)时,一切正常。当我在纵向模式下启动此代码时,扫描条结果永远不会返回,并且没有错误消息。如果我启动新的扫描时间(在横向中),它就会返回index.html


因此,我猜手机旋转和phonegap条形码插件存在缺陷。有人有解决方案吗?

执行时似乎没有调用barcodescanner.java的“onActivityResult”回调。我不知道为什么。答案在第一个答案中