Android sensorLandscape

I am trying to make it so my app can be used in both left and right landscape orientations, but not in portrait orientation. I was able to do this before by removing the “Orientation” preference from config.xml and then manually adding ‘android:screenOrientation=“sensorLandscape”’ to AndroidManifest.xml.
Sometime since then I have updated both Cordova and Ionic and now that attribute always gets deleted whenever I build the app.

I got it to work fine on iOS by checking “Landscape Left” and “Landscape Right” in General settings on Xcode.

Any ideas how to achieve this for Android now?

I solved it with a hack i.e. by editing a Cordova file.


if (orientation && !this.helper.isDefaultOrientation(orientation)) {
act.attrib[‘android:screenOrientation’] = orientation;
} else {
//delete act.attrib[‘android:screenOrientation’]; //<-- MY CHANGE !!! I commented this line out !!!


Thanks for the idea! I took the some idea and edited a Cordova file. Except I changed the preferences.js file that parses the config.xml preferences. I added a global preference of ‘sensorLandscape’ to it.

I also edited ios_parser.js to add a ‘sensorLandscape’ case that does the same thing for iOS as the landscape preference already does, since that has the ‘LandscapeLeft’ and ‘LandscapeRight’ behavior that I want.

Now I can go into Cordova’s config.xml and add:

<preference name="Orientation" value="sensorLandscape"/>

Now both iOS and Android versions will use both landscape orientations but not portrait.