Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android deprecated android.hardware.Camera and now recommend using android.hardware.camera2 but this is not available in anything below API 21

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.

like image 894
bjohnson Avatar asked Jul 28 '15 18:07

bjohnson


1 Answers

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

like image 197
tyczj Avatar answered Sep 22 '22 00:09

tyczj