Android: Check whether camera supports auto-focus?

user441316 picture user441316 · Dec 6, 2010 · Viewed 16.2k times · Source

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?

Answer

Elhanan Mishraky picture Elhanan Mishraky · Apr 24, 2014
List<String> supportedFocusModes = camera.getParameters().getSupportedFocusModes();
boolean hasAutoFocus = supportedFocusModes != null && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)