Reputation: 2414
I am wanting to listen for an orientation change in an activity. I've attempted some of the usual things,
onConfigurationChange
with orientation in the android:configChanges
element
in the manifest,getWindowManager().getDefaultDisplay().getRotation()
after a rotation unless I check it constantly in my draw thread, which is wasteful.OrientationEventListener
but this gets called for every degree change of the phone, which (imo) is also wasteful.I am trying to detect the difference from LandscapeLeft and LandscapeRight. I'm unsure how else to approach it at this point.
Upvotes: 0
Views: 757
Reputation: 121
I don't believe the OrientationEventListener
will necessarily tell you whether or not the screen's orientation has changed since it only returns the degrees.
Using getWindowManager().getDefaultDisplay().getRotation()
is probably the way to go, but you would have to know the device's default orientation since this will only tell you the rotation based on the default.
There's a decent blog about using the various sensors with orientation changes and the coordinate system here.
Upvotes: 2