Android Camera Check hasFlash(Camera mCamera)

Here you can find the source of hasFlash(Camera mCamera)

Description

Check if this device has flash

License

Open Source License

Declaration

public static boolean hasFlash(Camera mCamera) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import android.hardware.Camera;

import java.util.List;

public class Main {
    /**//from w  w  w.  jav  a2s  . c  om
     * Check if this device has flash
     */
    public static boolean hasFlash(Camera mCamera) {
        if (mCamera == null) {
            return false;
        }

        Camera.Parameters parameters = mCamera.getParameters();

        if (parameters.getFlashMode() == null) {
            return false;
        }

        List<String> supportedFlashModes = parameters
                .getSupportedFlashModes();
        if (supportedFlashModes == null
                || supportedFlashModes.isEmpty()
                || supportedFlashModes.size() == 1
                && supportedFlashModes.get(0).equals(
                        Camera.Parameters.FLASH_MODE_OFF)) {
            return false;
        }

        return true;
    }
}

Related

  1. checkCameraHardware(Context context)
  2. checkCameraHardware(Context context)
  3. checkFrontCamera(Context context)
  4. deviceHasCamera(Context context)
  5. sizeSupported(Camera.Parameters cp, CamcorderProfile profile)
  6. findBestPreviewSizeValue( Camera.Parameters parameters, Point screenResolution)