Search code examples
androidapiandroid-cameraandroid-appcompatcamera2

Is it possible to use camera on < 21 and camera2 on 21+?


I would like to use camera2, because it have features that we want. But it's important to stay compatible with <21 API versions. So, I have CameraActivity and CameraController classes that using Camera. Is it possible to use android.hardware.Camera on old devices and android.hardware.camera2 on new?


Solution

  • Yes. You can use numerous SDK versions as you like.

        <uses-sdk android:minSdkVersion="integer"
              android:targetSdkVersion="integer"
              android:maxSdkVersion="integer" />
    

    Source

    edit: Credit to selvin also. While I was searching for this, he beat me to it!