I am using the following code to set orientation locking per user preference:
private void doLock(boolean locked) {
if (locked) {
int o = getRes
What you are describing is not a bug but rather the expected behavior from Android 2.2 or lower.
@forgivegod provided a theoretically correct approach, except that for Android 2.2 or lower the screenOrientation.reverseLandscape
and screenOrientation.reversePortrait
values are not recognized, even if faked (as @forgivegod's code does).
I bet you are seeing this problem when you rotate the phone clockwise (rotation=3) but not counter-clockwise (rotation=1).
Try with Android 2.3 or higher and see what happens.