Вопрос

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.

Это было полезно?

Решение

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> 

Другие советы

That is possible do it the way next:

  1. Go the project properties.
  2. Build Settings
  3. Orientation

You select, landscape or portrait. If you emule the project, you see the changes.

use the setRotateOrientation-Method:

To lock the device in portrait mode, use:

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

Works on Android as well as iOS.

See: Documentation

Easier is to go to Build Settings -> Your Platform -> Orientation. That very fast and simple.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top