Code example for Camera.Parameters

Methods: getFlashMode, getSupportedFlashModes, setFlashMode

0
    Parameters parameters = mCamera.getParameters();
    if (parameters == null) {
    	Log.d(TAG, "Y U NO HAVE CAMERA PARAMS!");
      return; 
    } 
    List<String> flashModes = parameters.getSupportedFlashModes();
    // Check if camera flash exists 
    if (flashModes == null) {
    	Log.d(TAG, "Y U NO HAVE FLASH!");
      return; 
    } 
    String flashMode = parameters.getFlashMode();
    Log.i(TAG, "Flash mode: " + flashMode);
    Log.i(TAG, "Flash modes: " + flashModes);
    if (!Parameters.FLASH_MODE_TORCH.equals(flashMode)) {
      // Turn on the flash 
      if (flashModes.contains(Parameters.FLASH_MODE_TORCH)) {
        parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
        mCamera.setParameters(parameters);
        startWakeLock(); 
      } else { 
        Log.e(TAG, "FLASH_MODE_TORCH not supported");
      }