How to check if camera supports auto-focus on Android with CameraX?

Viewed 374

Currently I'm using the CameraX library in my Android project. I'd like to decide programmatically if the given camera instance supports auto-focus. How can I get this info?

1 Answers

I could solve it by extending the CameraCharacteristics class in the following way:

import android.hardware.camera2.CameraCharacteristics

val CameraCharacteristics.hasAutoFocus: Boolean
  get() = get(CameraCharacteristics.CONTROL_MAX_REGIONS_AF) != 0
Related