title: Rebinding CameraX UseCases
body: <p>I am trying to stop/pause the camera <code>PreviewView</code> during image processing/detection using <code>Firebase MLKit</code>. To pause the preview I call</p>
  
  <pre><code>cameraProvider.unbind(previewUseCase)
  </code></pre>
  
  <p>That stops the preview on the last frame but now I dont know how to restart it. I tried just binding the preview again like this</p>
  
  <pre><code>cameraProvider.bindToLifecycle(lifecycleOwner, cameraSelector, preview)
  </code></pre>
  
  <p>But that causes the <code>PreviewView</code> to just show white like its gone and cant get it back ntil  restart the app.</p>
  
  <p>The same thing happens when I call <code>unbindAll()</code></p>
  
  <p>So my question is how do I pause the preview view and then restart it again at a later point?</p>
  
  <p>this is my code</p>
  
  <pre><code>fun setupCamera(windowManager: WindowManager, previewView: PreviewView){
  
      _cameraProvider = _cameraProviderFuture.get()
  
      _preview = Preview.Builder()
          .setTargetRotation(windowManager.defaultDisplay.rotation)
          .build()
  
      _preview.setSurfaceProvider(previewView.previewSurfaceProvider)
  
      _cameraSelector = CameraSelector.Builder()
          .requireLensFacing(_requiredCameraLens)
          .build()
  
      _imageAnalyzer = ImageAnalysis.Builder()
          .setTargetResolution(Size(_imageWidth, _imageHeight))
          .setBackpressureStrategy(_imageBackpressureStrategy)
          .build()
  
      _imageAnalyzer.setAnalyzer(_imageExecutor,_analyzer)
  
      startPreview()
  
      _cameraProvider.bindToLifecycle(_lifecycleOwner, _cameraSelector, _imageAnalyzer)
  }
  
  // Called after image processing has finished
  fun startPreview(){
      _cameraProvider.bindToLifecycle(_lifecycleOwner, _cameraSelector, _preview)
  }
  
  // Called when object is detected in an image
  fun stopPreview(){
      _cameraProvider.unbind(_preview)
  }
  </code></pre>