I am writing the code that we use to implement the flash in custom camera.
First, we need Camera.Parameters object that we get from Camersa's getParameters() method.
Then by using Camera.Parameters's setFlashMode() method we can specify our requirement.
We can use either FLASH_MODE_ON, FLASH_MODE_OFF or FLASH_MODE_AUTO properties.
Below is the code:
private void setFlashOnOff(boolean flash) {
if (flash) {
Camera.Parameters params = mCamera.getParameters();
params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
mCamera.setParameters(params);
} else {
Camera.Parameters params = mCamera.getParameters();
params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
mCamera.setParameters(params);
}
}
0 Comment(s)