get Camera Best Focus Mode - Android Camera

Android examples for Camera:Camera Focus

Description

get Camera Best Focus Mode

Demo Code


//package com.java2s;

import android.hardware.Camera;

import android.os.Build;

import java.util.List;

public class Main {
    public static String getBestFocusMode(Camera.Parameters params) {
        if (params == null)
            return null;

        String focusMode = null;/* w  w  w  . j av a  2 s.  c o  m*/

        List<String> focusModes = params.getSupportedFocusModes();

        if (Build.VERSION.SDK_INT >= 14
                && focusModes
                        .contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
            params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
        } else if (Build.VERSION.SDK_INT >= 9
                && focusModes
                        .contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
            params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
        } else if (focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
            params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
        }

        return focusMode;
    }
}

Related Tutorials