How do you create landscape orientation for mobile applications created with cordova-cli?

I use cordova cli to build my application. I want to target both Android and ios (maybe more).

As I want this to be true for all platforms, I was hoping I could simply define this as a preference in the config.xml file as follows:

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

because this is apparently how it works in the phonegap assembly https://build.phonegap.com/docs/config-xml

I assume that the functions supported in the config.xml file using the phonegap assembly are different from the cordova-cli functions?

I know that I can force it to be inserted android:screenOrientation="landscape"into my AndroidManifest.xml in an Android application , but that’s not good, because it will be rewritten the next time I execute cordova build.

Any suggestions?

+5
source share
2 answers

Simply put, it is not possible to set the orientation using element preferencec www/config.xml. After checking the cordova-cli code, it appears that AndroidManifest.xmlonly the version package and input class package are updated in the package .

For a list of supported settings, see Cordoba .

Added configurations to the file AndroidManifest.xmlshould not be lost on cordova build, unless the configuration parameter is pulled out from another place (for example, version).

+4
+10

All Articles