title: Android - Camera2 : The easiest way to turn on the torch light
body: <p>The simplest way to turn on the torch light was :</p>
  
  <pre><code>Camera camera = Camera.open();
  Camera.Parameters parameters = camera.getParameters();
  parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
  camera.setParameters(parameters);
  camera.startPreview();
  </code></pre>
  
  <p>The simplest way to turn it off was :</p>
  
  <pre><code>Camera camera = Camera.open();
  Camera.Parameters parameters = camera.getParameters();
  parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
  camera.setParameters(parameters);
  camera.stopPreview();
  </code></pre>
  
  <p>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...</p>