Search code examples
androidcordovaphonegap-cli

Trying to understand how Phonegap/Cordova's config.xml gets included in the build


I'm working on a Phonegap app and have two simple requirements:

  1. Lock app orientation to portrait
  2. Prevent the device keyboard from changing the height of the window on Android

From what I've found, there are two preferences that can be added to the root config.xml file to enable these properties:

<preference name="orientation" value="portrait" />
<preference name="android-windowSoftInputMode" value="adjustNothing" />

However, I can't get either behavior to manifest no matter how I run the app; the browser allows landscape, and both the Phonegap Developer app and the compiled apk show landscape and height changes.

How do I ensure the changes in the config.xml get reflected in the builds? Are there any peculiarities with phonegap serve/build I should know about regarding this?

EDIT: It seems like the changes not being reflected was a weird quirk. Building again, the preferences work exactly as they should.


Solution

  • The config settings in config.xml will be reflected in the build once you build the platform. In case of Android, executing cordova build android will reflect the changes in AndroidManifest.xml Also platform specific preferences should be placed inside respective platform tags. Eg: <platform name="android"> <allow-intent href="market:*" /> </platform>

    And also i m not sure about adjustNothing value for android-windowSoftInputMode property as i dont see such value in the official documentation - https://developer.android.com/guide/topics/manifest/activity-element.html#wsoft Guess you gotta use adjustPan