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

Application crashes when pressing the torch button on devices without a torch #15

Open jbcrouse opened 8 years ago

jbcrouse commented 8 years ago

Tested with a couple of devices and the ones with a torch present work fine when the button is pressed, but those without flash capability cause the app to crash when pressed.

Tested on a Samsung Galaxy Tab III.

Looks like the problem is in CameraSource,java setFlashMode(). parameters.getSupportedFlashModes() returns null if flash mode setting is not supported, which causes a null reference exception when .contains(mode) is called on it. https://developer.android.com/reference/android/hardware/Camera.Parameters.html#getSupportedFlashModes()