Camera.getParameters().getSupportedPreviewSizes() 在模拟器中返回 NULL
我的相机和 Android 版本有问题。 我尝试获取 Android 相机流程支持的预览尺寸,如下所示:
@Override
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
mCamera = Camera.open();
mSupportedPreviewSizes = mCamera.getParameters()
.getSupportedPreviewSizes();
try {
mCamera.setPreviewDisplay(holder);
} catch (IOException exception) {
mCamera.release();
mCamera = null;
}
}
我尝试使用模拟器在 2 个 Android 版本上测试我的代码(Android 2.2 SDK && Android 2.1 SDK) 模拟器中两个版本 Android 的配置如下:
Skin : HVGA
Abstracted LCD density : 160
我的问题: 当我在模拟器 - 2.2 SDK 上运行我的应用程序时:好的 - 好 但是当我在 Emulator-2.1 SDK 上运行时:遇到问题“mCamera.getParameters().getSupportedPreviewSizes() 返回为 NULL”
如果您知道这一点,请帮助我! 非常非常非常感谢…………非常感谢……
I have a problem with Camera and Android Version.
I try to get preview size supported by Android Camera flow as below :
@Override
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
mCamera = Camera.open();
mSupportedPreviewSizes = mCamera.getParameters()
.getSupportedPreviewSizes();
try {
mCamera.setPreviewDisplay(holder);
} catch (IOException exception) {
mCamera.release();
mCamera = null;
}
}
I try to test my code on 2 Android Version with Emulator ( Android 2.2 SDK && Android 2.1 SDK )
Configuration for both of version Android in Emulator as below:
Skin : HVGA
Abstracted LCD density : 160
My problem :
When I run my Apps on Emulator - 2.2 SDK : OK -- GOOD
but when I run on Emulator - 2.1 SDK : have a problem " mCamera.getParameters().getSupportedPreviewSizes() return is NULL "
If you known that, please help me !
Thank you very very very ..........much....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这被谷歌列为缺陷,我认为这意味着有计划修复它:
http://code.google.com/p/android/issues/detail ?id=6271
我在一些运行 Android 4.0 版本的硬件设备上遇到过这种情况。到目前为止,我唯一能做的就是处理 getSupportedPreviewSizes() 返回 null 的情况。它并不总是发生在我身上,所以如果我检测到这种情况发生,我通常会销毁并重新实例化我的预览表面和相机。
This is listed as a defect by Google, which I assume means there are plans to fix it:
http://code.google.com/p/android/issues/detail?id=6271
I've experienced this on some hardware devices running android all the way up to 4.0. So far, the only thing I've been able to do is handle the case where getSupportedPreviewSizes() returns null. It doesn't always happen for me, so I'll normally destroy and re-instantiate my preview surface and camera if I detect this has happened.
您应该在 mCamera.unlock() 之前和 mCamera.lock() 之后调用 getSupportedPreviewSizes()
You should call getSupportedPreviewSizes() before mCamera.unlock() and after mCamera.lock()