Coming from this question, here
I am currently developing an application that needs to scan QR Codes via the Device's built-in camera, using the following libraries:
implementation 'com.google.zxing:core:3.3.3'
implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
The logic I am using to scan the QR Code is as follows, which has been taken from this tutorial:
IntentIntegrator integrator = new IntentIntegrator(QR_Activity.this);
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
integrator.setPrompt("Scan");
integrator.setCameraId(0);
integrator.setBeepEnabled(false);
integrator.setBarcodeImageEnabled(false);
integrator.initiateScan();
This code is being called inside a Button using View.OnClickListener()
, and the result is being handled by onActivityResult
Whenever I run this code and get the result back from the scanner, the scanner returns nothing, and a exception is written to the console, namely Access denied finding property "camera.hal1.packagelist"
. Permissions have been successfully granted to the application. The permissions in question are the CAMERA
and INTERNET
permissions.
The test device in question is a LG V30+ ThinQ Smartphone.
Is there a way to get around this issue? Or is this problem prevalent on all smartphones that have a dual camera setup, and therefore 'unfixable'?
UPDATE
Conducting a simple test using the following code:
/** A safe way to get an instance of the Camera object. */
public static Camera getCameraInstance(){
Camera c = null;
try {
c = Camera.open(); // attempt to get a Camera instance
}
catch (Exception e){
// Camera is not available (in use or does not exist)
}
return c; // returns null if camera is unavailable
}
(The code has been taken from this answer from the above post.)
The above code yields the same results as the IntentIntegrator
code shown above, and throws the same Access denied finding property "camera.hal1.packagelist"
error as before.