Open majirosstefan opened 3 years ago
This is a minor issue but it need to be fixed With this implementation, when there are no QR code in the image, the app will crash due to assumption that there must be a barcode in the list on success. I used this patch file to add exception handling which aligns with IOS
diff --git a/node_modules/react-native-qr-decode-image-camera/android/src/main/java/com/lewin/qrcode/QRScanReader.java b/node_modules/react-native-qr-decode-image-camera/android/src/main/java/com/lewin/qrcode/QRScanReader.java
index cc77de0..3d6e811 100644
--- a/node_modules/react-native-qr-decode-image-camera/android/src/main/java/com/lewin/qrcode/QRScanReader.java
+++ b/node_modules/react-native-qr-decode-image-camera/android/src/main/java/com/lewin/qrcode/QRScanReader.java
@@ -55,6 +55,12 @@ public class QRScanReader extends ReactContextBaseJavaModule {
.addOnSuccessListener(new OnSuccessListener<List<Barcode>>() {
@Override
public void onSuccess(List<Barcode> barcodes) {
+ if (barcodes.size() == 0 ){
+ Log.d("NOT_OK", "No related QR code");
+ scanner.close();
+ promise.reject("NOT_OK", "No related QR code");
+ return;
+ }
Log.d("OK", " " + barcodes.toString());
List<String> rawValues = new LinkedList<>();
for (Barcode barcode: barcodes) {`
Hi Deepan,
on Android 8, (Asus Zenfone Max3) it took more than 10s to detect QR codes from gallery images. I used patch-package to fix it like this (it uses MLKit from Google and now QR detection is under 1s) + I guess it can also scan barcodes, etc: