title: How to use the camera Flash light as torch?
body: <p>The following is my code to enable Flashlight in Android. In a Toast message it returned the following parameters: auto, on, off, torch. After setting the parameters to FLASH_MODE_TORCH, the torch is not enabling for me. My Manifest permissions are:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.CAMERA"&gt;&lt;/uses-permission&gt;
      &lt;permission android:name="android.permission.FLASHLIGHT"
         android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
         android:protectionLevel="normal"/&gt;
      &lt;uses-feature android:name="android.hardware.camera"&gt;&lt;/uses-feature&gt;
  </code></pre>
  
  <p>My Code:   </p>
  
  <pre><code> public class CameraFlashActivity extends Activity {
          /** Called when the activity is first created. */
          public Camera mCamera;
          Parameters cameraParameters;
          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.main);
              boolean cameraPresnt = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
             if( cameraPresnt == true)
             {
                 Toast.makeText(getApplicationContext(),"Flash is there",10).show();
                 if(mCamera==null)
                 {
  
                   try {
                      mCamera = Camera.open();
                      mCamera.startPreview();
                   Toast.makeText(getApplicationContext(),"Camera is  present",10).show();
                    } catch (Exception e) {
                      Log.i("CameraFlashActivity", "Camera.open() failed: " + e.getMessage());
                    }
                     if(mCamera==null)
                     {
                         Toast.makeText(getApplicationContext(),"Camera object is null",10).show();
                     }
                     else
                     {
                 cameraParameters = mCamera.getParameters();
                 if(cameraParameters==null)
                 {
                     Toast.makeText(getApplicationContext(),"No camera parameters",10).show();
                 }
                 else
                 {
                     List&lt;String&gt; flashmodes = cameraParameters.getSupportedFlashModes();
                     String supportedFlashModes = cameraParameters.getFlashMode();
                     Toast.makeText(getApplicationContext(),flashmodes.toString(),10).show();
                     Toast.makeText(getApplicationContext(),supportedFlashModes,10).show();
                     cameraParameters.setFlashMode(Parameters.FLASH_MODE_ON);
                     mCamera.setParameters(cameraParameters);
                     String supportFlashModes = cameraParameters.getFlashMode();
                     Toast.makeText(getApplicationContext(),supportFlashModes,10).show();
                     Toast.makeText(getApplicationContext(),"Camera parameters are set on flash light",10).show();
  
                 }
                     }
                 }
                 else
                 {
  
                 }
             }
             else
             {
                 Toast.makeText(getApplicationContext(),"Flash is not  there",10).show();
             }
          }
          public void onDestroy() {
              super.onDestroy();
              if (mCamera != null) {
                  cameraParameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
                     mCamera.setParameters(cameraParameters);
                     mCamera.stopPreview();
                mCamera.release();
              }
              Log.i("cameraFlashLight", "onDestroy");
            }
      }
  </code></pre>