diff --git a/en/application-dev/device/sensor-guidelines.md b/en/application-dev/device/sensor-guidelines.md index 50ebd3428f89eba4f968dd98e5fe2edee91bee34..4660ed06e631ab5de0e5e300fc73f0c2b5576cbe 100644 --- a/en/application-dev/device/sensor-guidelines.md +++ b/en/application-dev/device/sensor-guidelines.md @@ -3,30 +3,18 @@ ## When to Use -- Data provided by the compass sensor denotes the current orientation of the user device, which helps your application accurately navigate for the user. +With the sensor module, a device can obtain sensor data. For example, the device can subscribe to data of the orientation sensor to detect its own orientation, and data of the pedometer sensor to learn the number of steps the user walks every day. -- Data provided by the proximity sensor denotes the distance between the device and a visible object, which enables the device to automatically turn on or off its screen accordingly to prevent accidental touch on the screen. - -- Data provided by the barometer sensor helps your application accurately determine the altitude of the device. - -- Data provided by the ambient light sensor helps your device automatically adjust its backlight. - -- Data provided by the Hall effect sensor implements the smart cover mode of your device. - -- Data provided by the heart rate sensor helps your application track the heart health of a user. - -- Data provided by the pedometer sensor helps your application obtain the number of steps a user has walked. - -- Data provided by the wear detection sensor helps your application detect whether a user is wearing a wearable device. +For details about the APIs, see [Sensor](../reference/apis/js-apis-sensor.md). ## Available APIs | Module| API| Description| | -------- | -------- | -------- | -| ohos.sensor | sensor.on(sensorType, callback:AsyncCallback<Response>): void | Subscribes to data changes of a type of sensor.| -| ohos.sensor | sensor.once(sensorType, callback:AsyncCallback<Response>): void | Subscribes to only one data change of a type of sensor.| -| ohos.sensor | sensor.off(sensorType, callback?:AsyncCallback<void>): void | Unsubscribes from sensor data changes.| +| ohos.sensor | sensor.on(sensorId, callback:AsyncCallback<Response>): void | Subscribes to data changes of a type of sensor.| +| ohos.sensor | sensor.once(sensorId, callback:AsyncCallback<Response>): void | Subscribes to only one data change of a type of sensor.| +| ohos.sensor | sensor.off(sensorId, callback?:AsyncCallback<void>): void | Unsubscribes from sensor data changes.| ## How to Develop @@ -43,52 +31,49 @@ For details about how to configure a permission, see [Declaring Permissions](../security/accesstoken-guidelines.md). -2. Subscribe to data changes of a type of sensor. +2. Subscribe to data changes of a type of sensor. The following uses the acceleration sensor as an example. - ``` + ```js import sensor from "@ohos.sensor"; - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function(data){ - console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z); // Data is obtained. + sensor.on(sensor.SensorId.ACCELEROMETER, function(data){ + console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z);// Data is obtained. }); ``` - The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**. - ![en-us_image_0000001241693881](figures/en-us_image_0000001241693881.png) + ![171e6f30-a8d9-414c-bafa-b430340305fb](figures/171e6f30-a8d9-414c-bafa-b430340305fb.png) 3. Unsubscribe from sensor data changes. - ``` + ```js import sensor from "@ohos.sensor"; - sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); + sensor.off(sensor.SensorId.ACCELEROMETER); ``` - The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**. - ![en-us_image_0000001196654004](figures/en-us_image_0000001196654004.png) + ![65d69983-29f6-4381-80a3-f9ef2ec19e53](figures/65d69983-29f6-4381-80a3-f9ef2ec19e53.png) 4. Subscribe to only one data change of a type of sensor. - ``` + ```js import sensor from "@ohos.sensor"; - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function(data) { - console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z); // Data is obtained. + sensor.once(sensor.SensorId.ACCELEROMETER, function(data) { + console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z);// Data is obtained. }); ``` - The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**. - ![en-us_image_0000001241733907](figures/en-us_image_0000001241733907.png) + ![db5d017d-6c1c-4a71-a2dd-f74b7f23239e](figures/db5d017d-6c1c-4a71-a2dd-f74b7f23239e.png) If the API fails to be called, you are advised to use the **try/catch** statement to capture error information that may occur in the code. Example: - ``` + ```js import sensor from "@ohos.sensor"; try { - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function(data) { - console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z); // Data is obtained. + sensor.once(sensor.SensorId.ACCELEROMETER, function(data) { + console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z);// Data is obtained. }); } catch (error) { - console.error("Failed to get sensor data"); + console.error("Get sensor data error. data:" + error.data, " msg:", error.message); } - ``` \ No newline at end of file + ``` diff --git a/en/application-dev/media/audio-renderer.md b/en/application-dev/media/audio-renderer.md index 0b5b382d72fec98bfa18c3cfdee7bd61ef713da1..119722ed2e72d4857048f8d7fac905ddb4566a35 100644 --- a/en/application-dev/media/audio-renderer.md +++ b/en/application-dev/media/audio-renderer.md @@ -34,8 +34,7 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference 1. Use **createAudioRenderer()** to create an **AudioRenderer** instance. - -Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. This instance is used to render audio, control and obtain the rendering status, and register a callback for notification. + Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. This instance is used to render audio, control and obtain the rendering status, and register a callback for notification. ```js import audio from '@ohos.multimedia.audio'; diff --git a/en/application-dev/reference/errorcodes/errorcode-avsession.md b/en/application-dev/reference/errorcodes/errorcode-avsession.md index 98b811bd159ccf0be5eed06746622a3686e96bce..a072aa68d0d35b21470b3c68e55b06a856466932 100644 --- a/en/application-dev/reference/errorcodes/errorcode-avsession.md +++ b/en/application-dev/reference/errorcodes/errorcode-avsession.md @@ -4,7 +4,7 @@ **Error Message** -Session service exception +Session service exception. **Description** @@ -24,7 +24,7 @@ The session service is killed during session restart. **Error Message** -The session does not exist +The session does not exist. **Description** @@ -44,7 +44,7 @@ The session has been destroyed, and no session record exists on the server. **Error Message** -The session controller does not exist +The session controller does not exist. **Description** @@ -62,7 +62,7 @@ Query the session record and create the corresponding controller. **Error Message** -The remote session connection failed +The remote session connection failed. **Description** @@ -80,7 +80,7 @@ Stop sending control commands to the session. Subscribe to output device changes **Error Message** -Invalid session command +Invalid session command. **Description** @@ -98,7 +98,7 @@ Stop sending the command or event. Query the commands supported by the session, **Error Message** -The session not active +The session is not activated. **Description** @@ -116,7 +116,7 @@ Stop sending the command or event. Subscribe to the session activation status, a **Error Message** -Command or event overload +Too many commands or events. **Description**