I'm using PhoneGap 2.2.0 and the barcode plugin https://github.com/phonegap/phonegap-plugins/tree/master/Android/BarcodeScanner (version 2.0.0)
Here is the 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>
When I launch this code on my phone(Galaxy S3 under 4.1.1) in landscape mode everything is ok. When I launch this code in portrait mode then the scan bar result is never returned and there is not error message. It just come back to the index.html, if I launch a new time the scan(in landscape) it works.
So I guess that there is a bug with the phone rotation and the phonegap barcode plug in. Someone has a solution please ?