Android : Is it possible to lock an android app in portait mode only on phones with cordova?

on Tuesday, September 23, 2014


I would like my app to support only the following orientations:



  • On phones: portrait or reverse-portrait

  • On tablets: portrait, reverse-portrait, landscape, reverse-landscape


I am finding a lot of information about how to do this in an Android application, but not in a cordova application. Is there no way to do this without having to modify the Java code?


I have already solved this problem on iOS by adding the following to my project's plist file:



<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>


The plist file is created by cordova and it's an xml file, so it's easy to make a script that adds these configurations every time I build.


But on Android, there seems to be only one property for this in AndroidManifest.xml which applies to both phones and tablets. What is the cordova way of doing this?


0 comments:

Post a Comment