Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Regular Visitor
Posts: 1
Registered: ‎06-05-2013
My Device: Bold 9900
My Carrier: 3 HK

Turn on Camera flash while scanning barcode

I am using the BarcodeScanner component to scan barcodes. So far, everything works fine and the barcodes are successfully scanned and decoded.


Now, we would like to add the feature of turning on the camera flash by pressing a button while the barcode scanner is working. This would help in scanning 2d barcodes in dimly lit areas (one of our use cases is for check in to different venues, like a bar or dimly lit restaurant)


Below is the sample code

//decoder and barcodeDecoderListener are previously initialized, and scanning a barcode is successful


BarcodeScanner scanner = new BarcodeScanner( decoder, barcodeDecoderListener );


FlashControl flashControl = (FlashControl) scanner.getPlayer().getControl("javax.microedition.amms.control.camera.FlashControl");



But this does not turn on the flash. If I use the standard method to capture video (as in the demo app), then I can turn on the flash for video recording. But it does not work when using the BarcodeScanner component.


Any ideas? Or is it not possible when using the barcode scanner? Is it only possible when using the video camera recorder?


PS: I have also tried to instantiate a new camera player for recording in addition to the barcode scanner, but it seems only one component can open the camera at the same time.