Hi everybody, 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:

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);
}

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.

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?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to