Is there a way to place values which defined in the Manifest such as Activity screenOrientation in a resource xml file?
For example, Activity screenOrientation attribute can have values such as "portrait", "landscape" etc'
Well, these values are constant once defined. If I want to have different values for phones and tablets, like "portrait" for phones, while on tables I want it to be "sensor" how can this be done? I don't want to set it in code.
At the end, these values are integer constants, and can be found here: https://developer.android.com/reference/android/content/pm/ActivityInfo
Therefore, I thought maybe I can define two files, integers.xml for phones and integers-w400dp.xml for large screens, then define an attribute like
<integer name="orientation">portrait</integer> //for phones in the integers.xml
<integer name="orientation">sensor</integer> //for tablets in the integers-w400dp.xml
Then in the manifest i can refer to them do like this:
android:screenOrientation="@integer/orientation" //This actually accepted with no error
However, the integer xml wouldn't accept "portrait" or "sensor" values and instead I must put their numeric values like this:
<integer name="orientation">1</integer> //For portrait
<integer name="orientation">4</integer> //For sensors
This I believe will work but I don't want to use hard coded values as they might change between api's level.
I've tried to add xmlns to the resource file (the same ns as in the manifest) but it didn't worked.
* Edited * At the bottom line, this question is about how to lock Activity to portrait on phones, while NOT to lock it on Tablets, but doing this from xml and not in code.
Any idea will be appreciated.