I have the following piece of code in my app to get screen width and height:
screenHeight = (short) Activity.getWindow().getWindowManager().getDefaultDisplay().getHeight();
screenWidth = (short) Activity.getWindow().getWindowManager().getDefaultDisplay().getWidth();
And in the AndroidManifest, I have:
<activity
android:name="com.test.MyActivity"
android:configChanges="keyboardHidden|orientation"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
</activity>
Now, for a device with screen resolution 1280x700, I expect the screenWidth variable to always have the value 1280 and the screenHeight to be 700. This is regardless of how the user may be holding the phone.
But still, sometimes I get screenWidth equal to 700 and height equal to 1280. Why is that? Shouldn't my manifest file enforce the orientation of my app to always remain landscape?