android.view.Display class provide a simple way to determine the phone orientation.
// Get display for detecting the phone orientation display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); // Get the orientation int orientation = display.getOrientation();
For my HTC Tattoo, i get
When the phone is vertical
orientation = 0
When the phone rotates 90 degrees in clockwise direction
orientation = 0
When the phone is inverted
orientation = 0
When the phone rotates 90 degrees in anti-clockwise direction
orientation = 1
Although the above method is simple, it can only detect 90 degrees anti-clockwise rotation.
Done =)
Reference: Android Snippets – Get Size and Orientation of the Screen
Why does it continue to say “no rotation” 3 out of the 4 rotations????
LikeLike
where did u get the output “no rotation”?
LikeLike