未验证 提交 e9b682eb 编写于 作者: O openharmony_ci 提交者: Gitee

!6536 翻译完成:6418 【轻量级 PR】:update zh-cn/application-dev/device/sensor-guidelines.md.

Merge pull request !6536 from wusongqing/TR6418
...@@ -34,40 +34,52 @@ ...@@ -34,40 +34,52 @@
1. To obtain data from a type of sensor, configure the requested permissions in the **config.json** file. 1. To obtain data from a type of sensor, configure the requested permissions in the **config.json** file.
``` ```
"reqPermissions":[ "reqPermissions": [
{ {
"name":"ohos.permission.ACCELEROMETER", "name": "ohos.permission.ACCELEROMETER",
"reason"":"", "reason": "",
"usedScene":{ "usedScene": {
"ability": ["sensor.index.MainAbility",".MainAbility"], "ability": [
"when":"inuse" "sensor.index.MainAbility",
} ".MainAbility"
}, ],
{ "when": "inuse"
"name":"ohos.permission.GYROSCOPE", }
"reason"":"", },
"usedScene":{ {
"ability": ["sensor.index.MainAbility",".MainAbility"], "name": "ohos.permission.GYROSCOPE",
"when":"inuse" "reason": "",
} "usedScene": {
}, "ability": [
{ "sensor.index.MainAbility",
"name":"ohos.permission.ACTIVITY_MOTION", ".MainAbility"
"reason"":"ACTIVITY_MOTION_TEST", ],
"usedScene":{ "when": "inuse"
"ability": ["sensor.index.MainAbility",".MainAbility"], }
"when":"inuse" },
} {
}, "name": "ohos.permission.ACTIVITY_MOTION",
{ "reason": "ACTIVITY_MOTION_TEST",
"name":"ohos.permission.READ_HEALTH_DATA", "usedScene": {
"reason"":"HEALTH_DATA_TEST", "ability": [
"usedScene":{ "sensor.index.MainAbility",
"ability": ["sensor.index.MainAbility",".MainAbility"], ".MainAbility"
"when":"inuse" ],
} "when": "inuse"
}, }
] },
{
"name": "ohos.permission.READ_HEALTH_DATA",
"reason": "HEALTH_DATA_TEST",
"usedScene": {
"ability": [
"sensor.index.MainAbility",
".MainAbility"
],
"when": "inuse"
}
}
]
``` ```
2. Subscribe to data changes of a type of sensor. 2. Subscribe to data changes of a type of sensor.
...@@ -75,7 +87,7 @@ ...@@ -75,7 +87,7 @@
``` ```
import sensor from "@ohos.sensor" import sensor from "@ohos.sensor"
sensor.on(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data){ sensor.on(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data){
console.info("Subscription succeeded. data = "+ data); // The call is successful, and the obtained sensor data is printed. console.info("Subscription succeeded. data = " + data); // The call is successful, and the obtained sensor data is printed.
} }
); );
``` ```
...@@ -127,4 +139,4 @@ ...@@ -127,4 +139,4 @@
The following sample is provided to help you better understand how to develop sensors: The following sample is provided to help you better understand how to develop sensors:
- [`Sensor`: sensor (eTS, API 8)](https://gitee.com/openharmony/app_samples/tree/master/device/Sensor) - [`Sensor`: sensor (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/device/Sensor)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册