Relative Content

Tag Archive for androidandroid-camerakotlin-coroutinesandroid-camera2android-camerax

Cancelling ListenableFuture returned from ProcessCameraProvider.getInstance(context) call

According to the documentation of ProcessCameraProvider https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getInstance(android.content.Context) the call to getInstance(context) returns a ListenableFuture<ProcessCameraProvider> and the cancellation of this future is no-op. But if you cancel this future and try to call the ProcessCameraProvider.getInstance(context) again, it would return the ListenableFuture that is already canceled (it happens for all subsequent calls to this method). Is this how it really should be? If so, how should I handle the cancellation of a coroutine in which ProcessCameraProvider.getInstance(context) is called?