Trying to set orientation in manifest file, using a string qualifier
android:screenOrientation="@string/orientation"
Works on an 4.0 asus tablet, but fails on both a 2.1 wildfire and 4.1 Galaxy S. The problem is infact linking to a resource, If portrait is typed in it works.
Ive tried changing the qualifiers used in the tablet to test on the phone. This means the exact same code, resources and layouts are used for all devices. So it cant be spelling mistakes or build issues. But it still fails on the phones and not the tablet. This seems to be yet another bug in android.
Gives the error below, nothing in logcat
Installation error: INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION
Please check logcat output for more details.
Launch canceled!
Manifest section
<activity
android:name=".MainActivity"
android:screenOrientation="@string/orientation"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I know I can do it programatically. But theres another issue with the wildfire, not restarting immediately. Instead it waits for views to be setup etc. This doesnt occur in the other devices.
Googled and found a few others using the methods, but they dont seem to have discovered any problems. http://capdroid.wordpress.com/2012/07/21/different-screen-orientation-on-different-screen-size
Thanks
Trying to set orientation in manifest file, using a string qualifier
While it is a string when you type it into your editor, AFAIK it is actually stored as an integer in the system, and therefore the conversion from a string resource is unlikely to be reliable. Frankly, I'm surprised it works on that one tablet -- the device manufacturer may have added support for this to handle one of their own apps.
While you can use string resources in the manifest, they need to be things that will be stored as strings (e.g., android:label
).
You might be able to get this to work with an integer resource, looking up the values used for those constants (probably the same as their Java equivalents).
This seems to be yet another bug in android.
To me, this seems to be yet another place where a developer is going beyond the bounds of documented behavior, then wondering why the undocumented behavior does not work.