Is there a way for the Android Manifest to be different depending on screen size? I want android:configChanges to not include “orientation” if the device is a tablet (ie xlarge screen size)
Moreover, I want android:screenOrientation to be different depending on which device is used. Any advice?
I know of no way to do something that complex in AndroidManifest.xml, however you can do it programmatically via
Activity.setRequestedOrientation()method. It’s easy enough to wrap this in a utility class and then query your environment accordingly. One word of warning though – if calling this method does actually result in an orientation change, your Activity’sonCreate()will be called a second time. Another thing that might come in handy if you choose to go this route, if the following evaluates to true:Then you are on a tablet device, or at least your layouts are being loaded from layout-large (if you have one). Puting it all together, the following would lock a tablet into landscape mode and phones into portrait mode: