Reputation: 1384
I have an android app in which the screen orientation is set to portrait in manifest file. It uses a custom camera in b/w , to take a photo and I need to save the photo.
Before I save the image I have to rotate the image depending on how the user is holding the camera, so that the image gets saved in the right orientation.
So, is there any way by which I can get the device orientation even when my app is running in portrait mode and android "auto-rotation" feature is ON. How can I achieve this?
Upvotes: 4
Views: 257
Reputation: 1384
I am currently using android orientation sensor to solve this problem and its working perfectly. Till someone gives a better working method , am accepting this as answer for other who have the same question.
Upvotes: 0
Reputation: 23665
You should do the rotation depending on the orientation information within the image, not depending on the device orientation.
Here is some more information on how to determine the rotation.
Since this does not help, have you tried hackpod's answer here:
getResources().getConfiguration().orientation
Upvotes: 2
Reputation: 4837
To get current device orientation try this:
getWindowManager().getDefaultDisplay().getRotation();
Upvotes: 1
Reputation: 4702
Simply check, the height and width of the image. If the height is less than your width, it means the user was holding the phone horizontally, so you have to rotate it.
Upvotes: 0