在调用takePicture方法时需要传入三个参数,分别是:
public void TakePicture() {
if (mCamera == null)
throw new NullPointerException("Camera is null,please check it");
Log.i(TAG, "CameraUtils takePicture in");
mCamera.takePicture(null, raw, jpeg);
Log.i(TAG, "CameraUtils takePicture out");
}
// 拍照瞬间调用
private Camera.ShutterCallback shutter = new Camera.ShutterCallback() {
@Override
public void onShutter() {
Log.d(TAG, "shutter");
}
};
// 获得没有压缩过的图片数据
private Camera.PictureCallback raw = new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera Camera) {
Log.d(TAG, "raw");
}
};
//创建jpeg图片回调数据对象
private Camera.PictureCallback jpeg = new Camera.PictureCallback() {
@Override
public void onPictureTaken(final byte[] data, Camera Camera) {}
第一个参数是拍照瞬间调用,大部分机型该参数传null,则拍照时不会有卡擦声。