check if you can Disable Camera Shutter - Android Camera

Android examples for Camera:Camera Feature

Description

check if you can Disable Camera Shutter

Demo Code


//package com.java2s;

import android.hardware.Camera;
import android.os.Build;
import android.util.Log;

public class Main {
    private static final String TAG = "";
    private static int cameraNumber = -1;

    public static boolean canDisableShutter(int id) {
        // cameraInfo.canDisableShutterSound is only available for API 17 and newer
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            Camera.CameraInfo cameraInfo = getCameraInfo(id);
            return cameraInfo != null && cameraInfo.canDisableShutterSound;
        } else {//from w w  w.j  a  va  2  s.c  o  m
            Log.d(TAG, "SDK does not support disabling shutter sound");
            return false;
        }
    }

    public static Camera.CameraInfo getCameraInfo(int id) {
        if (id >= 0 && id < getCameraNumber()) {
            Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
            Camera.getCameraInfo(id, cameraInfo);
            return cameraInfo;
        }
        return null;
    }

    public static int getCameraNumber() {
        if (cameraNumber == -1) {
            cameraNumber = Camera.getNumberOfCameras();
        }
        return cameraNumber;
    }
}

Related Tutorials