my.onAccelerometerChange
Use this API to listen to the acceleration data event. The callback interval is 500ms. After the interface is called, the listening is automatically started. You can use my.offAccelerometerChange to stop listening.**
Sample Code
copy
my.onAccelerometerChange(function(res) {
console.log(res.x);
console.log(res.y);
console.log(res.z);
})
Parameters
The property is a callback function which uses object properties with the following property:
Property | Type | Description |
x | Number | x-axis |
y | Number | y-axis |
z | Number | z-axis |