5

I have an application that supports back to Android API 19 (KitKat) and there is heavy Camera use internally.

Currently, android.hardware.camera2 is the recommended way of using the camera API and android.hardware.Camera is deprecated.

Is there a way to support API 19 and stop using android.hardware.Camera without getting deprecation warnings in my build? If so, how?

The only other question I could find was this but it doesn't answer my question.

Community
  • 1
  • 1
bjohnson
  • 301
  • 5
  • 15

1 Answers1

6

you would use

if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    //use old camera API
}else{
    //use new camera API
}

then you can support what you want

tyczj
  • 71,600
  • 54
  • 194
  • 296
  • I was aware of this method but will this eliminate the build warnings I see from Lint in Gradle? – bjohnson Jul 28 '15 at 18:52
  • 1
    no it will not, nothing will if you want to support lower version, the only thing you can do it use `@SuppressWarnings( "deprecation" )` to suppress it – tyczj Jul 28 '15 at 18:55