I'm working on Ionic/Cordova, I added this to androidManifest.xml
but this didn't work for me and app is still showing in both ways
android:screenOrientation="portrait"
How can I restrict my app to portrait mode only? I have checked on android and it doesn't work
Ionic v2+ Update
For Ionic versions 2 and later, you will need to also install the corresponding Ionic Native package for any plugin you use, including
cordova-plugin-
andphonegap-plugin-
plugins.Install Ionic Native Plugin
Install Ionic Native's TypeScript module for the plugin from the CLI.
* Note that the
--save
command is optional and can be omitted if you do not wish to add the plugin to yourpackage.json
fileImport
ScreenOrientation
PluginImport plugin into your
controller
, more details available in the documentation.Do Your Thing
Lock and unlock the screen orientation programatically.
Bonus Points
You can also get the current orientation.
If you want to restrict to portrait mode only on all devices you should add this line to the config.xml in your projects root folder.
After that, please rebuild the platform by typing below text in command line: