This method will asynchronously acquire the device's acceleration repeatedly at a given interval

var watchID = intel.xdk.accelerometer.watchAcceleration(accelerometerSuccess,accelerometerOptions);


This method will asynchronously acquire the acceleration repeatedly at a given interval. The acceleration options parameter is looking for a javascript object with two properties: ".frequency" which changes that millisecond interval for refresh and has a default of 500 and ".adjustForRotation" which changes the values of the .x and .y parameter based on the device orientation. The success function callback is triggered each time data is available. Successful data is returned as an object with the attributes “.x”, “.y”, and “.z”. This method returns a watch timer object to be cleared with clearWatch.

Available Platforms:


  • accelerometerSuccess: A function executed when the method successfully detects an accelerometer change.
  • accelerometerOptions: An object that contains properties which will modify how the accelerometer information is accessed.


  • watchID: A unique identifier returned from this method that can be used to stop watching for an accelerometer change.


    function onSuccess(acceleration) {
    alert('Acceleration X: ' + acceleration.x + '\n' +
    'Acceleration Y: ' + acceleration.y + '\n' +
    'Acceleration Z: ' + acceleration.z + '\n' +
    'Timestamp: '      + acceleration.timestamp + '\n');
    var options = { frequency: 3000, adjustForRotation: true  };  // Update every 3 seconds
    var watchID = intel.xdk.accelerometer.watchAcceleration(onSuccess, options);
For more complete information about compiler optimizations, see our Optimization Notice.