I have multiple use cases for lens, preview, focus etc
I know how to unbind it all cameraProvider?.unbindAll()
But, how to unbind only one use case. How to pass only focus to unbind ?
And how It knows, Which one to unbind if I pass cameraProvider?.unbind(imageCapture)
because there is no order and they are not assigned to any variable. So, I'm confused !
Each time I unbind all the screen will be reloaded. So, I need to somehow avoid that.
while trying so, I'm also getting this error
No supported surface combination is found for camera device - Id : 0. May be attempting to bind too many use cases.
But, how to unbind only one use case
You can unbind only one use case (or even two use cases) using ProcessCameraProvider.unbind()
which takes a variable number of arguments (varargs) of type UseCase
.
// Binding Preview and ImageCapture use cases
cameraProvider.bind(lifecycleOwner, cameraSelector, preview, imageCapture)
...
// Unbinding the ImageCapture use case
cameraProvider.unbind(imageCapture)
And how It knows, Which one to unbind if I pass cameraProvider?.unbind(imageCapture) because there is no order and they are not assigned to any variable. So, I'm confused !
CameraX doesn't need to explicitly know that you're unbinding an image capture use case for example. It unbinds a use case, which has a certain configuration, e.g. Surface, resolution, image format, etc. This translates to updating the camera capture session if necessary.
Each time I unbind all the screen will be reloaded. So, I need to somehow avoid that.
The glitch is probably caused by unbinding a repeating capture request, like preview.