相机拍照时,遇到问题Method called after release()的解决方法

友盟上会出现bug   Method called after release();

报错在mCamera.takePicture(shutterCallback, rawCallback, jpegCallback);

而mCamera.release();执行是在

@Override
public void surfaceDestroyed(SurfaceHolder surfaceholder) {
if (isCameraRight) {
if (mCamera != null) {
try {
/* 停止预览 */
mCamera.stopPreview();
} catch (Exception e) {
e.printStackTrace();
}
}
mCamera.release();
mCamera = null;
}
}

网上的解决方法是在stoppreview和release之前加一句

mCamera.setPreviewCallback(null);


Installs a callback to be invoked for every preview frame in addition to displaying them on the screen. The callback will be repeatedly called for as long as preview is active. This method can be called at any time, even while preview is live. Any other preview callbacks are overridden.

Parameters: cb a callback object that receives a copy of each preview frame, or null to stop receiving callbacks.

你可能感兴趣的:(android)