2

I was recently trying to develop a flashlight application using the older Camera API. I get the Camera object by

camera = Camera.open();
p = camera.getParameters();

This is enclosed in try-catch block.The code I am using to turn on camera flash is

p.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(p);

This code given in try-catch block to handle exceptions and whether device support FLASH_MODE_TORCH is also checked. The code I am using to turn off camera flash is

p.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(p);

This is also enclosed in try-catch block and the Camera object camera and Parameter object p are also defined correctly. My question is that do I need to "necessarily" use camera.startPreview() and camera.stopPreview() methods after setting camera parameters while turning on and turning off the flash light.?

Vivek Sasidharan
  • 1,265
  • 3
  • 17
  • 34

0 Answers0