In my camera app, the UI orientation is fixed to portrait.
the preview displayed correctly on both landscape and portrait by setting camera.setdisplayorientation(90).
I can take picture and save it to file.
when I display it by ImageView,
the picture that was taken in landscape orientation could display correctly.
(the top of phone in my left side)
But… the one that was taken in portrait orientation is not so lucky…
It looks like turn 90 degrees to left.
I try to detect the device orientation through sensor so that I can set the EXIF header,
but… so far…that too hard to achieve for me…does any one can help me to solve this problem?
Use the getRotation method:
From the documentation:
getRotation was introduced from Android 2.2. Use getOrientation if your target are older devices.
Got answer form here:
how to detect orientation of android device?
If you just want to detect orientation of the device then you can use an OrientationEventListener.
here’s the official docs:
http://developer.android.com/reference/android/view/OrientationEventListener.html#onOrientationChanged(int)
But before you use anything, check out this excellent blog post about orientation handling in android:
http://android-developers.blogspot.in/2010/09/one-screen-turn-deserves-another.html