Search code examples
xamarin.formszxing

Use auto Flashlight while scanning QR Code with ZXing in Xamarin Forms


I am trying to scan a QR code with my xamarin forms app

I use the ZXing Package

I was able to turn the flashlight on the whole time with this:

            TimeSpan timespan = new TimeSpan(0, 0, 0, 0, 0);
            Device.StartTimer(timespan, () =>
            {
                scanner.Torch(true);
                return true;
            });
            var scanResult = await scanner.Scan(optionsCustom);
            return scanResult.Text;

Is there a way to turn the flashlight on only when needed?

or intercept the Volume Buttons to turn the Flashlight on and off manually


Solution

  • You can create custom overlay for your scanner with button that turns on/off the flashlight.