Android examples for Camera:Camera Flash
Attempts to set the camera's flash mode via reflection.
//package com.java2s; import java.lang.reflect.Method; import android.hardware.Camera; public class Main { /** Attempts to set the camera's flash mode. Returns true if successful, false if the Android API doesn't support setting flash modes. *///www.j a v a 2s .co m public static boolean setFlashMode(Camera camera, String mode) { Camera.Parameters params = camera.getParameters(); try { Method flashModeMethod = params.getClass().getMethod( "setFlashMode", String.class); flashModeMethod.invoke(params, mode); camera.setParameters(params); return true; } catch (Exception ignored) { return false; } } }