[英]setParameters Failed in Nexus 5 and Nexus 7
I have implemented custom camera in my app. 我在我的应用中实现了自定义相机。 It is working fine in all device except Nexus 5 and Nexus 7. In both devices, It is crashing with SetParameters failed on camera.
除了Nexus 5和Nexus 7之外,它在所有设备上都运行良好。在这两款设备中,相机上的SetParameters崩溃都会导致崩溃。 I have implemented custom camera with below code:
我用以下代码实现了自定义相机:
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
if (mCamera != null) {
Log.e(TAG, "surfaceChanged called");
Camera.Parameters parameters = mCamera.getParameters();
if (mSupportedPreviewSizes != null) {
mPreviewSize = getOptimalPreviewSize(mSupportedPreviewSizes, w,
h);
}
Log.e(TAG, "surfaceChanged : mPreviewSize height:"
+ mPreviewSize.height + " width: " + mPreviewSize.width);
parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
requestLayout();
mCamera.setParameters(parameters);
Log.e(TAG, "surfaceChanged called setParameters success");
}
}
I have found at many places comments that it is due to unsupported preview size but In my case, I am already taking it from supported preview sizes. 我在许多地方发现了评论,这是由于预览尺寸不受支持,但在我的情况下,我已经从支持的预览尺寸中获取了它。
I had the same issue with a Nexus tablet: the same code changing the preview size to another supported preview size worked on various tablets but not the nexus tablet I had. 我在Nexus平板电脑上遇到了同样的问题:相同的代码将预览大小更改为另一个支持的预览尺寸,适用于各种平板电脑,但不是我的nexus平板电脑。
In my case, the issue was that I had already started previewing before changing the preview size. 在我的情况下,问题是我在更改预览大小之前已经开始预览。 Changing the preview size before starting the preview size solved my issue.
在开始预览尺寸之前更改预览尺寸解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.