安卓:检查摄像头是否支持自动对焦?自动对焦、摄像头

2023-09-06 02:15:42 作者:妳~快到怀里來

有关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)
 
双模尚待新典范 摩托罗拉A1800近4K

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)