setParameters失败的Nexus 5和Nexus 7 [英] setParameters Failed in Nexus 5 and Nexus 7
问题描述
我在我的应用程序实现的自定义相机。它在所有的设备,除了Nexus 5和Nexus 7,做工精细在这两个设备,它与崩溃失败SetParameters相机。我已实施的自定义相机跌破code:
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. 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");
}
}
我在很多地方发现评论说,这是由于不支持preVIEW大小,但就我而言,我已经从支持preVIEW大小服用。
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.
推荐答案
我有一台Nexus平板电脑相同的问题:在同一code更改preVIEW大小到另一个支持preVIEW大小制作各种平板电脑而不是平板电脑的Nexus我了。
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.
在我的情况下,这个问题,我已经改变了preVIEW大小之前已经开始previewing。启动preVIEW大小解决了我的问题之前,改变preVIEW大小。
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.
这篇关于setParameters失败的Nexus 5和Nexus 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!