MaterialBarcodeScanner
MaterialBarcodeScanner copied to clipboard
Scanning not started after granting permission
First time I try to scan a barcode MaterialBarcodeScanner asks for camera permission, this is correct, but after the user has granted the permission nothing happens, scanning doesn't get started and the user has to tap in the button calling startScan() again. Is it a bug or the app has to handle the onRequestPermissionsResult callback on its own?
I did a workaround to do this. But I'll send a Pull Request to fix this.
//TODO WORKAROUND TO START LIB AFTER PERMISSION. @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (requestCode ==2 && grantResults[0] == PackageManager.PERMISSION_GRANTED){ //TODO START SCAN AGAIN } super.onRequestPermissionsResult(requestCode, permissions, grantResults); }
There is some example code
https://github.com/EdwardvanRaak/MaterialBarcodeScanner/blob/master/app/src/main/java/com/edwardvanraak/materialbarcodescannerexample/MainActivity.java