I have an Activity, which needs its orientation to be locked with
setRequestedOrientation(screenOrientation);
But I want to get orientation updates, so that I can do adjustments to the UI(imagine HTC camera app, when only button’s icons change orientation).
So I found this class. It delivers orientation values, between 0 and 360. Ho do I filter this values, i.e. perfect interval [a, b], and if a<x<b then orientation is landscape or portrait? Compute mean? Any hints?
It sounds like you are needing code to only react when the device’s orientation has changed to one of the 4 normal orientations instead of at every angle. This will filter the orientation to only values of 0, 90, 180 and 270 degrees: