titanium disable device rotation & fix so only one mode ever shown

titanium

Solution

Full-ish answer - this will STILL allow an orientation change when the loading screen starts up. Titanium seems to be holding this one close to their chest, but here goes:

in the tiap.xml file, you need to make changes to the first indentation-level android element

<android xmlns:android="http://schemas.android.com/apk/res/android">
    <manifest>
        <application>
            <activity
                android:configChanges="keyboardHidden|orientation"
                android:name="org.appcelerator.titanium.TiActivity" android:screenOrientation="portrait"/>
            <activity
                android:configChanges="keyboardHidden|orientation"
                android:name="org.appcelerator.titanium.TiTranslucentActivity"
                android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent"/>
            <activity
                android:configChanges="keyboardHidden|orientation"
                android:name="org.appcelerator.titanium.TiModalActivity"
                android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent"/>
            <activity
                android:configChanges="keyboardHidden|orientation"
                android:name="ti.modules.titanium.ui.TiTabActivity" android:screenOrientation="portrait"/>
            <activity
                android:name="ti.modules.titanium.ui.android.TiPreferencesActivity" android:screenOrientation="portrait"/>
        </application>
    </manifest>
</android>

the above code can be dropped in (remove the existing android element first, of course!) and should work.

The trick here is the use of

android:screenOrientation="portrait" 

which sets the orientation to portrait. The other option is 'landscape', of course. I think if you leve this out the the default behaviour is to allow the orientation to switch around.

iOS is, of course, easier.

In the same tiapp.xml file you need

<ios>
    <plist>
        <dict>
            <key>UISupportedInterfaceOrientations</key>
            <array>
                <string>UIInterfaceOrientationPortrait</string>
            </array>
        </dict>
    </plist>
</ios>

this will replace whatever is in your current ios element, and is at the same level as the android element

ie

<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
    ...
    <ios>
        ...
    </ios>
    <android>
        ...
    </android>
</ti:app>

I still don't know how to stop android (and possibly ios) from re-orienting the splash screen, if anybody knows how let me in on the secret!!!

Problem

how do i fix the device rotation in a titanium app across all mobile platforms? Any references to official doco would be super useful! so i don't want to so much "disable rotation" as "only ever let the app run in a particular orientation" (which in my case is portrait mode) cheers

Original source