Recently made a module about two-dimensional code parsing
Choose Google's Open source project Zxing
Add Flash features in zxing as follows:
In the Cameramanager class under the Com.xxx.xxx.Zxing.camera package
Add code:
Openlight is to turn on the flash
Offlight is to turn off the flash
public void Openlight () { if (camera! = null) { parameter = camera.getparameters (); Parameter.setflashmode (parameters.flash_mode_torch); Camera.setparameters (parameter); } } public void Offlight () { if (camera! = null) { parameter = camera.getparameters (); Parameter.setflashmode (Parameters.flash_mode_off); Camera.setparameters (parameter); }}
In the class where you need to call the Flash
Open Flash Cameramanager.get (). Openlight ();//Off Flash Cameramanager.get (). Offlight ();
The function of the flash is added in.
Hope to be useful to everyone
Android Zxing Add Flash function