-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Error while scanning sometimes on android #137
Comments
It happend also to me in my samsung s3 mini. The first scan works fine, then the scanner scan the code twice and returns {text:"", cancelled: true} |
I made an interesting test: $scope.scanBarcode = function() {
alert("With this alert, the scan will work");
$cordovaBarcodeScanner.scan().then(function(imageData) {
alert(imageData.text);
console.log("Barcode Format -> " + imageData.format);
console.log("Cancelled -> " + imageData.cancelled);
}, function(error) {
alert(error);
console.log("An error happened -> " + error);
});
}; It's a bit weird, but the scan works. This doesn't solve the issue, but can help to find what's wrong. |
Yeah i think the js code is fine, something probably wrong with the java code here I think this test |
That java code doesn't explain why the barcode reader tries to scan twice. I think there are some bug in the activation of the cordova plugin or in the zxing library installed in some phones, but I'm unable to debug this issue atm :( Maybe some official dev could try to recreate the bug or just release the plugin with some extra debug log info 😸 |
given the amount of activity here that will be a long time |
Maybe this issue could be related |
@sparshy please, you can try if my fork submitted in the pr solves your problem? https://github.com/kbytesys/phonegap-plugin-barcodescanner/tree/android-zxing-integration |
@kbytesys No still the same error, is it working for you? |
@sparshy yep did you removed the old plugin and added mine with cordova plugin add https://github.com/kbytesys/phonegap-plugin-barcodescanner.git#android-zxing-integration ? |
Wrapping the plugin call with a setTimeout also works. |
@sparshy I've used the $timeout from Ionic/Angular
But I guess you can use a simple setTimeout instead the $timeout. |
@fonini Wrapping in a $timeout worked for me. Do you have any idea what the issue is and why this would fix it? |
@koga73 Unfortunately, I have no idea why. |
I've noticed when it is going to "fail" the barcode scanner almost appears to open twice. Any scanning after and it fails. The timeout works most of the time but I still saw it fail once or twice. I added a 100ms delay to the timeout and it seems to be better now. |
Update: This is the same as issue #38 |
This thread has been automatically locked. |
On android, sometimes, when the code is scanned the scanner doesnt close and if u continue scanning after scan that the scanner closes with {text:"", cancelled: true}
The text was updated successfully, but these errors were encountered: