title: Torch / Flashlight app (android.hardware.camera is deprecated)
body: <p>I have a torch / flashlight app using this code</p>
  
  <p>Turn On</p>
  
  <pre><code>    params = camera.getParameters();
      params.setFlashMode(Parameters.FLASH_MODE_TORCH);
      camera.setParameters(params);
      camera.startPreview();
  </code></pre>
  
  <p>Turn Off</p>
  
  <pre><code>    params = camera.getParameters();
      params.setFlashMode(Parameters.FLASH_MODE_OFF);
      camera.setParameters(params);
      camera.stopPreview();
  </code></pre>
  
  <p>However now </p>
  
  <blockquote>
    <p><strong>android.hardware.Camera</strong> has been deprecated and It is advised to use the new <strong>camera2</strong> api instead.</p>
  </blockquote>
  
  <p>Any help on how I would use <code>camera2</code> to turn on/off the device's flashlight? </p>
  
  <p>Thank you for your help </p>