Code example for Camera.Parameters

Methods: getFlashMode, getSupportedFlashModes, setFlashMode

0
        Parameters parameters = mCamera.getParameters();
        if (parameters == null) {
            Log.d(TAG, "Camera Params not Found!");
            return; 
        } 
        List<String> flashModes = parameters.getSupportedFlashModes();
        // Check if camera flash exists 
        if (flashModes == null) {
            Log.d(TAG, "Camera Flash not Found!");
            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");
            }