is Camera Flash Supported - Android Camera

Android examples for Camera:Camera Flash

Description

is Camera Flash Supported

Demo Code


//package com.java2s;
import android.hardware.Camera;
import java.util.List;

public class Main {
    public static boolean isFlashSupported(Camera camera) {
        /* Credits: Top answer at http://stackoverflow.com/a/19599365/868173 */
        if (camera != null) {
            Camera.Parameters parameters = camera.getParameters();

            if (parameters.getFlashMode() == null) {
                return false;
            }//from w w w . j a  v  a 2  s.co m

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

Related Tutorials