Java tutorial
//package com.java2s; //License from project: Apache License import java.util.List; import android.hardware.Camera; import android.hardware.Camera.Parameters; public class Main { public static Camera openFlightLight() { try { Camera camera = Camera.open(); if (null != camera) { Parameters parameters = camera.getParameters(); List<String> list = parameters.getSupportedFlashModes(); for (String string : list) { if (Parameters.FLASH_MODE_TORCH.equals(string)) { parameters.setFlashMode(string); camera.setParameters(parameters); camera.startPreview(); return camera; } } } } catch (Exception e) { } return null; } }