For my project requirement, I am using Google's camera2 api basic example and I don't want to restart my activity on orientation change. But, while doing this I face an issue that If i change my view from portrait to landscape mode camera preview is not redrawn and aspects of portrait are applied in landscape mode. Due to this when i capture image, Camera captures larger image then what is shown on preview in landscape mode.
Reproduction steps :
Pre condition :
Handle onOrientationChange
in manifest file for the activity.
Steps:
1. Open camera in portrait mode and then rotate to landscape mode
2. Capture image
For this, I called closeCamera()
and then openCamera()
in onConfigurationChanged()
but it is not a good solution beacuse it takes a lot of time to recreate everything. Is there any way I can redraw the preview surface ?