Prevent Screen Rotation in PhoneGap / Android

You may have an app at some point that requires a set screen orientation. Using PhoneGap in Android this is done by editing your project’s AndroidManifest.xml. This file is located in your project root. Double click the file to open it within Eclipse and note the activity node:

  

<application android:debuggable="false" android:hardwareAccelerated="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:logo="@drawable/ic_launcher">
   <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="app_name" android:screenOrientation="portrait">
      <intent-filter>
         <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
   </activity>
</application>

You can change highlighted code from above to

  

android:screenOrientation=”landscape”

in order to show only landscape…..

 

Enjoy

Sharief Mohatad

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s