Question

My Titanium Appceleartor(version 3.1.3) app has both portrait & landscape orientations. But in Android device, even when i enabled the "screen rotation" mode, my app renders in both orientation modes. How to prevent the App from rendering in landscape mode when device is "screenLocked"?

My TiApp.xml;

 <activity android:alwaysRetainTaskState="true"
           android:configChanges="keyboardHidden|Orientation"
           android:label="SampleApp" android:name=".SampleAppActivity">
                <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
 </activity>
Was it helpful?

Solution 3

Hi all thanks for the help. I have added these things already in my tiapp.xml. But still problem exists. I figured out that i have set OrientationMode property to all windows in my app, which should not be set because Android takes all 4 orientations by default. We don't need to specify it in code. So i removed this property & now everything works fine..

OTHER TIPS

you need to set protrait orientation to each activity tag

<activity android:alwaysRetainTaskState="true"
           android:configChanges="keyboardHidden|Orientation"
           android:screenOrientation="portrait"
           android:label="SampleApp" android:name=".SampleAppActivity">
                <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
</activity>

so i would suggest to use custom android manifest.

Copy your AndroidManifest.xml file from build/android folder and put it into the platform/android/ folder of your application. If folders are not present then create them. Now put a android:screenOrientation="portrait" in each activity tag like this:

<activity android:name="YourActivityName"
        android:label="YourActName" android:theme="@style/Theme.Titanium"
        android:configChanges="keyboardHidden|orientation"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity> 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top