You can lock the orientation mode for Android in Titanium by successfully implementing the following steps :
By following the below steps you can lock the orientation mode throughout the app.
1) Create a custom AndroidManifest.xml (copy this from original generated source
"build/android/AndroidManifest.xml")
2) Copy this on the created folder "platform/android/AndroidManifest.xml" at the top level of your project.(Inside your project root)
3) Add this: android:screenOrientation="portrait" to all activities
4) Remove this: "|orientation" from all activities.
Here is my AndroidManifest.xml.
Here you can download the complete working project from my Github account
Titanium-Android-Orientation
By following the below steps you can lock the orientation mode throughout the app.
1) Create a custom AndroidManifest.xml (copy this from original generated source
"build/android/AndroidManifest.xml")
2) Copy this on the created folder "platform/android/AndroidManifest.xml" at the top level of your project.(Inside your project root)
![]() |
Locking Android Orientation Mode |
3) Add this: android:screenOrientation="portrait" to all activities
4) Remove this: "|orientation" from all activities.
Here is my AndroidManifest.xml.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.test.AndroidOrientation" android:versionCode="1" | |
android:versionName="1"> | |
<uses-sdk android:minSdkVersion="8" /> | |
<!-- TI_MANIFEST --> | |
<application android:icon="@drawable/appicon" | |
android:label="AndroidOrientation" android:name="AndroidorientationApplication" | |
android:debuggable="false"> | |
<!-- TI_APPLICATION --> | |
<activity android:name=".AndroidorientationActivity" | |
android:label="AndroidOrientation" android:theme="@style/Theme.Titanium" | |
android:configChanges="keyboardHidden" android:screenOrientation="portrait"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> | |
<activity android:name="org.appcelerator.titanium.TiActivity" | |
android:configChanges="keyboardHidden" android:screenOrientation="portrait" /> | |
<activity android:name="org.appcelerator.titanium.TiTranslucentActivity" | |
android:configChanges="keyboardHidden" android:screenOrientation="portrait" | |
android:theme="@android:style/Theme.Translucent" /> | |
<activity android:name="org.appcelerator.titanium.TiModalActivity" | |
android:configChanges="keyboardHidden" android:screenOrientation="portrait" | |
android:theme="@android:style/Theme.Translucent" /> | |
<activity android:name="ti.modules.titanium.ui.TiTabActivity" | |
android:configChanges="keyboardHidden" android:screenOrientation="portrait" /> | |
<activity android:name="ti.modules.titanium.ui.android.TiPreferencesActivity" /> | |
<service android:name="org.appcelerator.titanium.analytics.TiAnalyticsService" | |
android:exported="false" android:screenOrientation="portrait" /> | |
</application> | |
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | |
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/> | |
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | |
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> | |
<uses-permission android:name="android.permission.INTERNET"/> | |
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> | |
</manifest> |
Yes ...This is used by me and it's Working
ReplyDeleteThanks! It works perfectly!
ReplyDeleteIn android, how lock the screen for smaller screen but in bigger screen it have to work on both orientation like portrait and landscape. But in small screen it have to work on only portrait. Please suggest me.
ReplyDelete