EdwardvanRaak / MaterialBarcodeScanner

Easy to use barcode reader for your Android Project (Uses Google Mobile Vision API)
Apache License 2.0
272 stars 113 forks source link

Scanning not started after granting permission #31

Open xabaras opened 7 years ago

xabaras commented 7 years ago

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?

uziassantosferreira commented 7 years ago

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); }

benoffi7 commented 7 years ago

There is some example code

https://github.com/EdwardvanRaak/MaterialBarcodeScanner/blob/master/app/src/main/java/com/edwardvanraak/materialbarcodescannerexample/MainActivity.java