set Camera Focus Mode - Android android.hardware

Android examples for android.hardware:Camera Focus

Description

set Camera Focus Mode

Demo Code

import java.util.List;

import android.hardware.Camera.Parameters;

public class Main {

  public static void setFocusMode(Parameters params, String value) {
    List<String> supported = params.getSupportedFocusModes();
    String supportedValue = getSupportedValue(supported, value);
    if (supportedValue == null) {
      return;/*  ww  w .j a va  2  s. c om*/
    }
    params.setFocusMode(supportedValue);
  }

  private static String getSupportedValue(List<String> supported, String value) {
    return (supported != null) && supported.contains(value) ? value : null;
  }
}

Related Tutorials