How to fix screen orientation to portrait for my whole PhoneGap app

Vinayak Bevinakatti picture Vinayak Bevinakatti · Sep 20, 2011 · Viewed 17.2k times · Source

How to configure the Phonegap app to be fixed to only portrait mode, I there any possibility to do it with CSS or JavaScript so that I should be able to get the consistent behaviour across the platforms

I found this useful post detecting-displays-orientation-change-on-mobile-devices-with-accelerometer-a-platform-indipendent-approach

Here it is explained how to detect the orientation, but I need to configure it

Is it possible through CSS3 Media queries?

Answer

Maulik J picture Maulik J · Sep 20, 2011

To fix your orientation in portrait mode just add the below line in your activity tag in AndroidManifest.xml file:

 android:screenOrientation="portrait"

or this in the activity class:

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);