Camera java.lang.RuntimeException: setParameters failed

痴心易碎 提交于 2019-12-03 23:37:05

Issue is caused by:

params.setPictureSize(1200, 900);

because required size is not suppoerted by Camera.

Use getSupportedPictureSizes to get all available preview sizes.

To check which is maximum picture size available from camera:

List<Size> allSizes = param.getSupportedPictureSizes();
Camera.Size size = allSizes.get(0); // get top size
for (int i = 0; i < allSizes.size(); i++) {
     if (allSizes.get(i).width > size.width)
       size = allSizes.get(i);
 }
//set max Picture Size
 params.setPictureSize(size.width, size.height);

Any Camera App is restricted by the Camera HAL supported for that device. So in Camera HAL we define that we will provide a list of supported size, these sizes could be preview size, picture size or video size. so I think you are facing this issue, because 1200*900 is not supported by camera HAL or lower level code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!