zxing-android-embedded icon indicating copy to clipboard operation
zxing-android-embedded copied to clipboard

Turning on and off the flash is not working on Android 11

Open TheKamranUllah opened this issue 4 years ago • 2 comments

Description of the problem:

if (isFlashOn) { mCodeScanner!!.isFlashEnabled = false isFlashOn = false Toast.makeText(getActivity(), "False", Toast.LENGTH_LONG).show(); } else { mCodeScanner!!.isFlashEnabled = true isFlashOn = true Toast.makeText(getActivity(), "True", Toast.LENGTH_LONG).show(); } The above code makes no sense for turning flash light on/off

Which library version are you using? E.g. 3.2.0. Library version: 3.2.1'

Which phone/tablet are you using, and which Android version does it run? (e.g. Samsung Galaxy S5, Android 5.0) I am using Redmi 9 with Android version 11

Does the same happen on other devices or an emulator? Works fine on Android 10 and Android 6 I checked on these two.

Can you reproduce the issue in the sample project included with the library? If not, can you provide your own sample project or sample code that produces this error?

Provided above in the problem description

In the case of an error do you have a stack trace or adb logs?

TheKamranUllah avatar Aug 17 '21 07:08 TheKamranUllah

Using the sample project, flash works for me on Android 11.

The above code does not show how it is trying to turn the flash on or off.

See this code for a working sample:

https://github.com/journeyapps/zxing-android-embedded/blob/master/sample/src/main/java/example/zxing/CustomScannerActivity.java

rkistner avatar Oct 25 '21 13:10 rkistner

I am also faced the same issue i copied all code from this repository and created the new library with small change where flash light button is integrated in Barcodeview layout you can use from here repo

manumathew17 avatar Jun 15 '22 11:06 manumathew17