Android examples for Camera:Camera Flash
initialize Camera Flash
//package com.java2s; import android.hardware.Camera; import android.hardware.Camera.Parameters; public class Main { private static Camera camera = null; public static boolean initializeCameraFlash() { checkCamera();//from w w w . jav a2s . com if (camera != null) { final Parameters param = camera.getParameters(); param.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); try { camera.setParameters(param); camera.startPreview(); return true; } catch (final Exception e) { releaseCamera(); } } return false; } private static void checkCamera() { if (camera == null) camera = Camera.open(); } public static void releaseCamera() { if (camera != null) { camera.stopPreview(); camera.release(); camera = null; } } }