PhoneGap - Forcing Landscape orientation

Solution 1:

Have you tried this?

android:screenOrientation="portrait"

Inside the AndroidManifest.xml file, where you have declared your activity, just add the above line.

For example:

<activity
            android:name=".Activity.SplashScreenActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait">
            <intent-filter>
                <action
                    android:name="android.intent.action.MAIN" />
                <category
                    android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

Solution 2:

The correct way to do this for all devices is to configure config.xml

<preference name="orientation" value="portrait" />

<preference name="orientation" value="landscape" />

https://build.phonegap.com/docs/config-xml

Solution 3:

It is very simple, you need to add android:screenOrientation="landscape" in your AndroidManifest.xml file.

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".LogUploaderActivity" android:label="Log Uploader" android:screenOrientation="landscape" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Solution 4:

Please try this in your activity. Inside onCreate() and before setContentView.

// keeps the screen orientation in Landscape mode
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

Solution 5:

Maybe important to mention because i did not know it:

If you use the online phonegap apk converter with hydration enabled to your application, u'll have to rebuild your app completly instead of just update it. This will help you also with preferences like "orientation" or "fullscreen" !