- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all.
I'm using Cordova Screen Orientation Plugin for an iOS app.In my app-init.js file the code blocks below supposed to do the job. But it doesn't.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
intel.xdk.device.setRotateOrientation("landscape");
intel.xdk.device.setAutoRotate(false);
window.screen.lockOrientation('landscape-primary');
}
Also this node is added in the config.xml file : <preference name="Orientation" value="landscape" />
mayday.
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please do not use those old intel.xdk functions, they are not getting updated and are obsolete. Please see this FAQ > https://software.intel.com/en-us/xdk/faqs/cordova#app-orientation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok. Thanks for the info.
However I'm still wondering what is the solution.
The last line in the code block is Cordova Screen Orientation Plugin and it's not deprecated. But it doesan't work anyway.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This screen orientation plugin is the solution - https://github.com/gbenvenuti/cordova-plugin-screen-orientation
Many users have had luck with it. Where exactly is it failing?
If you are facing issues with iPad, create a plugin.xml as instructed in the first part of the FAQ.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Anusha Muthiah , Im also trying that solution can be seen in the codes. But the problem is, it's ok when opening the app but when i change the orientation it changes, doesn't prevent its state.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Ozgur, I just did an experiment with an Android device and the Debug tab, which is an easy way to experiment with the API to make sure you are using it correctly:
- add the plugin to a blank project
- configure your Android device for USB debugging (see https://software.intel.com/en-us/xdk/docs/configuring-your-windows-usb-android-debug-connection-for-the-intel-xdk)
- attach your Android device via USB and startup the Debug tab
- let the Debug tab build a custom debug module
- start a debug session with the Debug tab (once you have the custom module installed)
- go to the debug session command-line and experiment with the screen object.
For example, I was able to experiment with:
screen.lockOrientation("portrait-primary") screen.lockOrientation("portrait") ...etc... cordova.plugins.screenorientation.setOrientation("landscape-primary") cordova.plugins.screenorientation.setOrientation("landscape-secondary") ...etc...
The docs are not very good, but you can figure out what the APIs are by inspecting the files in the www directory in the github repo and by looking for the "clobbers" and "merges" statements inside the plugin.xml file.
Here's a sample of what part of my console debugging session looked like (this plugin fits part of its API into the window.screen object and the rest into window.cordova.plugins, so I was playing with both objects):
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Paul,
Have you tried to rotate your device and did the orientation change?
I'm using the plugin for an iOS App. Maybe there's a bug for the iOS version...
But there's a difference between your code and mine. I used:
window.screen.lockOrientation('landscape-primary');
You used :
cordova.plugins.screenorientation.setOrientation(
"landscape-primary"
);
Maybe it makes a difference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I used the lockOrientation function my device stayed locked. The setOrientation functions do not lock the screen.
There could be a bug in iOS, check the issues link in the github repo, I recall seeing some recent issues posted there, but I don't recall what they were about.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page