The simplest way to turn on the torch light was :
Camera camera = Camera.open();
Camera.Parameters parameters = camera.getParameters();
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
camera.setParameters(parameters);
camera.startPreview();
The simplest way to turn it off was :
Camera camera = Camera.open();
Camera.Parameters parameters = camera.getParameters();
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
camera.setParameters(parameters);
camera.stopPreview();
But, as the Camera class is now deprecated, what is the easiest way to achieve the same result with the Camera2 class? I only found long and complicated solutions...
check the answer from Daniel Netzer here you just need to write 3 line to turn on torch