Search code examples
androidandroid-cameraandroid-orientation

The result from getRotation is not precise in Android


Nexus 4.

I specially use System.out.println to print out the rotation on LogCat, to observe the value when I rotate my device.

int orientation_photo = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
System.out.println("For Debug: orientation_photo: " + orientation_photo);

The rotation (0, 1, 2 or 4) is not prcise at all. Sometimes I have rotated 90 degrees, but the rotation value does not change.

However, believe Nexus 4 device can detect it correctly, from the orientation performance of its default camera, which always record a correct orientation, so that we can view pictures in a correct way.

I need a correct rotation value, so that I could put in ExifInterface of the photo .jpg file. Any help?


Solution

  • I think I find the answer, that is: Yes, it is not precise, from the basic physical principle, because the orientation is subjective.