Intel XDK disables rotation

I made a simple application in Intel XDK. When I tested the application, I noticed that they activated the accelerometer.

For this application you need to have only 1 position. How to disable the accelerometer?

Thanks in advance.

+4
source share
4 answers

Inactive accelerometer, its device orientation must be corrected.

Call this API to fix the orientation: intel.xdk.device.setRotateOrientation(ORIENTATION);after intel.xdk.device.ready.

Full documentation here

Portrait :intel.xdk.device.setRotateOrientation("portrait");

Landscape :intel.xdk.device.setRotateOrientation("landscape");

Both :intel.xdk.device.setRotateOrientation("any");

The following is sample code:

<!DOCTYPE html>
<html>
<head>
    <title>XDK</title>
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0;" />

    <script src="intelxdk.js"></script>

    <script>
document.addEventListener("intel.xdk.device.ready", onDeviceReady, false);               
function onDeviceReady(){
    // set orientation
    intel.xdk.device.setRotateOrientation('landscape');
//    intel.xdk.device.setRotateOrientation('portrait');
//    intel.xdk.device.setRotateOrientation('any');

    intel.xdk.device.hideSplashScreen();   
}        
    </script>
    <style>
        body {font-family:arial;background-color:white}
    </style>    
</head>
<body> 
    <h1>Hello World</h1>
    <p>Locked to Landscape</p>
</body>
</html> 
+8
source

:

  • .

, . , .

+2

setRotateOrientation -Method:

, :

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

Android, iOS.

See: Documentation

+1
source

Easier to go to build settings → Platform → Orientation. It is very fast and easy.

0
source

Source: https://habr.com/ru/post/1532469/


All Articles