0

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?

fadden
  • 51,356
  • 5
  • 116
  • 166
Ilya Ilin
  • 2,283
  • 21
  • 27
  • 1
    depends on your needs (prolly you wana show some preview) so make a common interface inside PreviewFragmentImplBase then `if(API < 21) { usePreviewFragmentImplBase } else {usePreviewFragmenImpl22 }` ... – Selvin Nov 06 '15 at 10:39
  • android studio will not require to change version to 21 if I'll use this class? – Ilya Ilin Nov 06 '15 at 10:44
  • 1
    [which one?](http://developer.android.com/guide/topics/manifest/uses-sdk-element.html) or buildSDK? in gradle ... you can always build with the newest SDK version but you have to do checks if you are using newest API on old platform ... thats how the compat library is builded – Selvin Nov 06 '15 at 10:46
  • Thanks, you can add it as answer – Ilya Ilin Nov 06 '15 at 11:10

1 Answers1

0

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!

S A
  • 827
  • 10
  • 23