79648482

Date: 2025-06-02 09:35:20
Score: 0.5
Natty:
Report link

I temporarely fixed my issue by stopping the preview before releasing the camera :

private void stopPreview() {
    if (camera != null) {
        try {
            // Stop preview first
            camera.stopPreview();
            // Detach preview display (optional but safer)
            camera.setPreviewCallback(null);
            camera.setPreviewDisplay(null);
        } catch (Exception e) {
            Log.w("CameraRelease", "Error while stopping preview: " + e.getMessage());
        }

        // Finally release the camera
        camera.release();
        camera = null;
        
        inPreview = false;
        cameraReleased = true;
        onAutofocus = false;
    }
}

Finally, i migrated all camera.Hardware usages to CameraX

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: azaLiza