DavidAndroidDev
DavidAndroidDev

Reputation: 2414

Listen for orientation change when screenOrientation="sensorLandscape"

I am wanting to listen for an orientation change in an activity. I've attempted some of the usual things,

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

Answers (1)

Rich B
Rich B

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

Related Questions