Open zeusalmighty717 opened 2 years ago
I updated the latest WindowManager but I get: CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments/CameraFragment.kt: (49, 24): Unresolved reference: WindowManager CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments/CameraFragment.kt: (102, 41): Unresolved reference: WindowManager CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments/CameraFragment.kt: (205, 25): Unresolved reference: WindowManager
class androidx.window.WindowManager
might have been removed to avoid confusion with interface android.view.WindowManager
.
The suggested fix would be to obtain the aspect ratio with the WindowMetricsCalculator
:
// Get screen metrics used to setup camera for full screen resolution
val windowMetrics = WindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(requireActivity())
Log.d(TAG, "Screen metrics: ${windowMetrics.bounds.width()} x ${windowMetrics.bounds.height()}")
val screenAspectRatio = aspectRatio(windowMetrics.bounds.width(), windowMetrics.bounds.height())
Log.d(TAG, "Preview aspect ratio: $screenAspectRatio")
See this blog post: Unbundling the WindowManager.
When reporting the issue latest WindowManager available is
androidx.window:window:1.0.0