my.stopAccelerometer
Use this JSAPI to stop receiving the data from the accelerometer. The current mini program does not receive any AccelerometerChange event.
Sample Code
// .js
Page({
listener(res) {
console.log("1" + JSON.stringify(res))
},
listener2(res) {
console.log("2" + JSON.stringify(res));
},
start() {
my.startAccelerometer({
success: () => {
my.onAccelerometerChange(this.listener);
my.onAccelerometerChange(this.listener2);
}
});
},
stop() {
my.stopAccelerometer();
},
offSingle() {
my.offAccelerometerChange(this.listener);
}
});
Parameters
The incoming parameter is of the Object type with the following properties:
Property | Type | Required | Description |
success | Function | No | The callback function that is called upon successful call. |
fail | Function | No | The callback function that is called when the JSAPI call fails. When executed, it receives an |
complete | Function | No | The callback function that is called upon call completion (to be executed upon either successful or failed call). |
err
object
Parameter | Data type | Required | Description |
error | Number | Yes | An error code that represents the specific error encountered. |
errorMessage | String | Yes | An error message that describes the corresponding error code. |