Turn On flash - Android Camera

Android examples for Camera:Camera Flash

Description

Turn On flash

Demo Code


//package com.java2s;

import android.hardware.Camera;
import android.hardware.Camera.Parameters;

public class Main {
    public static Camera camera;
    public static boolean isFlashOn;
    public static Parameters params;

    /**//from  w  w w.ja  v a  2 s. c om
     * Turn On flash ?
     */
    public static void turnOnFlash() {
        if (!isFlashOn) {
            if (camera == null || params == null) {
                return;
            }
            params.setFlashMode(Parameters.FLASH_MODE_TORCH);
            camera.setParameters(params);
            isFlashOn = true;
        }
    }
}

Related Tutorials