安卓:检查摄像头是否支持自动对焦? [英] Android: Check whether camera supports auto-focus?

查看:712
本文介绍了安卓:检查摄像头是否支持自动对焦?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关Android的API版本2.1及更高版本,我们可以使用上下文:

  getPackageManager()。hasSystemFeature(PackageManager.FEATURE_CAMERA_AUTOFOCUS)
 

不过2.1版本之前,我们怎么能执行相同的操作?有没有这样的事,不涉及调用 Camera.open 然后 getParameters

解决方案

 名单,其中,字符串> supportedFocusModes = camera.getParameters()getSupportedFocusModes()。
布尔hasAutoFocus = supportedFocusModes = NULL和放大器;!&安培; supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)
 

For the Android API version 2.1 and higher, we can use context:

getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_AUTOFOCUS)

But before version 2.1, how can we perform the same operation? Is there anything like this that does not involve invoking Camera.open and then getParameters?

解决方案

List<String> supportedFocusModes = camera.getParameters().getSupportedFocusModes();
boolean hasAutoFocus = supportedFocusModes != null && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)

这篇关于安卓:检查摄像头是否支持自动对焦?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆