Search code examples
cordovaintel-xdk

Intel XDK - Lock screen orientation


I want to lock screen orientation to portrait on my Standard HTML5 app, made in Intel XDK. Cordova has a plugin for this, but can it be done in a Standard HTML5 project?

All I have found is this, but it seems that intel.xdk.device is retired and don't work anymore:

intel.xdk.device.setRotateOrientation('portrait');

Solution

  • Rasmus -- the orientation API you are referencing (intel.xdk.device.setRotateOrientation) has been retired. There is a standard Cordova plugin you should use, instead. However, you need to convert your standard HTML5 project to a Cordova project and make sure to add a reference to cordova.js in your index.html. Generally, it's easier to:

    • start with a new blank "HTML5+Cordova" template
    • copy your source files into that new project
    • add the core Cordova "screen orientation" plugin

    Select the "documentation link" on the plugin management page for that plugin to find the API docs for the plugin. That is, when you are viewing the description of that plugin, in the XDK plugin manager, click the "documentation" link to get to the description of that plugin's API.