Most smartphone buyers buy a phone to take advantage of these phones’ great camera capabilities. For example, the Galaxy S22 Ultra saw a huge demand among smartphone buyers because of its exceptional camera performance. And cameras are going to be one of the top reasons for a consumer to purchase a phone.
App developers, in order to use the camera capabilities in their apps, adopt Android’s Camera Framework. The first use case of the framework is to implement the camera preview to be displayed in the app. But as ambitious foldable devices like Samsung’s Galaxy Z Fold 4 are becoming increasingly popular, the camera preview screen may become stretched, upside-down, or incorrectly rotated. Often these make the app crash if used in a multi-window environment.
To fix all this, Google is setting some new guidelines with the new CameraViewfinder that will take care of all those details and provide a streamlined camera experience. As noted in the official blog, “CameraViewfinder is a new artifact from the Jetpack library that allows you to quickly implement camera previews with minimal effort.”
This CameraViewfinder employs either a TextureView or a SurfaceView, allowing the camera feed to adjust in accordance with the transformations. The transformations include the correct aspect ratio, scale, and rotation. Moreover, it is fully compatible with the Camera2 codebase.
For a complete step-by-step process to use the CameraViewfinder, you can visit here. The CameraViewfinder function is now ready to use across foldable phones, configuration changes, rotations, and multi-window modes. In fact, as noted in the blog, it has been tried and tested on many foldable devices.