Detecting phone orientation with sensor events
<p>I have an Activity, which needs its orientation to be locked with</p>

<pre><code>setRequestedOrientation(screenOrientation);
</code></pre>

<p>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 <a href="http://developer.android.com/reference/android/view/OrientationEventListener.html" rel="nofollow">this class</a>. It delivers orientation values, between 0 and 360. Ho do I filter this values, i.e. perfect interval <code>[a, b]</code>, and if <code>a&lt;x&lt;b</code> then orientaion is landscape or portrait? Compute mean? Any hints?</p>
