Java tutorial
//package com.java2s; //License from project: Open Source License 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. */ 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; } } }