Interface upside-down on temporary lock orientation
<p>I'm having a problem with Android 2.2 and screen
orientation. I have checkbox on my interface that when checked, the
orientation must be locked on the current orientation, so I did the
following code:</p>

<pre><code>Activity a = (Activity) getContext();

if (isChecked) {
    if (getResources().getConfiguration().orientation == configuration.ORIENTATION_LANDSCAPE)
        a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
        a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else {
    a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
}
</code></pre>

<p>The problem with this is that if I turn upside down the device, my
screen will rotate to that, and when I click on my "lock orientation",
getResources().getConfiguration().orientation will return
SCREEN_ORIENTATION_PORTRAIT and my code will lock the orientation to
SCREEN_ORIENTATION_PORTRAIT and the interface will be upside-down.</p>

<p>I can see that on Gingerbread (http://developer.android.com/reference/
android/R.attr.html#screenOrientation), there is a reversePortait and
reverseLandscape to solve this, but I really need this code to run on
2.2, so is there anyway to set the screen to upside down? Or is there
any other way to lock the rotation? </p>
