From 2c33816a19d1e21f61c23ebc854800a7a58bf8c8 Mon Sep 17 00:00:00 2001 From: Jacob Gur Date: Tue, 22 Feb 2022 14:07:29 -0500 Subject: [PATCH] fix NPE --- src/android/QRScanner.java | 5 ++++- src/common/src/createQRScannerAdapter.js | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/android/QRScanner.java b/src/android/QRScanner.java index 1a5fde6c..4d144c3b 100755 --- a/src/android/QRScanner.java +++ b/src/android/QRScanner.java @@ -777,7 +777,10 @@ public void run() { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { - ((ViewGroup) mBarcodeView.getParent()).removeView(mBarcodeView); + ViewGroup parent = (ViewGroup) mBarcodeView.getParent(); + if (parent != null) { + parent.removeView(mBarcodeView); + } cameraPreviewing = false; } }); diff --git a/src/common/src/createQRScannerAdapter.js b/src/common/src/createQRScannerAdapter.js index 184708a2..8bf9209f 100644 --- a/src/common/src/createQRScannerAdapter.js +++ b/src/common/src/createQRScannerAdapter.js @@ -165,6 +165,7 @@ return { throw new Error('No callback provided to scan method.'); } var success = function(result) { + // TODO: If there's an error code, then add message. callback(null, result); }; cordova.exec(success, errorCallback(callback), 'QRScanner', 'scan', []);