Reputation: 5384
How do I lock the orientation of my phonegap application to portrait?
My current config.xml
is using this preference:
<preference name="orientation" value="portrait"/>
However it makes no difference and I can still orientate my application in both orientations by rotating my mobile test device.
Also if you know of a an active phonegap/cordova community could you please post a link?
Upvotes: 3
Views: 2551
Reputation: 759
If you are working with Android you can add
android:screenOrientation="portrait"
to the main activity tag in the platforms/android/AndroidManifest.xml file.
So
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="inappbrowser" android:theme="@android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
becomes
<activity android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="inappbrowser" android:theme="@android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Just another note in case you want other portrait variations. From: http://developer.android.com/guide/topics/manifest/activity-element.html
You could use reversePortrait or sensorPortrait
Upvotes: 9