Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intel XDK disable rotation

I made a simple application in Intel XDK. When I was testing the application I noticed that they enabled the accelerometer.

For this application it's needed to have only 1 position. How can I disable the accelerometer?

Thanks in advance.

like image 471
user3428833 Avatar asked Dec 20 '22 16:12

user3428833


1 Answers

Its not accelerometer that is causing, its the device orientation that needs to fixed.

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

Full documentation is here

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

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

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

Below 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> 
like image 123
krisrak Avatar answered Jan 05 '23 22:01

krisrak