Accelerometer

API Reference: Device.Accelerometer

Accelerometer allows capturing accelerometer (motion) events on the device.

JavaScript
JavaScript
const Page = require("sf-core/ui/page");
const extend = require("js-base/core/extend");
const Accelerometer = require('sf-core/device/accelerometer');
var Page1 = extend(Page)(
function(_super) {
_super(this, {
onShow: function(params) {
Application.statusBar.visible = false;
this.headerBar.visible = false;
}
});
Accelerometer.start();
Accelerometer.onAccelerate = function(event) {
console.log("x: " + event.x + " y : " + event.y + " z : " + event.z);
if (event.z > 9) {
Accelerometer.stop();
}
};
}
);
module.exports = Page1;