I’m working on an Android app that shows a camera preview. Ideally I’d like the app to work in portrait mode, which means I need to deal with rotation of the camera preview image.
I only need to support API level 8 (Android version 2.2) and up, so I can use Camera.setDisplayOrientation to set the orientation, and the API docs for that method include a setDisplayOrientation function that does what I want. The only problem is that it uses the API Level 9 Camera.CameraInfo to get the orientation of the camera with respect to the device (presumably to deal with landscape vs portrait devices).
So is it safe to assume that I can do setDisplayOrientation(90) for all level 8 devices and just use CameraInfo.orientation for newer devices?
As a follow up for anyone else finding this – I didn’t find a definitive answer on this, so I did as I suggested above (setDisplayOrientation(90)) for 2.2 devices and released the app. It’s had about 70,000 downloads and no reports of the camera display being wrongly rotated by 90 degrees, so it looks like this is a reasonable solution.