I am using the following code to set orientation locking per user preference:
private void doLock(boolean locked) {
if (locked) {
int o = getRes
try with universal landscape orientation
private static final int ORIENTATION_90 = 1;
private static final int ORIENTATION_0 = 0;
private static final int ORIENTATION_180 = 2;
private static final int ORIENTATION_270 = 3;
switch (orientation)
{
default:
case ORIENTATION_0: // Portrait
//dostuff
break;
case ORIENTATION_90: // Landscape left
//do stuff
break;
case ORIENTATION_180: // Upside down.
//do stuff
break;
case ORIENTATION_270: // Landscape right
//do stuff
break;
}