I am building a custom camera app. To make it look good, I have to adjust the camera preview dimensions based on the device's supported aspect ratio. I searched on google and stackoverflow but couldn't find the solution I'm looking for. Please help me.
What I've tried :
There is an API method getSupportedPreviewSizes that returns a list of supported camera preview sizes. I tried using the getOptimalPreviewSize method suggested in this post but it's not returning the best preview size (or) aspect ratio.
My device details :
Honor Holy mobile phone with android 4.4.2.
Screen dimensions : 1280 X 720
Correct aspect ratio : 4/3
But here's the twist. If I click a picture from my camera app and open it in the gallery app, the imageview scales automatically to the correct 4/3 aspect ratio. How does the android system detect this aspect ratio for the device? How can I also get it? If I can get the best aspect ratio for the device, I can resize my camera preview to look good.