I am trying to setup activity screen orientation with values from XML file in res/values. I would like to do that because, more or less, I need same Activity for both tablet
Same problem for me with your second exlanation and I used a workaround by code which you aren't looking for.
I added 4 values folders under res folder. "values", "values-v11", "values-v14" and "values-sw720dp"
All values folders have "integers.xml".
"values" and "values-v14" have value 1 which is portrait orientation;
.
"values-v11" and "values-sw720dp" have value 2 which is user orientation;
.
And in Manifest file, activity has a property like;
android:screenOrientation="@integer/portrait_if_not_tablet"
.
All "values", "values-v11", "values-v14" are working as expected but "values-sw720dp"!
While debugging I realized that value of portrait_if_not_tablet comes as expected on a sw720dp device(with API 16) with getResources().getInteger(R.integer.portrait_if_not_tablet) but when i checked the value of current orientation by getRequestedOrientation() I got a different value.
int requestedOrientation = getResources().getInteger(R.integer.portrait_if_not_tablet);
int currentOrientation = getRequestedOrientation();
if (currentOrientation != requestedOrientation) {
setRequestedOrientation(requestedOrientation);
}
So I used a code block on onCreate method of my activities to solve this.