hi I am using phonegap barcodeplugin wildabeast/BarcodeScanner
for scanning the barcodes.
Here is my code
$('#scanbtn').on( "tap", function(evt){
scanner = null;
if(ival == 0){
ival = 1;
scanaction();
}
});
function scanaction(){
cordova.plugins.barcodeScanner.scan( function (result) {
scanText = result.text;
scanFormat = result.format;
scanCancelled = result.cancelled;
/* alert("We got a barcode\n" +
"Result: " + scanText + "\n" +
"Format: " + scanFormat + "\n" +
"Cancelled: " + scanCancelled); */
$.mobile.changePage('#pageTwo',{transition: "slide"});
}, function (error) {
ival = 0;
console.log("Scanning failed: ", error);
});
}
And the log I'm getting on this occasion is
2014-05-23 10:41:26.629 ShareQ[283:60b] WARNING: -[<AVCaptureVideoPreviewLayer: 0x155ba090> isOrientationSupported] is deprecated. Please use AVCaptureConnection's -isVideoOrientationSupported
2014-05-23 10:41:26.735 ShareQ[283:60b] WARNING: -[<AVCaptureVideoPreviewLayer: 0x155ba090> setOrientation:] is deprecated. Please use AVCaptureConnection's -setVideoOrientation:
2014-05-23 10:41:27.300 ShareQ[283:60b] WARNING: -[<AVCaptureVideoPreviewLayer: 0x155ba090> setOrientation:] is deprecated. Please use AVCaptureConnection's -setVideoOrientation:
2014-05-23 10:41:27.310 ShareQ[283:60b] Warning: Attempt to present <CDVbcsViewController: 0x155392f0> on <MainViewController: 0x1559e3c0> while a presentation is in progress!
2014-05-23 10:41:27.321 ShareQ[283:60b] Warning: Attempt to present <CDVbcsViewController: 0x1553bb20> on <MainViewController: 0x1559e3c0> while a presentation is in progress!
2014-05-23 10:41:27.324 ShareQ[283:60b] Warning: Attempt to present <CDVbcsViewController: 0x1553d2b0> on <MainViewController: 0x1559e3c0> while a presentation is in progress!
2014-05-23 10:41:27.326 ShareQ[283:60b] Warning: Attempt to present <CDVbcsViewController: 0x155418b0> on <MainViewController: 0x1559e3c0> while a presentation is in progress!
2014-05-23 10:41:27.328 ShareQ[283:60b] Warning: Attempt to present <CDVbcsViewController: 0x155456f0> on <MainViewController: 0x1559e3c0> while a presentation is in progress!
2014-05-23 10:41:27.331 ShareQ[283:60b] Warning: Attempt to present <CDVbcsViewController: 0x155fa710> on <MainViewController: 0x1559e3c0> while a presentation is in progress!
The problem is due to the jquerymobile framework. The "tap" function in the jquerymobile fires multiple times on a single click was the reason for the issue I've mensioned. It is rectified by changing the jquerymobile's "tap" method as follows
$(document).off('tap', '#scanbtn')
.on('tap', '#scanbtn',function(e) {
if(ival == 0){
ival = 1;
scanaction();
}
});
Now my issue is solved. The scanner works fine.