提交 5e886f45 编写于 作者: W wusongqing

updated against against 5486

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 25306f71
# Media Query # Media Query
> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE** > **NOTE**
>
> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
``` ```js
import mediaquery from '@ohos.mediaquery' import mediaquery from '@ohos.mediaquery'
``` ```
...@@ -22,19 +23,19 @@ matchMediaSync(condition: string): MediaQueryListener ...@@ -22,19 +23,19 @@ matchMediaSync(condition: string): MediaQueryListener
Sets the media query criteria and returns the corresponding listening handle. Sets the media query criteria and returns the corresponding listening handle.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | --------- | ------ | ---- | ---------- |
| condition | string | Yes| Matching condition of a media event.| | condition | string | Yes | Matching condition of a media event.|
- Return value **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------------------ | ---------------------- |
| MediaQueryListener | Listening handle to a media event, which is used to register or unregister the listening callback.| | MediaQueryListener | Listening handle to a media event, which is used to register or unregister the listening callback.|
- Example **Example**
``` ```js
listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events. listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events.
``` ```
...@@ -45,10 +46,10 @@ Media query handle, including the first query result when the handle is applied ...@@ -45,10 +46,10 @@ Media query handle, including the first query result when the handle is applied
### Attributes ### Attributes
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ------- | ------- | ---- | ---- | ---------- |
| matches | boolean | Yes| No| Whether the match condition is met.| | matches | boolean | Yes | No | Whether the match condition is met. |
| media | string | Yes| No| Matching condition of a media event.| | media | string | Yes | No | Matching condition of a media event.|
### on ### on
...@@ -57,13 +58,13 @@ on(type: 'change', callback: Callback&lt;MediaQueryResult&gt;): void ...@@ -57,13 +58,13 @@ on(type: 'change', callback: Callback&lt;MediaQueryResult&gt;): void
Registers a callback with the corresponding query condition by using the handle. This callback is triggered when the media attributes change. Registers a callback with the corresponding query condition by using the handle. This callback is triggered when the media attributes change.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------------------------------- | ---- | ---------------- |
| type | string | Yes| Must enter the string **change**.| | type | string | Yes | Must enter the string **change**.|
| callback | Callback&lt;MediaQueryResult&gt; | Yes| Callback registered with media query.| | callback | Callback&lt;MediaQueryResult&gt; | Yes | Callback registered with media query. |
- Example **Example**
For details, see [off Example](#off). For details, see [off Example](#off).
...@@ -72,14 +73,14 @@ Registers a callback with the corresponding query condition by using the handle. ...@@ -72,14 +73,14 @@ Registers a callback with the corresponding query condition by using the handle.
off(type: 'change', callback?: Callback&lt;MediaQueryResult&gt;): void off(type: 'change', callback?: Callback&lt;MediaQueryResult&gt;): void
Unregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change. Unregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------------------------------- | ---- | ----------------------------- |
| type | boolean | Yes| Must enter the string **change**.| | type | boolean | Yes | Must enter the string **change**. |
| callback | Callback&lt;MediaQueryResult&gt; | No| Callback to be unregistered. If the default value is used, all callbacks of the handle are unregistered.| | callback | Callback&lt;MediaQueryResult&gt; | No | Callback to be unregistered. If the default value is used, all callbacks of the handle are unregistered.|
- Example **Example**
``` ```js
import mediaquery from '@ohos.mediaquery' import mediaquery from '@ohos.mediaquery'
listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events. listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events.
...@@ -90,8 +91,8 @@ Unregisters a callback with the corresponding query condition by using the handl ...@@ -90,8 +91,8 @@ Unregisters a callback with the corresponding query condition by using the handl
// do something here // do something here
} }
} }
this.listener.on('change', this.onPortrait) // Registration callback. listener.on('change', onPortrait) // Register a callback.
this.listener.off('change', this.onPortrait) // Deregistration callback. listener.off('change', onPortrait) // Unregister a callback.
``` ```
...@@ -100,15 +101,15 @@ Unregisters a callback with the corresponding query condition by using the handl ...@@ -100,15 +101,15 @@ Unregisters a callback with the corresponding query condition by using the handl
### Attributes ### Attributes
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ------- | ------- | ---- | ---- | ---------- |
| matches | boolean | Yes| No| Whether the match condition is met.| | matches | boolean | Yes | No | Whether the match condition is met. |
| media | string | Yes| No| Matching condition of a media event.| | media | string | Yes | No | Matching condition of a media event.|
### Example ### Example
``` ```js
import mediaquery from '@ohos.mediaquery' import mediaquery from '@ohos.mediaquery'
let portraitFunc = null let portraitFunc = null
......
# Sensor # Sensor
> **NOTE**<br/> > **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
``` ```js
import sensor from '@ohos.sensor'; import sensor from '@ohos.sensor';
``` ```
## sensor.on
## sensor.on(SensorType.SENSOR_TYPE_ID_ACCELEROMETER) ### ACCELEROMETER
on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;,options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;,options?: Options): void
...@@ -30,7 +32,7 @@ Subscribes to data changes of the acceleration sensor. If this API is called mul ...@@ -30,7 +32,7 @@ Subscribes to data changes of the acceleration sensor. If this API is called mul
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -40,8 +42,7 @@ Subscribes to data changes of the acceleration sensor. If this API is called mul ...@@ -40,8 +42,7 @@ Subscribes to data changes of the acceleration sensor. If this API is called mul
); );
``` ```
### LINEAR_ACCELERATION
## sensor.on(SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION)
on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;LinearAccelerometerResponse&gt;, options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;LinearAccelerometerResponse&gt;, options?: Options): void
...@@ -59,7 +60,7 @@ Subscribes to data changes of the linear acceleration sensor. If this API is cal ...@@ -59,7 +60,7 @@ Subscribes to data changes of the linear acceleration sensor. If this API is cal
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -69,8 +70,7 @@ Subscribes to data changes of the linear acceleration sensor. If this API is cal ...@@ -69,8 +70,7 @@ Subscribes to data changes of the linear acceleration sensor. If this API is cal
); );
``` ```
### ACCELEROMETER_UNCALIBRATED
## sensor.on(SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED)
on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback&lt;AccelerometerUncalibratedResponse&gt;, options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback&lt;AccelerometerUncalibratedResponse&gt;, options?: Options): void
...@@ -88,7 +88,7 @@ Subscribes to data changes of the uncalibrated acceleration sensor. If this API ...@@ -88,7 +88,7 @@ Subscribes to data changes of the uncalibrated acceleration sensor. If this API
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -101,8 +101,7 @@ Subscribes to data changes of the uncalibrated acceleration sensor. If this API ...@@ -101,8 +101,7 @@ Subscribes to data changes of the uncalibrated acceleration sensor. If this API
); );
``` ```
### GRAVITY
## sensor.on(SensorType.SENSOR_TYPE_ID_GRAVITY)
on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityResponse&gt;,options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityResponse&gt;,options?: Options): void
...@@ -118,7 +117,7 @@ Subscribes to data changes of the gravity sensor. If this API is called multiple ...@@ -118,7 +117,7 @@ Subscribes to data changes of the gravity sensor. If this API is called multiple
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -128,8 +127,7 @@ Subscribes to data changes of the gravity sensor. If this API is called multiple ...@@ -128,8 +127,7 @@ Subscribes to data changes of the gravity sensor. If this API is called multiple
); );
``` ```
### GYROSCOPE
## sensor.on(SensorType.SENSOR_TYPE_ID_GYROSCOPE)
on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;, options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;, options?: Options): void
...@@ -147,7 +145,7 @@ Subscribes to data changes of the gyroscope sensor. If this API is called multip ...@@ -147,7 +145,7 @@ Subscribes to data changes of the gyroscope sensor. If this API is called multip
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -157,8 +155,7 @@ Subscribes to data changes of the gyroscope sensor. If this API is called multip ...@@ -157,8 +155,7 @@ Subscribes to data changes of the gyroscope sensor. If this API is called multip
); );
``` ```
### GYROSCOPE_UNCALIBRATED
## sensor.on(SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED)
on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback&lt;GyroscopeUncalibratedResponse&gt;, options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback&lt;GyroscopeUncalibratedResponse&gt;, options?: Options): void
...@@ -176,7 +173,7 @@ Subscribes to data changes of the uncalibrated gyroscope sensor. If this API is ...@@ -176,7 +173,7 @@ Subscribes to data changes of the uncalibrated gyroscope sensor. If this API is
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -189,8 +186,7 @@ Subscribes to data changes of the uncalibrated gyroscope sensor. If this API is ...@@ -189,8 +186,7 @@ Subscribes to data changes of the uncalibrated gyroscope sensor. If this API is
); );
``` ```
### SIGNIFICANT_MOTION
## sensor.on(SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION)
on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback&lt;SignificantMotionResponse&gt;, options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback&lt;SignificantMotionResponse&gt;, options?: Options): void
...@@ -206,7 +202,7 @@ Subscribes to data changes of the significant motion sensor. If this API is call ...@@ -206,7 +202,7 @@ Subscribes to data changes of the significant motion sensor. If this API is call
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
}, },
...@@ -214,8 +210,7 @@ Subscribes to data changes of the significant motion sensor. If this API is call ...@@ -214,8 +210,7 @@ Subscribes to data changes of the significant motion sensor. If this API is call
); );
``` ```
### PEDOMETER_DETECTION
## sensor.on(SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION)
on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback&lt;PedometerDetectionResponse&gt;, options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback&lt;PedometerDetectionResponse&gt;, options?: Options): void
...@@ -233,7 +228,7 @@ Subscribes to data changes of the pedometer detection sensor. If this API is cal ...@@ -233,7 +228,7 @@ Subscribes to data changes of the pedometer detection sensor. If this API is cal
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
}, },
...@@ -241,8 +236,7 @@ Subscribes to data changes of the pedometer detection sensor. If this API is cal ...@@ -241,8 +236,7 @@ Subscribes to data changes of the pedometer detection sensor. If this API is cal
); );
``` ```
### PEDOMETER
## sensor.on(SensorType.SENSOR_TYPE_ID_PEDOMETER)
on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerResponse&gt;, options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerResponse&gt;, options?: Options): void
...@@ -260,7 +254,7 @@ Subscribes to data changes of the pedometer sensor. If this API is called multip ...@@ -260,7 +254,7 @@ Subscribes to data changes of the pedometer sensor. If this API is called multip
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){
console.info('Steps: ' + data.steps); console.info('Steps: ' + data.steps);
}, },
...@@ -268,8 +262,7 @@ Subscribes to data changes of the pedometer sensor. If this API is called multip ...@@ -268,8 +262,7 @@ Subscribes to data changes of the pedometer sensor. If this API is called multip
); );
``` ```
### AMBIENT_TEMPERATURE
## sensor.on(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
on(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback&lt;AmbientTemperatureResponse&gt;, options?: Options): void on(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback&lt;AmbientTemperatureResponse&gt;, options?: Options): void
...@@ -285,7 +278,7 @@ Subscribes to data changes of the ambient temperature sensor. If this API is cal ...@@ -285,7 +278,7 @@ Subscribes to data changes of the ambient temperature sensor. If this API is cal
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){
console.info('Temperature: ' + data.temperature); console.info('Temperature: ' + data.temperature);
}, },
...@@ -293,8 +286,7 @@ Subscribes to data changes of the ambient temperature sensor. If this API is cal ...@@ -293,8 +286,7 @@ Subscribes to data changes of the ambient temperature sensor. If this API is cal
); );
``` ```
### MAGNETIC_FIELD
## sensor.on(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD)
on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;,options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;,options?: Options): void
...@@ -310,7 +302,7 @@ Subscribes to data changes of the magnetic field sensor. If this API is called m ...@@ -310,7 +302,7 @@ Subscribes to data changes of the magnetic field sensor. If this API is called m
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -320,8 +312,7 @@ Subscribes to data changes of the magnetic field sensor. If this API is called m ...@@ -320,8 +312,7 @@ Subscribes to data changes of the magnetic field sensor. If this API is called m
); );
``` ```
### MAGNETIC_FIELD_UNCALIBRATED
## sensor.on(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED)
on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;, options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;, options?: Options): void
...@@ -337,7 +328,7 @@ Subscribes to data changes of the uncalibrated magnetic field sensor. If this AP ...@@ -337,7 +328,7 @@ Subscribes to data changes of the uncalibrated magnetic field sensor. If this AP
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -350,8 +341,7 @@ Subscribes to data changes of the uncalibrated magnetic field sensor. If this AP ...@@ -350,8 +341,7 @@ Subscribes to data changes of the uncalibrated magnetic field sensor. If this AP
); );
``` ```
### PROXIMITY
## sensor.on(SensorType.SENSOR_TYPE_ID_PROXIMITY)
on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityResponse&gt;,options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityResponse&gt;,options?: Options): void
...@@ -367,7 +357,7 @@ Subscribes to data changes of the proximity sensor. If this API is called multip ...@@ -367,7 +357,7 @@ Subscribes to data changes of the proximity sensor. If this API is called multip
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){
console.info('Distance: ' + data.distance); console.info('Distance: ' + data.distance);
}, },
...@@ -375,8 +365,7 @@ Subscribes to data changes of the proximity sensor. If this API is called multip ...@@ -375,8 +365,7 @@ Subscribes to data changes of the proximity sensor. If this API is called multip
); );
``` ```
### HUMIDITY
## sensor.on(SensorType.SENSOR_TYPE_ID_HUMIDITY)
on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityResponse&gt;,options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityResponse&gt;,options?: Options): void
...@@ -392,7 +381,7 @@ Subscribes to data changes of the humidity sensor. If this API is called multipl ...@@ -392,7 +381,7 @@ Subscribes to data changes of the humidity sensor. If this API is called multipl
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){
console.info('Humidity: ' + data.humidity); console.info('Humidity: ' + data.humidity);
}, },
...@@ -400,8 +389,7 @@ Subscribes to data changes of the humidity sensor. If this API is called multipl ...@@ -400,8 +389,7 @@ Subscribes to data changes of the humidity sensor. If this API is called multipl
); );
``` ```
### BAROMETER
## sensor.on(SensorType.SENSOR_TYPE_ID_BAROMETER)
on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerResponse&gt;,options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerResponse&gt;,options?: Options): void
...@@ -417,7 +405,7 @@ Subscribes to data changes of the barometer sensor. If this API is called multip ...@@ -417,7 +405,7 @@ Subscribes to data changes of the barometer sensor. If this API is called multip
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){
console.info('Atmospheric pressure: ' + data.pressure); console.info('Atmospheric pressure: ' + data.pressure);
}, },
...@@ -425,8 +413,7 @@ Subscribes to data changes of the barometer sensor. If this API is called multip ...@@ -425,8 +413,7 @@ Subscribes to data changes of the barometer sensor. If this API is called multip
); );
``` ```
### HALL
## sensor.on(SensorType.SENSOR_TYPE_ID_HALL)
on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;, options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;, options?: Options): void
...@@ -442,7 +429,7 @@ Subscribes to data changes of the Hall effect sensor. If this API is called mult ...@@ -442,7 +429,7 @@ Subscribes to data changes of the Hall effect sensor. If this API is called mult
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){
console.info('Status: ' + data.status); console.info('Status: ' + data.status);
}, },
...@@ -450,8 +437,7 @@ Subscribes to data changes of the Hall effect sensor. If this API is called mult ...@@ -450,8 +437,7 @@ Subscribes to data changes of the Hall effect sensor. If this API is called mult
); );
``` ```
### AMBIENT_LIGHT
## sensor.on(SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT)
on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;, options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;, options?: Options): void
...@@ -467,7 +453,7 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu ...@@ -467,7 +453,7 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){
console.info(' Illumination: ' + data.intensity); console.info(' Illumination: ' + data.intensity);
}, },
...@@ -475,8 +461,7 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu ...@@ -475,8 +461,7 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu
); );
``` ```
### ORIENTATION
## sensor.on(SensorType.SENSOR_TYPE_ID_ORIENTATION)
on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;OrientationResponse&gt;, options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;OrientationResponse&gt;, options?: Options): void
...@@ -492,7 +477,7 @@ Subscribes to data changes of the orientation sensor. If this API is called mult ...@@ -492,7 +477,7 @@ Subscribes to data changes of the orientation sensor. If this API is called mult
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma); console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
...@@ -502,7 +487,7 @@ Subscribes to data changes of the orientation sensor. If this API is called mult ...@@ -502,7 +487,7 @@ Subscribes to data changes of the orientation sensor. If this API is called mult
); );
``` ```
## sensor.on(SensorType.SENSOR_TYPE_ID_HEART_RATE) ### HEART_RATE
on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;, options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;, options?: Options): void
...@@ -521,7 +506,7 @@ Subscribes to only one data change of the heart rate sensor. ...@@ -521,7 +506,7 @@ Subscribes to only one data change of the heart rate sensor.
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){
console.info("Heart rate: " + data.heartRate); console.info("Heart rate: " + data.heartRate);
}, },
...@@ -529,7 +514,7 @@ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){ ...@@ -529,7 +514,7 @@ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){
); );
``` ```
## sensor.on(SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR) ### ROTATION_VECTOR
on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback&lt;RotationVectorResponse&gt;,options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback&lt;RotationVectorResponse&gt;,options?: Options): void
...@@ -545,7 +530,7 @@ Subscribes to data changes of the rotation vector sensor. If this API is called ...@@ -545,7 +530,7 @@ Subscribes to data changes of the rotation vector sensor. If this API is called
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -556,8 +541,7 @@ Subscribes to data changes of the rotation vector sensor. If this API is called ...@@ -556,8 +541,7 @@ Subscribes to data changes of the rotation vector sensor. If this API is called
); );
``` ```
### WEAR_DETECTION
## sensor.on(SensorType.SENSOR_TYPE_ID_WEAR_DETECTION)
on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;,options?: Options): void on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;,options?: Options): void
...@@ -573,7 +557,7 @@ Subscribes to data changes of the wear detection sensor. If this API is called m ...@@ -573,7 +557,7 @@ Subscribes to data changes of the wear detection sensor. If this API is called m
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. | | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example** **Example**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){
console.info('Wear status: ' + data.value); console.info('Wear status: ' + data.value);
}, },
...@@ -581,8 +565,9 @@ Subscribes to data changes of the wear detection sensor. If this API is called m ...@@ -581,8 +565,9 @@ Subscribes to data changes of the wear detection sensor. If this API is called m
); );
``` ```
## sensor.once
## sensor.once(SensorType.SENSOR_TYPE_ID_ACCELEROMETER) ### ACCELEROMETER
once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;): void
...@@ -599,7 +584,7 @@ Subscribes to only one data change of the acceleration sensor. ...@@ -599,7 +584,7 @@ Subscribes to only one data change of the acceleration sensor.
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | Yes | One-shot callback used to return the acceleration sensor data. The reported data type in the callback is **AccelerometerResponse**.| | callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | Yes | One-shot callback used to return the acceleration sensor data. The reported data type in the callback is **AccelerometerResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -608,8 +593,7 @@ Subscribes to only one data change of the acceleration sensor. ...@@ -608,8 +593,7 @@ Subscribes to only one data change of the acceleration sensor.
); );
``` ```
### LINEAR_ACCELERATION
## sensor.once(SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION)
once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;LinearAccelerometerResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;LinearAccelerometerResponse&gt;): void
...@@ -626,7 +610,7 @@ Subscribes to only one data change of the linear acceleration sensor. ...@@ -626,7 +610,7 @@ Subscribes to only one data change of the linear acceleration sensor.
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | Yes | One-shot callback used to return the linear acceleration sensor data. The reported data type in the callback is **LinearAccelerometerResponse**.| | callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | Yes | One-shot callback used to return the linear acceleration sensor data. The reported data type in the callback is **LinearAccelerometerResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -635,8 +619,7 @@ Subscribes to only one data change of the linear acceleration sensor. ...@@ -635,8 +619,7 @@ Subscribes to only one data change of the linear acceleration sensor.
); );
``` ```
### ACCELEROMETER_UNCALIBRATED
## sensor.once(SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED)
once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback&lt;AccelerometerUncalibratedResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback&lt;AccelerometerUncalibratedResponse&gt;): void
...@@ -665,8 +648,7 @@ Subscribes to only one data change of the uncalibrated acceleration sensor. ...@@ -665,8 +648,7 @@ Subscribes to only one data change of the uncalibrated acceleration sensor.
); );
``` ```
### GRAVITY
## sensor.once(SensorType.SENSOR_TYPE_ID_GRAVITY)
once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityResponse&gt;): void
...@@ -681,7 +663,7 @@ Subscribes to only one data change of the gravity sensor. ...@@ -681,7 +663,7 @@ Subscribes to only one data change of the gravity sensor.
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | Yes | One-shot callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**.| | callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | Yes | One-shot callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -690,8 +672,7 @@ Subscribes to only one data change of the gravity sensor. ...@@ -690,8 +672,7 @@ Subscribes to only one data change of the gravity sensor.
); );
``` ```
### GYROSCOPE
## sensor.once(SensorType.SENSOR_TYPE_ID_GYROSCOPE)
once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;): void
...@@ -708,7 +689,7 @@ Subscribes to only one data change of the gyroscope sensor. ...@@ -708,7 +689,7 @@ Subscribes to only one data change of the gyroscope sensor.
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | Yes | One-shot callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**.| | callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | Yes | One-shot callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -717,8 +698,7 @@ Subscribes to only one data change of the gyroscope sensor. ...@@ -717,8 +698,7 @@ Subscribes to only one data change of the gyroscope sensor.
); );
``` ```
### GYROSCOPE_UNCALIBRATED
## sensor.once(SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED)
once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&lt;GyroscopeUncalibratedResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&lt;GyroscopeUncalibratedResponse&gt;): void
...@@ -735,7 +715,7 @@ Subscribes to only one data change of the uncalibrated gyroscope sensor. ...@@ -735,7 +715,7 @@ Subscribes to only one data change of the uncalibrated gyroscope sensor.
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | Yes | One-shot callback used to return the uncalibrated gyroscope sensor data. The reported data type in the callback is **GyroscopeUncalibratedResponse**.| | callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | Yes | One-shot callback used to return the uncalibrated gyroscope sensor data. The reported data type in the callback is **GyroscopeUncalibratedResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -747,8 +727,7 @@ Subscribes to only one data change of the uncalibrated gyroscope sensor. ...@@ -747,8 +727,7 @@ Subscribes to only one data change of the uncalibrated gyroscope sensor.
); );
``` ```
### SIGNIFICANT_MOTION
## sensor.once(SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION)
once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback&lt;SignificantMotionResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback&lt;SignificantMotionResponse&gt;): void
...@@ -763,15 +742,14 @@ Subscribes to only one data change of the significant motion sensor. ...@@ -763,15 +742,14 @@ Subscribes to only one data change of the significant motion sensor.
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | Yes | One-shot callback used to return the significant motion sensor data. The reported data type in the callback is **SignificantMotionResponse**.| | callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | Yes | One-shot callback used to return the significant motion sensor data. The reported data type in the callback is **SignificantMotionResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
} }
); );
``` ```
### PEDOMETER_DETECTION
## sensor.once(SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION)
once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback&lt;PedometerDetectionResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback&lt;PedometerDetectionResponse&gt;): void
...@@ -788,15 +766,14 @@ Subscribes to only one data change of the pedometer detection sensor. ...@@ -788,15 +766,14 @@ Subscribes to only one data change of the pedometer detection sensor.
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | Yes | One-shot callback used to return the pedometer detection sensor data. The reported data type in the callback is **PedometerDetectionResponse**.| | callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | Yes | One-shot callback used to return the pedometer detection sensor data. The reported data type in the callback is **PedometerDetectionResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
} }
); );
``` ```
### PEDOMETER
## sensor.once(SensorType.SENSOR_TYPE_ID_PEDOMETER)
once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerResponse&gt;): void
...@@ -813,15 +790,14 @@ Subscribes to only one data change of the pedometer sensor. ...@@ -813,15 +790,14 @@ Subscribes to only one data change of the pedometer sensor.
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes | One-shot callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**.| | callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes | One-shot callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) {
console.info('Steps: ' + data.steps); console.info('Steps: ' + data.steps);
} }
); );
``` ```
### AMBIENT_TEMPERATURE
## sensor.once(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback&lt;AmbientTemperatureResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback&lt;AmbientTemperatureResponse&gt;): void
...@@ -836,15 +812,14 @@ Subscribes to only one data change of the ambient temperature sensor. ...@@ -836,15 +812,14 @@ Subscribes to only one data change of the ambient temperature sensor.
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | Yes | One-shot callback used to return the ambient temperature sensor data. The reported data type in the callback is **AmbientTemperatureResponse**.| | callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | Yes | One-shot callback used to return the ambient temperature sensor data. The reported data type in the callback is **AmbientTemperatureResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) {
console.info('Temperature: ' + data.temperature); console.info('Temperature: ' + data.temperature);
} }
); );
``` ```
### MAGNETIC_FIELD
## sensor.once(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD)
once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;): void
...@@ -859,7 +834,7 @@ Subscribes to only one data change of the magnetic field sensor. ...@@ -859,7 +834,7 @@ Subscribes to only one data change of the magnetic field sensor.
| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | Yes | One-shot callback used to return the magnetic field sensor data. The reported data type in the callback is **MagneticFieldResponse**.| | callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | Yes | One-shot callback used to return the magnetic field sensor data. The reported data type in the callback is **MagneticFieldResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -868,8 +843,7 @@ Subscribes to only one data change of the magnetic field sensor. ...@@ -868,8 +843,7 @@ Subscribes to only one data change of the magnetic field sensor.
); );
``` ```
### MAGNETIC_FIELD_UNCALIBRATED
## sensor.once(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED)
once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;): void
...@@ -884,7 +858,7 @@ Subscribes to only one data change of the uncalibrated magnetic field sensor. ...@@ -884,7 +858,7 @@ Subscribes to only one data change of the uncalibrated magnetic field sensor.
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | Yes | One-shot callback used to return the uncalibrated magnetic field sensor data. The reported data type in the callback is **MagneticFieldUncalibratedResponse**.| | callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | Yes | One-shot callback used to return the uncalibrated magnetic field sensor data. The reported data type in the callback is **MagneticFieldUncalibratedResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -896,8 +870,7 @@ Subscribes to only one data change of the uncalibrated magnetic field sensor. ...@@ -896,8 +870,7 @@ Subscribes to only one data change of the uncalibrated magnetic field sensor.
); );
``` ```
### PROXIMITY
## sensor.once(SensorType.SENSOR_TYPE_ID_PROXIMITY)
once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityResponse&gt;): void
...@@ -912,7 +885,7 @@ Subscribes to only one data change of the proximity sensor. ...@@ -912,7 +885,7 @@ Subscribes to only one data change of the proximity sensor.
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | Yes | One-shot callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**.| | callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | Yes | One-shot callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) {
if (error) { if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message); console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
...@@ -923,8 +896,7 @@ Subscribes to only one data change of the proximity sensor. ...@@ -923,8 +896,7 @@ Subscribes to only one data change of the proximity sensor.
); );
``` ```
### HUMIDITY
## sensor.once(SensorType.SENSOR_TYPE_ID_HUMIDITY)
once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityResponse&gt;): void
...@@ -939,15 +911,14 @@ Subscribes to only one data change of the humidity sensor. ...@@ -939,15 +911,14 @@ Subscribes to only one data change of the humidity sensor.
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | Yes | One-shot callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**.| | callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | Yes | One-shot callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) {
console.info('Humidity: ' + data.humidity); console.info('Humidity: ' + data.humidity);
} }
); );
``` ```
### BAROMETER
## sensor.once(SensorType.SENSOR_TYPE_ID_BAROMETER)
once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerResponse&gt;): void
...@@ -962,15 +933,14 @@ Subscribes to only one data change of the barometer sensor. ...@@ -962,15 +933,14 @@ Subscribes to only one data change of the barometer sensor.
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | Yes | One-shot callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**.| | callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | Yes | One-shot callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) {
console.info('Atmospheric pressure: ' + data.pressure); console.info('Atmospheric pressure: ' + data.pressure);
} }
); );
``` ```
### HALL
## sensor.once(SensorType.SENSOR_TYPE_ID_HALL)
once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;): void
...@@ -985,15 +955,14 @@ Subscribes to only one data change of the Hall effect sensor. ...@@ -985,15 +955,14 @@ Subscribes to only one data change of the Hall effect sensor.
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | Yes | One-shot callback used to return the Hall effect sensor data. The reported data type in the callback is **HallResponse**.| | callback | Callback&lt;[HallResponse](#hallresponse)&gt; | Yes | One-shot callback used to return the Hall effect sensor data. The reported data type in the callback is **HallResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) {
console.info('Status: ' + data.status); console.info('Status: ' + data.status);
} }
); );
``` ```
### AMBIENT_LIGHT
## sensor.once(SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT)
once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;): void
...@@ -1008,15 +977,14 @@ Subscribes to only one data change of the ambient light sensor. ...@@ -1008,15 +977,14 @@ Subscribes to only one data change of the ambient light sensor.
| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | Yes | One-shot callback used to return the ambient light sensor data. The reported data type in the callback is **LightResponse**.| | callback | Callback&lt;[LightResponse](#lightresponse)&gt; | Yes | One-shot callback used to return the ambient light sensor data. The reported data type in the callback is **LightResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) {
console.info(' Illumination: ' + data.intensity); console.info(' Illumination: ' + data.intensity);
} }
); );
``` ```
### ORIENTATION
## sensor.once(SensorType.SENSOR_TYPE_ID_ORIENTATION)
once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;OrientationResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;OrientationResponse&gt;): void
...@@ -1031,7 +999,7 @@ Subscribes to only one data change of the orientation sensor. ...@@ -1031,7 +999,7 @@ Subscribes to only one data change of the orientation sensor.
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | Yes | One-shot callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**.| | callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | Yes | One-shot callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma); console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
...@@ -1040,8 +1008,7 @@ Subscribes to only one data change of the orientation sensor. ...@@ -1040,8 +1008,7 @@ Subscribes to only one data change of the orientation sensor.
); );
``` ```
### ROTATION_VECTOR
## sensor.once(SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR)
once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback&lt;RotationVectorResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback&lt;RotationVectorResponse&gt;): void
...@@ -1056,7 +1023,7 @@ Subscribes to only one data change of the rotation vector sensor. ...@@ -1056,7 +1023,7 @@ Subscribes to only one data change of the rotation vector sensor.
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | Yes | One-shot callback used to return the rotation vector sensor data. The reported data type in the callback is **RotationVectorResponse**.| | callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | Yes | One-shot callback used to return the rotation vector sensor data. The reported data type in the callback is **RotationVectorResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1066,8 +1033,7 @@ Subscribes to only one data change of the rotation vector sensor. ...@@ -1066,8 +1033,7 @@ Subscribes to only one data change of the rotation vector sensor.
); );
``` ```
### HEART_RATE
## sensor.once(SensorType.SENSOR_TYPE_ID_HEART_RATE)
once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;): void
...@@ -1084,15 +1050,14 @@ Subscribes to only one data change of the heart rate sensor. ...@@ -1084,15 +1050,14 @@ Subscribes to only one data change of the heart rate sensor.
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | Yes | One-shot callback used to return the heart rate sensor data. The reported data type in the callback is **HeartRateResponse**.| | callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | Yes | One-shot callback used to return the heart rate sensor data. The reported data type in the callback is **HeartRateResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function(data) {
console.info("Heart rate: " + data.heartRate); console.info("Heart rate: " + data.heartRate);
} }
); );
``` ```
### WEAR_DETECTION
## sensor.once(SensorType.SENSOR_TYPE_ID_WEAR_DETECTION)
once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;): void once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;): void
...@@ -1107,14 +1072,16 @@ Subscribes to only one data change of the wear detection sensor. ...@@ -1107,14 +1072,16 @@ Subscribes to only one data change of the wear detection sensor.
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | Yes | One-shot callback used to return the wear detection sensor data. The reported data type in the callback is **WearDetectionResponse**.| | callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | Yes | One-shot callback used to return the wear detection sensor data. The reported data type in the callback is **WearDetectionResponse**.|
**Example** **Example**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) {
console.info("Wear status: "+ data.value); console.info("Wear status: "+ data.value);
} }
); );
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_ACCELEROMETER) ## sensor.off
### ACCELEROMETER
off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback&lt;AccelerometerResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback&lt;AccelerometerResponse&gt;): void
...@@ -1133,7 +1100,7 @@ Unsubscribes from sensor data changes. ...@@ -1133,7 +1100,7 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('x-coordinate component: ' + data.x); console.info('x-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1142,7 +1109,7 @@ function callback(data) { ...@@ -1142,7 +1109,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED) ### ACCELEROMETER_UNCALIBRATED
off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callback&lt;AccelerometerUncalibratedResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callback&lt;AccelerometerUncalibratedResponse&gt;): void
...@@ -1161,7 +1128,7 @@ Unsubscribes from sensor data changes. ...@@ -1161,7 +1128,7 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1173,7 +1140,7 @@ function callback(data) { ...@@ -1173,7 +1140,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT) ### AMBIENT_LIGHT
off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback&lt;LightResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback&lt;LightResponse&gt;): void
...@@ -1190,14 +1157,14 @@ Unsubscribes from sensor data changes. ...@@ -1190,14 +1157,14 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info(' Illumination: ' + data.intensity); console.info(' Illumination: ' + data.intensity);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE) ### AMBIENT_TEMPERATURE
off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback&lt;AmbientTemperatureResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback&lt;AmbientTemperatureResponse&gt;): void
...@@ -1214,14 +1181,14 @@ Unsubscribes from sensor data changes. ...@@ -1214,14 +1181,14 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('Temperature: ' + data.temperature); console.info('Temperature: ' + data.temperature);
} }
sensor.off( sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback); sensor.off( sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE) ### AMBIENT_TEMPERATURE
off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback&lt;BarometerResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback&lt;BarometerResponse&gt;): void
...@@ -1238,14 +1205,14 @@ Unsubscribes from sensor data changes. ...@@ -1238,14 +1205,14 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('Atmospheric pressure: ' + data.pressure); console.info('Atmospheric pressure: ' + data.pressure);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_GRAVITY) ### GRAVITY
off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback&lt;GravityResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback&lt;GravityResponse&gt;): void
...@@ -1262,7 +1229,7 @@ Unsubscribes from sensor data changes. ...@@ -1262,7 +1229,7 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1271,7 +1238,7 @@ function callback(data) { ...@@ -1271,7 +1238,7 @@ function callback(data) {
sensor.off( sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); sensor.off( sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_GYROSCOPE) ### GYROSCOPE
off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback&lt;GyroscopeResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback&lt;GyroscopeResponse&gt;): void
...@@ -1290,7 +1257,7 @@ Unsubscribes from sensor data changes. ...@@ -1290,7 +1257,7 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1299,7 +1266,7 @@ function callback(data) { ...@@ -1299,7 +1266,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED) ### GYROSCOPE_UNCALIBRATED
off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback&lt;GyroscopeUncalibratedResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback&lt;GyroscopeUncalibratedResponse&gt;): void
...@@ -1318,7 +1285,7 @@ Unsubscribes from sensor data changes. ...@@ -1318,7 +1285,7 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1327,7 +1294,7 @@ function callback(data) { ...@@ -1327,7 +1294,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_HALL) ### HALL
off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback&lt;HallResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback&lt;HallResponse&gt;): void
...@@ -1344,14 +1311,14 @@ Unsubscribes from sensor data changes. ...@@ -1344,14 +1311,14 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('Status: ' + data.status); console.info('Status: ' + data.status);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_HEART_RATE) ### HEART_RATE
off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback&lt;HeartRateResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback&lt;HeartRateResponse&gt;): void
...@@ -1370,14 +1337,14 @@ Unsubscribes from sensor data changes. ...@@ -1370,14 +1337,14 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info("Heart rate: " + data.heartRate); console.info("Heart rate: " + data.heartRate);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_HUMIDITY) ### HUMIDITY
off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityResponse&gt;): void
...@@ -1396,14 +1363,14 @@ Unsubscribes from sensor data changes. ...@@ -1396,14 +1363,14 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('Humidity: ' + data.humidity); console.info('Humidity: ' + data.humidity);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION) ### LINEAR_ACCELERATION
off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback&lt;LinearAccelerometerResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback&lt;LinearAccelerometerResponse&gt;): void
...@@ -1422,7 +1389,7 @@ Unsubscribes from sensor data changes. ...@@ -1422,7 +1389,7 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1431,7 +1398,7 @@ function callback(data) { ...@@ -1431,7 +1398,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD) ### MAGNETIC_FIELD
off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback&lt;MagneticFieldResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback&lt;MagneticFieldResponse&gt;): void
...@@ -1450,7 +1417,7 @@ Unsubscribes from sensor data changes. ...@@ -1450,7 +1417,7 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1459,7 +1426,7 @@ function callback(data) { ...@@ -1459,7 +1426,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED) ### MAGNETIC_FIELD_UNCALIBRATED
off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback&lt;MagneticFieldUncalibratedResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback&lt;MagneticFieldUncalibratedResponse&gt;): void
...@@ -1476,7 +1443,7 @@ Unsubscribes from sensor data changes. ...@@ -1476,7 +1443,7 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1488,7 +1455,7 @@ function callback(data) { ...@@ -1488,7 +1455,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_ORIENTATION) ### ORIENTATION
off(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback?: Callback&lt;OrientationResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback?: Callback&lt;OrientationResponse&gt;): void
...@@ -1505,7 +1472,7 @@ Unsubscribes from sensor data changes. ...@@ -1505,7 +1472,7 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma); console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
...@@ -1514,7 +1481,7 @@ function callback(data) { ...@@ -1514,7 +1481,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_PEDOMETER) ### PEDOMETER
off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerResponse&gt;): void
...@@ -1529,16 +1496,16 @@ Unsubscribes from sensor data changes. ...@@ -1529,16 +1496,16 @@ Unsubscribes from sensor data changes.
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PEDOMETER**. | | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PEDOMETER**. |
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes | Callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**.| | callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes | Callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**.|
**Return value** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('Steps: ' + data.steps); console.info('Steps: ' + data.steps);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION) ### PEDOMETER_DETECTION
off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback&lt;PedometerDetectionResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback&lt;PedometerDetectionResponse&gt;): void
...@@ -1557,14 +1524,14 @@ Unsubscribes from sensor data changes. ...@@ -1557,14 +1524,14 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_PROXIMITY) ### PROXIMITY
off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback&lt;ProximityResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback&lt;ProximityResponse&gt;): void
...@@ -1581,14 +1548,14 @@ Unsubscribes from sensor data changes. ...@@ -1581,14 +1548,14 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('Distance: ' + data.distance); console.info('Distance: ' + data.distance);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR) ### ROTATION_VECTOR
off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback&lt;RotationVectorResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback&lt;RotationVectorResponse&gt;): void
...@@ -1605,7 +1572,7 @@ Unsubscribes from sensor data changes. ...@@ -1605,7 +1572,7 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1615,7 +1582,7 @@ function callback(data) { ...@@ -1615,7 +1582,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION) ### SIGNIFICANT_MOTION
off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback&lt;SignificantMotionResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback&lt;SignificantMotionResponse&gt;): void
...@@ -1632,14 +1599,14 @@ Unsubscribes from sensor data changes. ...@@ -1632,14 +1599,14 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function callback(data) { function callback(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback);
``` ```
## sensor.off(SensorType.SENSOR_TYPE_ID_WEAR_DETECTION) ### WEAR_DETECTION
off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback&lt;WearDetectionResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback&lt;WearDetectionResponse&gt;): void
...@@ -1656,7 +1623,7 @@ Unsubscribes from sensor data changes. ...@@ -1656,7 +1623,7 @@ Unsubscribes from sensor data changes.
**Example** **Example**
``` ```js
function accCallback(data) { function accCallback(data) {
console.info('Wear status: ' + data.value); console.info('Wear status: ' + data.value);
} }
...@@ -1681,13 +1648,13 @@ Rotates a rotation vector so that it can represent the coordinate system in diff ...@@ -1681,13 +1648,13 @@ Rotates a rotation vector so that it can represent the coordinate system in diff
**Example** **Example**
``` ```js
sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}, function(err, data) { sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}, function(err, data) {
if (err) { if (err) {
console.error("Operation failed. Error code: " + err.code + ", message: " + err.message); console.error("Operation failed. Error code: " + err.code + ", message: " + err.message);
return; return;
} }
console.info("Operation successed. Data obtained: " + data.x); console.info("Operation successed. Data obtained: " + data);
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
} }
...@@ -1716,8 +1683,8 @@ Rotates a rotation vector so that it can represent the coordinate system in diff ...@@ -1716,8 +1683,8 @@ Rotates a rotation vector so that it can represent the coordinate system in diff
**Example** **Example**
``` ```js
const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}); const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3});
promise.then((data) => { promise.then((data) => {
console.info("Operation successed."); console.info("Operation successed.");
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
...@@ -1744,8 +1711,8 @@ Obtains the geomagnetic field of a geographic location. This API uses a callback ...@@ -1744,8 +1711,8 @@ Obtains the geomagnetic field of a geographic location. This API uses a callback
| callback | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Yes | Callback used to return the geomagnetic field. | | callback | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Yes | Callback used to return the geomagnetic field. |
**Example** **Example**
``` ```js
sensor.getGeomagneticField([80, 0, 0], 1580486400000, function(err, data) { sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000, function(err, data) {
if (err) { if (err) {
console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message); console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message);
return; return;
...@@ -1772,11 +1739,11 @@ Obtains the geomagnetic field of a geographic location. This API uses a promise ...@@ -1772,11 +1739,11 @@ Obtains the geomagnetic field of a geographic location. This API uses a promise
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ------- | | ---------------------------------------- | ------- |
| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Promise used to return the geomagnetic field.| | Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Promise used to return the geomagnetic field. |
**Return value** **Example**
``` ```js
const promise = sensor.getGeomagneticField([80, 0, 0], 1580486400000); const promise = sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000);
promise.then((data) => { promise.then((data) => {
console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' + console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' +
data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
...@@ -1802,9 +1769,9 @@ Obtains the altitude at which the device is located based on the sea-level atmos ...@@ -1802,9 +1769,9 @@ Obtains the altitude at which the device is located based on the sea-level atmos
| currentPressure | number | Yes | Atmospheric pressure at the altitude where the device is located, in hPa.| | currentPressure | number | Yes | Atmospheric pressure at the altitude where the device is located, in hPa.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the altitude, in meters. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the altitude, in meters. |
**Return value** **Example**
``` ```js
sensor.getAltitude(0, 200, function(err, data) { sensor.getAltitude(0, 200, function(err, data) {
if (err) { if (err) {
console.error( console.error(
...@@ -1836,9 +1803,9 @@ Obtains the altitude at which the device is located based on the sea-level atmos ...@@ -1836,9 +1803,9 @@ Obtains the altitude at which the device is located based on the sea-level atmos
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the altitude, in meters.| | Promise&lt;number&gt; | Promise used to return the altitude, in meters.|
**Return value** **Example**
``` ```js
const promise = sensor.getAltitude(0, 200); const promise = sensor.getAltitude(0, 200);
promise.then((data) => { promise.then((data) => {
console.info(' sensor_getAltitude_Promise success', data); console.info(' sensor_getAltitude_Promise success', data);
...@@ -1863,12 +1830,12 @@ Obtains the magnetic dip based on the inclination matrix. This API uses a callba ...@@ -1863,12 +1830,12 @@ Obtains the magnetic dip based on the inclination matrix. This API uses a callba
| inclinationMatrix | Array&lt;number&gt; | Yes | Inclination matrix. | | inclinationMatrix | Array&lt;number&gt; | Yes | Inclination matrix. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the magnetic dip, in radians.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the magnetic dip, in radians.|
**Return value** **Example**
``` ```js
sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
...@@ -1896,9 +1863,9 @@ Obtains the magnetic dip based on the inclination matrix. This API uses a promis ...@@ -1896,9 +1863,9 @@ Obtains the magnetic dip based on the inclination matrix. This API uses a promis
| --------------------- | -------------- | | --------------------- | -------------- |
| Promise&lt;number&gt; | Promise used to return the magnetic dip, in radians.| | Promise&lt;number&gt; | Promise used to return the magnetic dip, in radians.|
**Return value** **Example**
``` ```js
const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]); const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => { promise.then((data) => {
console.info(' getGeomagneticDip_promise successed', data); console.info(' getGeomagneticDip_promise successed', data);
...@@ -1923,18 +1890,18 @@ Obtains the angle change between two rotation matrices. This API uses a callback ...@@ -1923,18 +1890,18 @@ Obtains the angle change between two rotation matrices. This API uses a callback
| preRotationMatrix | Array&lt;number&gt; | Yes | The other rotation matrix. | | preRotationMatrix | Array&lt;number&gt; | Yes | The other rotation matrix. |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the angle change around the z, x, and y axes.| | callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the angle change around the z, x, and y axes.|
**Return value** **Example**
``` ```js
sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) { sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'Failed to register data, error code is: ' + err.code + ', message: ' + console.error('Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
console.info("SensorJsAPI--->Successed to get getAngleModifiy interface get data: " + data.x); console.info("SensorJsAPI--->Successed to get getAngleModifiy interface get data: " + data.x);
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
} }
}) })
``` ```
...@@ -1961,17 +1928,17 @@ Obtains the angle change between two rotation matrices. This API uses a promise ...@@ -1961,17 +1928,17 @@ Obtains the angle change between two rotation matrices. This API uses a promise
| ---------------------------------- | ------------------ | | ---------------------------------- | ------------------ |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the angle change around the z, x, and y axes.| | Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the angle change around the z, x, and y axes.|
**Return value** **Example**
``` ```js
const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]); const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]);
promise.then((data) => { promise.then((data) => {
console.info(LABEL + 'getAngleModifiy_promise success'); console.info('getAngleModifiy_promise success');
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
} }
}).catch((reason) => { }).catch((reason) => {
console.info(LABEL + "promise::catch", reason); console.info("promise::catch", reason);
}) })
``` ```
...@@ -1991,18 +1958,18 @@ Converts a rotation vector into a rotation matrix. This API uses a callback to r ...@@ -1991,18 +1958,18 @@ Converts a rotation vector into a rotation matrix. This API uses a callback to r
| rotationVector | Array&lt;number&gt; | Yes | Rotation vector to convert.| | rotationVector | Array&lt;number&gt; | Yes | Rotation vector to convert.|
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the rotation matrix.| | callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the rotation matrix.|
**Return value** **Example**
``` ```js
sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x); console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x);
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
} }
}) })
``` ```
...@@ -2028,17 +1995,17 @@ Converts a rotation vector into a rotation matrix. This API uses a promise to re ...@@ -2028,17 +1995,17 @@ Converts a rotation vector into a rotation matrix. This API uses a promise to re
| ---------------------------------- | ------- | | ---------------------------------- | ------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation matrix.| | Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation matrix.|
**Return value** **Example**
``` ```js
const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]); const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => { promise.then((data) => {
console.info(LABEL + 'createRotationMatrix_promise success'); console.info('createRotationMatrix_promise success');
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
} }
}).catch((reason) => { }).catch((reason) => {
console.info(LABEL + "promise::catch", reason); console.info("promise::catch", reason);
}) })
``` ```
...@@ -2058,18 +2025,18 @@ Converts a rotation vector into a quaternion. This API uses a callback to return ...@@ -2058,18 +2025,18 @@ Converts a rotation vector into a quaternion. This API uses a callback to return
| rotationVector | Array&lt;number&gt; | Yes | Rotation vector to convert.| | rotationVector | Array&lt;number&gt; | Yes | Rotation vector to convert.|
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the quaternion. | | callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the quaternion. |
**Return value** **Example**
``` ```js
sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
console.info("SensorJsAPI--->Successed to get createQuaternion interface get data: " + data.x); console.info("SensorJsAPI--->Successed to get createQuaternion interface get data: " + data.x);
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
} }
}) })
``` ```
...@@ -2095,14 +2062,14 @@ Converts a rotation vector into a quaternion. This API uses a promise to return ...@@ -2095,14 +2062,14 @@ Converts a rotation vector into a quaternion. This API uses a promise to return
| ---------------------------------- | ------ | | ---------------------------------- | ------ |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the quaternion.| | Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the quaternion.|
**Return value** **Example**
``` ```js
const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]); const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => { promise.then((data) => {
console.info('createQuaternion_promise successed'); console.info('createQuaternion_promise successed');
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
} }
}).catch((err) => { }).catch((err) => {
console.info('promise failed'); console.info('promise failed');
...@@ -2125,18 +2092,18 @@ Obtains the device direction based on the rotation matrix. This API uses a callb ...@@ -2125,18 +2092,18 @@ Obtains the device direction based on the rotation matrix. This API uses a callb
| rotationMatrix | Array&lt;number&gt; | Yes | Rotation matrix. | | rotationMatrix | Array&lt;number&gt; | Yes | Rotation matrix. |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the rotation angle around the z, x, and y axes.| | callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the rotation angle around the z, x, and y axes.|
**Return value** **Example**
``` ```js
sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
console.info(LABEL + "SensorJsAPI--->Successed to get getDirection interface get data: " + data.x); console.info("SensorJsAPI--->Successed to get getDirection interface get data: " + data);
for (var i = 1; i < data.length; i++) { for (var i = 1; i < data.length; i++) {
console.info(TAG +"sensor_getDirection_callback" + data[i]); console.info("sensor_getDirection_callback" + data[i]);
} }
}) })
``` ```
...@@ -2162,14 +2129,14 @@ Obtains the device direction based on the rotation matrix. This API uses a promi ...@@ -2162,14 +2129,14 @@ Obtains the device direction based on the rotation matrix. This API uses a promi
| ---------------------------------- | ------------------ | | ---------------------------------- | ------------------ |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation angle around the z, x, and y axes.| | Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation angle around the z, x, and y axes.|
**Return value** **Example**
``` ```js
const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]); const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => { promise.then((data) => {
console.info(' sensor_getAltitude_Promise success', data.x); console.info('sensor_getAltitude_Promise success', data);
for (var i = 1; i < data.length; i++) { for (var i = 1; i < data.length; i++) {
console.info(TAG +"sensor_getDirection_promise" + data[i]); console.info("sensor_getDirection_promise" + data[i]);
} }
}).catch((err) => { }).catch((err) => {
console.info('promise failed'); console.info('promise failed');
...@@ -2193,18 +2160,18 @@ Creates a rotation matrix based on the gravity vector and geomagnetic vector. Th ...@@ -2193,18 +2160,18 @@ Creates a rotation matrix based on the gravity vector and geomagnetic vector. Th
| geomagnetic | Array&lt;number&gt; | Yes | Geomagnetic vector.| | geomagnetic | Array&lt;number&gt; | Yes | Geomagnetic vector.|
| callback | AsyncCallback&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Yes | Callback used to return the rotation matrix.| | callback | AsyncCallback&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Yes | Callback used to return the rotation matrix.|
**Return value** **Example**
``` ```js
sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) { sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x); console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x);
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]) console.info("data[" + i + "]: " + data[i])
} }
}) })
``` ```
...@@ -2231,17 +2198,17 @@ Creates a rotation matrix based on the gravity vector and geomagnetic vector. Th ...@@ -2231,17 +2198,17 @@ Creates a rotation matrix based on the gravity vector and geomagnetic vector. Th
| ---------------------------------------- | ------- | | ---------------------------------------- | ------- |
| Promise&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Promise used to return the rotation matrix.| | Promise&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Promise used to return the rotation matrix.|
**Return value** **Example**
``` ```js
const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]); const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]);
promise.then((data) => { promise.then((data) => {
console.info(LABEL + 'createRotationMatrix_promise successed'); console.info('createRotationMatrix_promise successed');
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
} }
}).catch((err) => { }).catch((err) => {
console.info(LABEL + 'promise failed'); console.info('promise failed');
}) })
``` ```
...@@ -2355,11 +2322,11 @@ Describes the orientation sensor data. It extends from [Response](#response). ...@@ -2355,11 +2322,11 @@ Describes the orientation sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| ----- | ------ | ---- | ---- | ------------------------ | | ----- | ------ | ---- | ---- | ----------------- |
| alpha | number | Yes | Yes | Rotation angle of the device around the z-axis, in degrees.| | alpha | number | Yes | Yes | Rotation angle of the device around the z-axis, in degrees.|
| beta | number | Yes | Yes | Rotation angle of the device around the x-axis, in degrees. | | beta | number | Yes | Yes | Rotation angle of the device around the x-axis, in degrees.|
| gamma | number | Yes | Yes | Rotation angle of the device around the y-axis, in degrees. | | gamma | number | Yes | Yes | Rotation angle of the device around the y-axis, in degrees.|
## RotationVectorResponse ## RotationVectorResponse
......
# Prompt # Prompt
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
> >
> - The APIs of this module are no longer maintained since API version 8. You are advised to use ['@ohos.prompt](js-apis-prompt.md)' instead. > - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.prompt`](js-apis-prompt.md) instead.
> >
> >
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
## Modules to Import ## Modules to Import
``` ```js
import prompt from '@system.prompt'; import prompt from '@system.prompt';
``` ```
...@@ -31,7 +31,7 @@ Shows the toast. ...@@ -31,7 +31,7 @@ Shows the toast.
**Example** **Example**
``` ```js
export default { export default {
showToast() { showToast() {
prompt.showToast({ prompt.showToast({
...@@ -60,7 +60,7 @@ Shows the dialog box. ...@@ -60,7 +60,7 @@ Shows the dialog box.
**Example** **Example**
``` ```js
export default { export default {
showDialog() { showDialog() {
prompt.showDialog({ prompt.showDialog({
...@@ -100,7 +100,7 @@ Shows the action menu. ...@@ -100,7 +100,7 @@ Shows the action menu.
**Example** **Example**
``` ```js
export default { export default {
showActionMenu() { showActionMenu() {
prompt.showActionMenu({ prompt.showActionMenu({
...@@ -115,11 +115,11 @@ export default { ...@@ -115,11 +115,11 @@ export default {
color: '#000000', color: '#000000',
}, },
], ],
success: function(data) { success: function(tapIndex) {
console.log('dialog success callback, click button : ' + data.tapIndex); console.log('dialog success callback, click button : ' + data.tapIndex);
}, },
fail: function(data) { fail: function(errMsg) {
console.log('dialog fail callback' + data.errMsg); console.log('dialog fail callback' + errMsg);
}, },
}); });
} }
...@@ -135,7 +135,7 @@ Describes the options for showing the toast. ...@@ -135,7 +135,7 @@ Describes the options for showing the toast.
| ------------------- | -------------- | ---- | ---------------------------------------- | | ------------------- | -------------- | ---- | ---------------------------------------- |
| message | string | Yes | Text to display. | | message | string | Yes | Text to display. |
| duration | number | No | Duration that the toast will remain on the screen. The default value is 1500 ms. The recommended value range is 1500 ms to 10000 ms. If a value less than 1500 ms is set, the default value is used.| | duration | number | No | Duration that the toast will remain on the screen. The default value is 1500 ms. The recommended value range is 1500 ms to 10000 ms. If a value less than 1500 ms is set, the default value is used.|
| bottom<sup>5+</sup> | string\|number | No | Distance between the toast frame and the bottom of the screen. This parameter is available only on phones and tablets. | | bottom<sup>5+</sup> | string\|number | No | Distance between the toast border and the bottom of the screen. |
## Button ## Button
......
# Page Routing # Page Routing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
> >
> - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.router`](js-apis-router.md) instead. > - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.router`](js-apis-router.md) instead.
> >
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
## Modules to Import ## Modules to Import
``` ```js
import router from '@system.router'; import router from '@system.router';
``` ```
...@@ -31,7 +31,7 @@ Navigates to a specified page in the application. ...@@ -31,7 +31,7 @@ Navigates to a specified page in the application.
**Example** **Example**
``` ```js
// Current page // Current page
export default { export default {
pushPage() { pushPage() {
...@@ -49,7 +49,7 @@ export default { ...@@ -49,7 +49,7 @@ export default {
``` ```
``` ```js
// routerpage2 page // routerpage2 page
export default { export default {
data: { data: {
...@@ -85,7 +85,7 @@ Replaces the current page with another one in the application and destroys the c ...@@ -85,7 +85,7 @@ Replaces the current page with another one in the application and destroys the c
**Example** **Example**
``` ```js
// Current page // Current page
export default { export default {
replacePage() { replacePage() {
...@@ -100,7 +100,7 @@ export default { ...@@ -100,7 +100,7 @@ export default {
``` ```
``` ```js
// detail page // detail page
export default { export default {
data: { data: {
...@@ -128,7 +128,7 @@ Returns to the previous page or a specified page. ...@@ -128,7 +128,7 @@ Returns to the previous page or a specified page.
**Example** **Example**
``` ```js
// index page // index page
export default { export default {
indexPushPage() { indexPushPage() {
...@@ -140,7 +140,7 @@ export default { ...@@ -140,7 +140,7 @@ export default {
``` ```
``` ```js
// detail page // detail page
export default { export default {
detailPushPage() { detailPushPage() {
...@@ -152,7 +152,7 @@ export default { ...@@ -152,7 +152,7 @@ export default {
``` ```
``` ```js
// Navigate from the mall page to the detail page through router.back(). // Navigate from the mall page to the detail page through router.back().
export default { export default {
mallBackPage() { mallBackPage() {
...@@ -162,7 +162,7 @@ export default { ...@@ -162,7 +162,7 @@ export default {
``` ```
``` ```js
// Navigate from the detail page to the index page through router.back(). // Navigate from the detail page to the index page through router.back().
export default { export default {
defaultBack() { defaultBack() {
...@@ -172,7 +172,7 @@ export default { ...@@ -172,7 +172,7 @@ export default {
``` ```
``` ```js
// Return to the detail page through router.back(). // Return to the detail page through router.back().
export default { export default {
backToDetail() { backToDetail() {
...@@ -208,7 +208,7 @@ Clears all historical pages in the stack and retains only the current page at th ...@@ -208,7 +208,7 @@ Clears all historical pages in the stack and retains only the current page at th
**Example** **Example**
``` ```js
export default { export default {
clearPage() { clearPage() {
router.clear(); router.clear();
...@@ -232,7 +232,7 @@ Obtains the number of pages in the current stack. ...@@ -232,7 +232,7 @@ Obtains the number of pages in the current stack.
**Example** **Example**
``` ```js
export default { export default {
getLength() { getLength() {
var size = router.getLength(); var size = router.getLength();
...@@ -257,7 +257,7 @@ Obtains state information about the current page. ...@@ -257,7 +257,7 @@ Obtains state information about the current page.
**Example** **Example**
``` ```js
export default { export default {
getState() { getState() {
var page = router.getState(); var page = router.getState();
...@@ -284,7 +284,7 @@ Enables the display of a confirm dialog box before returning to the previous pag ...@@ -284,7 +284,7 @@ Enables the display of a confirm dialog box before returning to the previous pag
**Example** **Example**
``` ```js
export default { export default {
enableAlertBeforeBackPage() { enableAlertBeforeBackPage() {
router.enableAlertBeforeBackPage({ router.enableAlertBeforeBackPage({
...@@ -292,8 +292,8 @@ export default { ...@@ -292,8 +292,8 @@ export default {
success: function() { success: function() {
console.log('success'); console.log('success');
}, },
fail: function() { cancel: function() {
console.log('fail'); console.log('cancel');
}, },
}); });
} }
...@@ -316,15 +316,15 @@ Disables the display of a confirm dialog box before returning to the previous pa ...@@ -316,15 +316,15 @@ Disables the display of a confirm dialog box before returning to the previous pa
**Example** **Example**
``` ```js
export default { export default {
disableAlertBeforeBackPage() { disableAlertBeforeBackPage() {
router.disableAlertBeforeBackPage({ router.disableAlertBeforeBackPage({
success: function() { success: function() {
console.log('success'); console.log('success');
}, },
fail: function() { cancel: function() {
console.log('fail'); console.log('cancel');
}, },
}); });
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册