can Disable Camera Shutter - Android android.hardware

Android examples for android.hardware:Camera

Description

can Disable Camera Shutter

Demo Code

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

public class Main {

  private static final String TAG = "CameraUtil";

  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 . co  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;
  }
  private static int cameraNumber = -1;
  public static int getCameraNumber() {
      if (cameraNumber == -1) {
          cameraNumber = Camera.getNumberOfCameras();
      }
      return cameraNumber;
  }

}

Related Tutorials