提交 8bfe0ac4 编写于 作者: Z zhongyuyan 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into master

Signed-off-by: Nzhongyuyan <zhongyuyan1@huawei.com>
...@@ -224,8 +224,9 @@ zh-cn/application-dev/background-agent-scheduled-reminder/ @RayShih ...@@ -224,8 +224,9 @@ zh-cn/application-dev/background-agent-scheduled-reminder/ @RayShih
zh-cn/application-dev/background-task-management/ @ningningW @wangwenli_wolf @tangtiantian2021 @nan-xiansen zh-cn/application-dev/background-task-management/ @ningningW @wangwenli_wolf @tangtiantian2021 @nan-xiansen
zh-cn/application-dev/work-scheduler/ @ningningW zh-cn/application-dev/work-scheduler/ @ningningW
zh-cn/application-dev/internationalization/ @ningningW @Buda-Liu @mengjingzhimo @yangqing3 zh-cn/application-dev/internationalization/ @ningningW @Buda-Liu @mengjingzhimo @yangqing3
zh-cn/application-dev/device/usb-overview.md @ge-yafang @jasonyujia @andeszhang @liuhonggang123 zh-cn/application-dev/device/usb-overview.md @ge-yafang @Kevin-Lau @liuhonggang123
zh-cn/application-dev/device/usb-guidelines.md @ge-yafang @jasonyujia @andeszhang @liuhonggang123 zh-cn/application-dev/device/usb-guidelines.md @ge-yafang @Kevin-Lau @liuhonggang123
zh-cn/application-dev/napi/usb-ddk-guidelines.md @ge-yafang @Kevin-Lau @liuhonggang123
zh-cn/application-dev/device/device-location-overview.md @RayShih zh-cn/application-dev/device/device-location-overview.md @RayShih
zh-cn/application-dev/device/device-location-info.md @RayShih zh-cn/application-dev/device/device-location-info.md @RayShih
zh-cn/application-dev/device/device-location-geocoding.md @RayShih zh-cn/application-dev/device/device-location-geocoding.md @RayShih
...@@ -499,9 +500,9 @@ zh-cn/application-dev/reference/apis/js-apis-uitest.md @inter515 @ningningW @int ...@@ -499,9 +500,9 @@ zh-cn/application-dev/reference/apis/js-apis-uitest.md @inter515 @ningningW @int
zh-cn/application-dev/reference/apis/js-apis-update.md @hughes802 @ningningW @zhangzhengxue @mamba-ting zh-cn/application-dev/reference/apis/js-apis-update.md @hughes802 @ningningW @zhangzhengxue @mamba-ting
zh-cn/application-dev/reference/apis/js-apis-uri.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-uri.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-url.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-url.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-usbManager.md @jasonyujia @ge-yafang @andeszhang @liuhonggang123 zh-cn/application-dev/reference/apis/js-apis-usbManager.md @ge-yafang @Kevin-Lau @liuhonggang123
zh-cn/application-dev/reference/apis/js-apis-usb.md @jasonyujia @ge-yafang @andeszhang @liuhonggang123 zh-cn/application-dev/reference/apis/js-apis-usb.md @ge-yafang @Kevin-Lau @liuhonggang123
zh-cn/application-dev/reference/apis/js-apis-usb-deprecated.md @jasonyujia @ge-yafang @andeszhang @liuhonggang123 zh-cn/application-dev/reference/apis/js-apis-usb-deprecated.md @ge-yafang @Kevin-Lau @liuhonggang123
zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md @gaoyong @zengyawen @niejiteng @jumozhanjiang zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md @gaoyong @zengyawen @niejiteng @jumozhanjiang
zh-cn/application-dev/reference/apis/js-apis-util.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-util.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-vector.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-vector.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
......
...@@ -11,6 +11,12 @@ ...@@ -11,6 +11,12 @@
- 支持应用兼容性检测。 - 支持应用兼容性检测。
- 支持应用根据实际使用场景动态设置迁移状态(默认迁移状态为ACTIVE激活状态)。如编辑类应用在编辑文本的页面下才需要迁移,其他页面不需要迁移,则可以通过[setMissionContinueState](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissioncontinuestate10)进行控制。
- 支持应用动态选择是否进行页面栈恢复(默认进行页面栈信息恢复)。如应用希望自定义迁移到其他设备后显示的页面,则可以通过[SUPPORT_CONTINUE_PAGE_STACK_KEY](../reference/apis/js-apis-app-ability-wantConstant.md#wantconstantparams)进行控制。
- 支持应用动态选择流转成功后是否退出迁移发起端应用(默认流转成功后退出迁移发起端应用)。则可以通过[SUPPORT_CONTINUE_SOURCE_EXIT_KEY](../reference/apis/js-apis-app-ability-wantConstant.md#wantconstantparams)进行控制。
## 跨端迁移流程 ## 跨端迁移流程
...@@ -125,3 +131,63 @@ ...@@ -125,3 +131,63 @@
} }
``` ```
- 如果是单实例应用,则采用同样的代码实现onNewWant()接口即可。 - 如果是单实例应用,则采用同样的代码实现onNewWant()接口即可。
6. **可选配置:** 在应用支持迁移特性时,默认开启应用迁移状态开关,根据应用当前任务获取焦点/失去焦点通知周边的可信设备当前任务可流转/取消流转。若应用需要在特定场景下才通知周边设备可流转,则需要在应用打开时设置迁移状态为INACTIVE,在后续的业务流程中需要迁移时再设置迁移状态为ACTIVE。接口见[setMissionContinueState](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissioncontinuestate10)
- 示例:应用启动不需要流转
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
onCreate(want, launchParam) {
this.context.setMissionContinueState(AbilityConstant.ContinueState.INACTIVE, (result) => {
console.info(`setMissionContinueState: ${JSON.stringify(result)}`);
});
}
```
- 示例:应用在后续的业务流程中需要流转了
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
this.context.setMissionContinueState(AbilityConstant.ContinueState.ACTIVE, (result) => {
console.info(`setMissionContinueState: ${JSON.stringify(result)}`);
});
```
7. **可选配置:** 支持应用动态选择是否进行页面栈恢复(默认进行页面栈信息恢复)。如果应用不想使用系统默认恢复的页面栈,则可以设置不进行页面栈迁移,而需要在`onWindowStageRestore`设置流转后进入的页面,参数定义见[SUPPORT_CONTINUE_PAGE_STACK_KEY](../reference/apis/js-apis-app-ability-wantConstant.md#wantconstantparams)
- 示例:应用迁移不需要自动流转页面栈信息
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import wantConstant from '@ohos.app.ability.wantConstant.d.ts';
onContinue(wantParam : {[key: string]: any}) {
console.info(`onContinue version = ${wantParam.version}, targetDevice: ${wantParam.targetDevice}`)
wantParam[wantConstant.SUPPORT_CONTINUE_PAGE_STACK_KEY] = false;
return AbilityConstant.OnContinueResult.AGREE;
}
onWindowStageRestore(windowStage) {
// 若不需要自动流转页面栈信息,则需要在此处设置应用流转后进入的页面
windowStage.setUIContent(this.contex, "pages/index", null);
}
```
8. **可选配置:** 支持应用动态选择迁移成功后是否退出迁移发起端应用(默认流转成功后退出迁移发起端应用)。如果应用不想让系统自动退出迁移发起端应用,则可以设置不退出,参数定义见参数定义见[SUPPORT_CONTINUE_SOURCE_EXIT_KEY](../reference/apis/js-apis-app-ability-wantConstant.md#wantconstantparams)
- 示例:应用迁移设置不需要迁移成功后退出迁移发起端应用
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import wantConstant from '@ohos.app.ability.wantConstant.d.ts';
onContinue(wantParam : {[key: string]: any}) {
console.info(`onContinue version = ${wantParam.version}, targetDevice: ${wantParam.targetDevice}`)
wantParam[wantConstant.SUPPORT_CONTINUE_SOURCE_EXIT_KEY] = false;
return AbilityConstant.OnContinueResult.AGREE;
}
```
\ No newline at end of file
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
- **跨端迁移** - **跨端迁移**
在用户使用设备的过程中,当使用情境发生变化时(例如从室内走到户外或者周围有更合适的设备等),之前使用的设备可能已经不适合继续当前的任务,此时,用户可以选择新的设备来继续当前的任务,原设备退出任务,这就是跨端迁移场景。常见的跨端迁移场景实例:在平板上播放的视频,迁移到智慧屏继续播放,从而获得更佳的观看体验;平板上的视频应用退出。在应用开发层面,跨端迁移指在A端运行的UIAbility迁移到B端上,完成迁移后, B端UIAbility继续任务,而A端UIAbility退出。 在用户使用设备的过程中,当使用情境发生变化时(例如从室内走到户外或者周围有更合适的设备等),之前使用的设备可能已经不适合继续当前的任务,此时,用户可以选择新的设备来继续当前的任务,原设备可按需决定是否退出任务,这就是跨端迁移场景。常见的跨端迁移场景实例:在平板上播放的视频,迁移到智慧屏继续播放,从而获得更佳的观看体验;平板上的视频应用退出。在应用开发层面,跨端迁移指在A端运行的UIAbility迁移到B端上,完成迁移后, B端UIAbility继续任务,而A端UIAbility可按需决定是否退出。
- **多端协同** - **多端协同**
用户拥有的多个设备,可以作为一个整体,为用户提供比单设备更加高效、沉浸的体验,这就是多端协同场景。常见的多端协同场景实例:平板侧应用A做答题板,智慧屏侧应用B做直播,为用户提供更优的上网课体验。在应用开发层面,多端协同指多端上的不同UIAbility/ServiceExtensionAbility同时运行、或者交替运行实现完整的业务;或者多端上的相同UIAbility/ServiceExtensionAbility同时运行实现完整的业务。 用户拥有的多个设备,可以作为一个整体,为用户提供比单设备更加高效、沉浸的体验,这就是多端协同场景。常见的多端协同场景实例:场景一:两台设备A和B打开备忘录同一篇笔记进行双端协同编辑,在设备A上可以使用本地图库中的图片资源插入编辑,设备B上进行文字内容编辑。场景二:设备A上正在和客户进行聊天,客户需要的资料在设备B上,可以通过聊天软件打开设备B上的文档应用选择到想要的资料回传到设备A上,然后通过聊天软件发送给客户。在应用开发层面,多端协同指多端上的不同UIAbility/ServiceExtensionAbility同时运行、或者交替运行实现完整的业务;或者多端上的相同UIAbility/ServiceExtensionAbility同时运行实现完整的业务。
## 流转架构 ## 流转架构
......
...@@ -33,10 +33,11 @@ ...@@ -33,10 +33,11 @@
2. 以下场景以加速度传感器ACCELEROMETER为例。展示持续监听传感器接口的调用结果。 2. 以下场景以加速度传感器ACCELEROMETER为例。展示持续监听传感器接口的调用结果。
```js ```ts
import sensor from "@ohos.sensor"; import sensor from "@ohos.sensor";
sensor.on(sensor.SensorId.ACCELEROMETER, function(data){
console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z); // 获取数据成功 sensor.on(sensor.SensorId.ACCELEROMETER, function (data) {
console.info("Succeeded in obtaining data. x: " + data.x + "y: " + data.y + "z: " + data.z); // 获取数据成功
}); });
``` ```
...@@ -44,7 +45,7 @@ ...@@ -44,7 +45,7 @@
3. 注销传感器数据监听。 3. 注销传感器数据监听。
```js ```ts
import sensor from "@ohos.sensor"; import sensor from "@ohos.sensor";
sensor.off(sensor.SensorId.ACCELEROMETER); sensor.off(sensor.SensorId.ACCELEROMETER);
``` ```
...@@ -53,10 +54,11 @@ ...@@ -53,10 +54,11 @@
4. 获取一次传感器数据变化。 4. 获取一次传感器数据变化。
```js ```ts
import sensor from "@ohos.sensor"; import sensor from "@ohos.sensor";
sensor.once(sensor.SensorId.ACCELEROMETER, function(data) {
console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z); // 获取数据成功 sensor.once(sensor.SensorId.ACCELEROMETER, function (data) {
console.info("Succeeded in obtaining data. x: " + data.x + "y: " + data.y + "z: " + data.z); // 获取数据成功
}); });
``` ```
...@@ -64,13 +66,14 @@ ...@@ -64,13 +66,14 @@
若接口调用不成功,建议使用try/catch语句捕获代码中可能出现的错误信息。例如: 若接口调用不成功,建议使用try/catch语句捕获代码中可能出现的错误信息。例如:
```js ```ts
import sensor from "@ohos.sensor"; import sensor from "@ohos.sensor";
try { try {
sensor.once(sensor.SensorId.ACCELEROMETER, function(data) { sensor.once(sensor.SensorId.ACCELEROMETER, function (data) {
console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z); // 获取数据成功 console.info("Succeeded in obtaining data. x: " + data.x + "y: " + data.y + "z: " + data.z); // 获取数据成功
}); });
} catch (error) { } catch (error) {
console.error("Get sensor data error. data:" + error.data, " msg:", error.message); console.error(`Failed to get sensor data. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -110,8 +110,9 @@ Json文件共包含2个属性。 ...@@ -110,8 +110,9 @@ Json文件共包含2个属性。
2. 根据指定振动效果和振动属性触发马达振动。 2. 根据指定振动效果和振动属性触发马达振动。
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
try { try {
vibrator.startVibration({ // 使用startVibration需要添加ohos.permission.VIBRATE权限 vibrator.startVibration({ // 使用startVibration需要添加ohos.permission.VIBRATE权限
type: 'time', type: 'time',
...@@ -121,37 +122,38 @@ try { ...@@ -121,37 +122,38 @@ try {
usage: 'alarm' usage: 'alarm'
}, (error) => { }, (error) => {
if (error) { if (error) {
console.error('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message); console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
return; return;
} }
console.log('Callback returned to indicate a successful vibration.'); console.info('Succeed in starting vibration.');
}); });
} catch (err) { } catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`An unexpected error occurred. Code: ${err.code}, message: ${err.message}`);
} }
``` ```
3. 按照指定模式停止马达的振动。 3. 按照指定模式停止马达的振动。
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
try { try {
// 按照VIBRATOR_STOP_MODE_TIME模式停止振动, 使用stopVibration需要添加ohos.permission.VIBRATE权限 // 按照VIBRATOR_STOP_MODE_TIME模式停止振动, 使用stopVibration需要添加ohos.permission.VIBRATE权限
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) { vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) {
if (error) { if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
return; return;
} }
console.log('Callback returned to indicate successful.'); console.info('Succeeded in stopping vibration.');
}) })
} catch (err) { } catch (err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`An unexpected error occurred. Code: ${err.code}, message: ${err.message}`);
} }
``` ```
4. 停止所有模式的马达振动。 4. 停止所有模式的马达振动。
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
// 使用startVibration、stopVibration需要添加ohos.permission.VIBRATE权限 // 使用startVibration、stopVibration需要添加ohos.permission.VIBRATE权限
try { try {
...@@ -163,36 +165,37 @@ try { ...@@ -163,36 +165,37 @@ try {
usage: 'alarm' usage: 'alarm'
}, (error) => { }, (error) => {
if (error) { if (error) {
console.error('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message); console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
return; return;
} }
console.log('Callback returned to indicate a successful vibration.'); console.info('Succeed in starting vibration');
}); });
// 停止所有类型的马达振动 // 停止所有类型的马达振动
vibrator.stopVibration(function (error) { vibrator.stopVibration(function (error) {
if (error) { if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
return; return;
} }
console.log('Callback returned to indicate successful.'); console.info('Succeed in stopping vibration');
}) })
} catch (error) { } catch (error) {
console.info('errCode: ' + error.code + ' ,msg: ' + error.message); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
5. 查询是否支持传入的参数effectId。 5. 查询是否支持传入的参数effectId。
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
try { try {
// 查询是否支持'haptic.clock.timer' // 查询是否支持'haptic.clock.timer'
vibrator.isSupportEffect('haptic.clock.timer', function (err, state) { vibrator.isSupportEffect('haptic.clock.timer', function (err, state) {
if (err) { if (err) {
console.error('isSupportEffect failed, error:' + JSON.stringify(err)); console.error(`Failed to query effect. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.log('The effectId is ' + (state ? 'supported' : 'unsupported')); console.info('Succeed in querying effect');
if (state) { if (state) {
try { try {
vibrator.startVibration({ // 使用startVibration需要添加ohos.permission.VIBRATE权限 vibrator.startVibration({ // 使用startVibration需要添加ohos.permission.VIBRATE权限
...@@ -202,79 +205,67 @@ try { ...@@ -202,79 +205,67 @@ try {
}, { }, {
usage: 'unknown' usage: 'unknown'
}, (error) => { }, (error) => {
if(error) { if (error) {
console.error('haptic.clock.timer vibrator error:' + JSON.stringify(error)); console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
} else { } else {
console.log('haptic.clock.timer vibrator success'); console.info('Succeed in starting vibration');
} }
}); });
} catch (error) { } catch (error) {
console.error('Exception in, error:' + JSON.stringify(error)); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
} }
} }
}) })
} catch (error) { } catch (error) {
console.error('Exception in, error:' + JSON.stringify(error)); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
6. 启动和停止自定义振动 6. 启动和停止自定义振动
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
import resourceManager from '@ohos.resourceManager';
const FILE_NAME = "xxx.json"; const FILE_NAME = "xxx.json";
async function openResource(fileName) {
let fileDescriptor = undefined;
let mgr = await resourceManager.getResourceManager();
await mgr.getRawFd(fileName).then(value => {
fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length};
console.log('openResource success fileName: ' + fileName);
}).catch(error => {
console.log('openResource err: ' + error);
});
return fileDescriptor;
}
async function closeResource(fileName) {
let mgr = await resourceManager.getResourceManager();
await mgr.closeRawFd(fileName).then(()=> {
console.log('closeResource success fileName: ' + fileName);
}).catch(error => {
console.log('closeResource err: ' + error);
});
}
// 获取振动文件资源描述符 // 获取振动文件资源描述符
let rawFd = openResource(FILE_NAME); let fileDescriptor = undefined;
getContext().resourceManager.getRawFd(FILE_NAME).then(value => {
fileDescriptor = { fd: value.fd, offset: value.offset, length: value.length };
console.info('Succeed in getting resource file descriptor');
}).catch(error => {
console.error(`Failed to get resource file descriptor. Code: ${error.code}, message: ${error.message}`);
});
// 使用startVibration、stopVibration需要添加ohos.permission.VIBRATE权限 // 使用startVibration、stopVibration需要添加ohos.permission.VIBRATE权限
try { try {
// 启动自定义振动 // 启动自定义振动
vibrator.startVibration({ vibrator.startVibration({
type: "file", type: "file",
hapticFd: { fd: rawFd.fd, offset: rawFd.offset, length: rawFd.length } hapticFd: { fd: fileDescriptor.fd, offset: fileDescriptor.offset, length: fileDescriptor.length }
}, { }, {
usage: "alarm" usage: "alarm"
}).then(() => { }).then(() => {
console.info('startVibration success'); console.info('Succeed in starting vibration');
}, (error) => { }, (error) => {
console.info('startVibration error'); console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
}); });
// 停止所有类型的马达振动 // 停止所有类型的马达振动
vibrator.stopVibration(function (error) { vibrator.stopVibration(function (error) {
if (error) { if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
return; return;
} }
console.log('Callback returned to indicate successful.'); console.info('Succeed in stopping vibration');
}) })
} catch (error) { } catch (error) {
console.info('errCode: ' + error.code + ' ,msg: ' + error.message); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
} }
// 关闭振动文件资源 // 关闭振动文件资源
closeResource(FILE_NAME); getContext().resourceManager.closeRawFd(FILE_NAME).then(() => {
console.info('Succeed in closing resource file descriptor');
}).catch(error => {
console.error(`Failed to close resource file descriptor. Code: ${error.code}, message: ${error.message}`);
});
``` ```
......
...@@ -3,9 +3,13 @@ ...@@ -3,9 +3,13 @@
- [Native API在应用工程中的使用指导](napi-guidelines.md) - [Native API在应用工程中的使用指导](napi-guidelines.md)
- [Drawing开发指导](drawing-guidelines.md) - [Drawing开发指导](drawing-guidelines.md)
- [Rawfile开发指导](rawfile-guidelines.md) - [Rawfile开发指导](rawfile-guidelines.md)
- [NativeBuffer开发指导](native-buffer-guidelines.md)
- [NativeImage开发指导](native-image-guidelines.md)
- [NativeVsync开发指导](native-vsync-guidelines.md)
- [NativeWindow开发指导](native-window-guidelines.md) - [NativeWindow开发指导](native-window-guidelines.md)
- [使用MindSpore Lite引擎进行模型推理](mindspore-lite-guidelines.md) - [使用MindSpore Lite引擎进行模型推理](mindspore-lite-guidelines.md)
- [使用MindSpore Lite进行离线模型的转换及推理](mindspore-lite-offline-model-guidelines.md) - [使用MindSpore Lite进行离线模型的转换及推理](mindspore-lite-offline-model-guidelines.md)
- [Neural Network Runtime对接AI推理框架开发指导](neural-network-runtime-guidelines.md) - [Neural Network Runtime对接AI推理框架开发指导](neural-network-runtime-guidelines.md)
- [Purgeable memory开发指导](purgeable-memory-guidelines.md) - [Purgeable memory开发指导](purgeable-memory-guidelines.md)
- [XComponent开发指导](xcomponent-guidelines.md) - [XComponent开发指导](xcomponent-guidelines.md)
- [USB DDK开发指导](usb-ddk-guidelines.md)
\ No newline at end of file
...@@ -418,7 +418,7 @@ ...@@ -418,7 +418,7 @@
- [@ohos.enterprise.dateTimeManager (系统时间管理)](js-apis-enterprise-dateTimeManager.md) - [@ohos.enterprise.dateTimeManager (系统时间管理)](js-apis-enterprise-dateTimeManager.md)
- [@ohos.enterprise.deviceControl (设备控制管理)](js-apis-enterprise-deviceControl.md) - [@ohos.enterprise.deviceControl (设备控制管理)](js-apis-enterprise-deviceControl.md)
- [@ohos.enterprise.deviceInfo (设备信息管理)](js-apis-enterprise-deviceInfo.md) - [@ohos.enterprise.deviceInfo (设备信息管理)](js-apis-enterprise-deviceInfo.md)
- [@ohos.enterprise.deviceSettings (设备设置管理)](js-apis-enterprise-deviceSetings.md) - [@ohos.enterprise.deviceSettings (设备设置管理)](js-apis-enterprise-deviceSettings.md)
- [@ohos.enterprise.EnterpriseAdminExtensionAbility (企业设备管理扩展能力)](js-apis-EnterpriseAdminExtensionAbility.md) - [@ohos.enterprise.EnterpriseAdminExtensionAbility (企业设备管理扩展能力)](js-apis-EnterpriseAdminExtensionAbility.md)
- [@ohos.enterprise.networkManager (网络管理)](js-apis-enterprise-networkManager.md) - [@ohos.enterprise.networkManager (网络管理)](js-apis-enterprise-networkManager.md)
- [@ohos.enterprise.wifiManager (WiFi管理)](js-apis-enterprise-wifiManager.md) - [@ohos.enterprise.wifiManager (WiFi管理)](js-apis-enterprise-wifiManager.md)
......
...@@ -224,3 +224,24 @@ class MyAbility extends UIAbility { ...@@ -224,3 +224,24 @@ class MyAbility extends UIAbility {
} }
} }
``` ```
## AbilityConstant.ContinueState<sup>10+</sup>
ContinueState说明枚举值。用于表示当前应用任务流转的状态。可配合[UIAbilityContext](js-apis-inner-application-uiAbilityContext.md)[setMissionContinueState](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissioncontinuestate10)方法进行设置。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 值 | 说明 |
| ------------- | --------- | ------------------------------------------------------------ |
| ACTIVE | 0 | 指示当前应用任务流转处于激活状态。 |
| INACTIVE | 1 | 指示当前应用任务流转处于未激活状态。 |
**示例:**
```ts
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
this.context.setMissionContinueState(AbilityConstant.ContinueState.INACTIVE, (result) => {
console.info(`setMissionContinueState: ${JSON.stringify(result)}`);
});
```
\ No newline at end of file
...@@ -30,6 +30,8 @@ want的Params操作的常量。 ...@@ -30,6 +30,8 @@ want的Params操作的常量。
| CONTENT_TITLE_KEY<sup>10+</sup> | ohos.extra.param.key.contentTitle | 指示原子化服务支持分享标题的参数的操作。 | | CONTENT_TITLE_KEY<sup>10+</sup> | ohos.extra.param.key.contentTitle | 指示原子化服务支持分享标题的参数的操作。 |
| SHARE_ABSTRACT_KEY<sup>10+</sup> | ohos.extra.param.key.shareAbstract | 指示原子化服务支持分享内容的参数的操作。 | | SHARE_ABSTRACT_KEY<sup>10+</sup> | ohos.extra.param.key.shareAbstract | 指示原子化服务支持分享内容的参数的操作。 |
| SHARE_URL_KEY<sup>10+</sup> | ohos.extra.param.key.shareUrl | 指示原子化服务支持分享链接的参数的操作。 | | SHARE_URL_KEY<sup>10+</sup> | ohos.extra.param.key.shareUrl | 指示原子化服务支持分享链接的参数的操作。 |
| SUPPORT_CONTINUE_PAGE_STACK_KEY<sup>10+</sup> | ohos.extra.param.key.supportContinuePageStack | 指示在跨端迁移过程中是否迁移页面栈信息,默认值为true,自动迁移页面栈信息。|
| SUPPORT_CONTINUE_SOURCE_EXIT_KEY<sup>10+</sup> | ohos.extra.param.key.supportContinueSourceExit | 指示跨端迁移源端应用是否退出,默认值为true,源端应用自动退出。|
## wantConstant.Flags ## wantConstant.Flags
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
> - 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > - 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> >
> - 从API Version 9开始,该接口不再维护,推荐使用新接口[`@ohos.data.preferences`](js-apis-data-preferences.md)。 > - 从API Version 9开始,该接口不再维护,推荐使用新接口[`@ohos.data.preferences`](js-apis-data-preferences.md)。
>
> - 本模块接口仅可在FA模型下使用。
## 导入模块 ## 导入模块
......
...@@ -2213,6 +2213,82 @@ setMissionIcon(icon: image.PixelMap): Promise\<void>; ...@@ -2213,6 +2213,82 @@ setMissionIcon(icon: image.PixelMap): Promise\<void>;
console.error(`setMissionLabel failed, code is ${err.code}, message is ${err.message}`); console.error(`setMissionLabel failed, code is ${err.code}, message is ${err.message}`);
}); });
``` ```
## UIAbilityContext.setMissionContinueState<sup>10+</sup>
setMissionContinueState(state: AbilityConstant.ContinueState, callback:AsyncCallback&lt;void&gt;): void;
设置UIAbility任务中流转状态(callback形式)。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| state | [ContinueState](js-apis-app-ability-abilityConstant.md#abilityconstantcontinuestate10) | 是 | 流转状态。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,返回接口调用是否成功的结果。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
**示例:**
```ts
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
this.context.setMissionContinueState(AbilityConstant.ContinueState.INACTIVE, (result) => {
console.info(`setMissionContinueState: ${JSON.stringify(result)}`);
});
```
## UIAbilityContext.setMissionContinueState<sup>10+</sup>
setMissionContinueState(state: AbilityConstant.ContinueState): Promise&lt;void&gt;;
设置UIAbility任务中流转状态(promise形式)。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| state | [ContinueState](js-apis-app-ability-abilityConstant.md#abilityconstantcontinuestate10) | 是 | 流转状态。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 返回一个Promise,包含接口的结果。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
**示例:**
```ts
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
this.context.setMissionContinueState(AbilityConstant.ContinueState.INACTIVE).then(() => {
console.info('success');
}).catch((err) => {
console.error(`setMissionContinueState failed, code is ${err.code}, message is ${err.message}`);
});
```
## UIAbilityContext.restoreWindowStage ## UIAbilityContext.restoreWindowStage
restoreWindowStage(localStorage: LocalStorage) : void; restoreWindowStage(localStorage: LocalStorage) : void;
......
...@@ -1300,7 +1300,7 @@ setData(data: PasteData, callback: AsyncCallback&lt;void&gt;): void ...@@ -1300,7 +1300,7 @@ setData(data: PasteData, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
let pasteData = pasteboard.createPlainTextData('content'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'content');
let systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setData(pasteData, (err, data) => { systemPasteboard.setData(pasteData, (err, data) => {
if (err) { if (err) {
...@@ -1343,7 +1343,7 @@ setData(data: PasteData): Promise&lt;void&gt; ...@@ -1343,7 +1343,7 @@ setData(data: PasteData): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
let pasteData = pasteboard.createPlainTextData('content'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'content');
let systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setData(pasteData).then((data) => { systemPasteboard.setData(pasteData).then((data) => {
console.info('Succeeded in setting PasteData.'); console.info('Succeeded in setting PasteData.');
......
...@@ -9,7 +9,7 @@ sensor模块提供了获取传感器数据的能力,包括获取传感器属 ...@@ -9,7 +9,7 @@ sensor模块提供了获取传感器数据的能力,包括获取传感器属
## 导入模块 ## 导入模块
```js ```ts
import sensor from '@ohos.sensor'; import sensor from '@ohos.sensor';
``` ```
## sensor.on ## sensor.on
...@@ -42,14 +42,14 @@ on(type: SensorId.COLOR, callback: Callback\<ColorResponse>,options?: Options): ...@@ -42,14 +42,14 @@ on(type: SensorId.COLOR, callback: Callback\<ColorResponse>,options?: Options):
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.COLOR, function (data) { sensor.on(sensor.SensorId.COLOR, function (data) {
console.info('The intensity of light: ' + data.lightIntensity); console.info('Succeeded in getting the intensity of light: ' + data.lightIntensity);
console.info('The color temperature: ' + data.colorTemperature); console.info('Succeeded in getting the color temporature: ' + data.colorTemperature);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -81,13 +81,13 @@ on(type: SensorId.SAR, callback: Callback\<SarResponse>,options?: Options): void ...@@ -81,13 +81,13 @@ on(type: SensorId.SAR, callback: Callback\<SarResponse>,options?: Options): void
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.SAR, function (data) { sensor.on(sensor.SensorId.SAR, function (data) {
console.info('Specific absorption rate : ' + data.absorptionRatio); console.info('Succeeded in getting specific absorption rate : ' + data.absorptionRatio);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -119,15 +119,15 @@ on(type: SensorId.ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt; ...@@ -119,15 +119,15 @@ on(type: SensorId.ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.ACCELEROMETER, function (data) { sensor.on(sensor.SensorId.ACCELEROMETER, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -159,18 +159,18 @@ on(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback&lt;Acceleromete ...@@ -159,18 +159,18 @@ on(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback&lt;Acceleromete
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, function (data) { sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking on. X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking on. Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking on. Z-coordinate bias: ' + data.biasZ);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -200,13 +200,13 @@ on(type: SensorId.AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;, option ...@@ -200,13 +200,13 @@ on(type: SensorId.AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;, option
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.AMBIENT_LIGHT, function (data) { sensor.on(sensor.SensorId.AMBIENT_LIGHT, function (data) {
console.info('The ambient light intensity: ' + data.intensity); console.info('Succeeded in getting the ambient light intensity: ' + data.intensity);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -236,13 +236,13 @@ on(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback&lt;AmbientTemperatureR ...@@ -236,13 +236,13 @@ on(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback&lt;AmbientTemperatureR
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, function (data) { sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, function (data) {
console.info('Temperature: ' + data.temperature); console.info('Succeeded in invoking on. Temperature: ' + data.temperature);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -272,13 +272,13 @@ on(type: SensorId.BAROMETER, callback: Callback&lt;BarometerResponse&gt;, option ...@@ -272,13 +272,13 @@ on(type: SensorId.BAROMETER, callback: Callback&lt;BarometerResponse&gt;, option
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.BAROMETER, function (data) { sensor.on(sensor.SensorId.BAROMETER, function (data) {
console.info('Atmospheric pressure: ' + data.pressure); console.info('Succeeded in invoking on. Atmospheric pressure: ' + data.pressure);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -308,15 +308,15 @@ on(type: SensorId.GRAVITY, callback: Callback&lt;GravityResponse&gt;,options?: O ...@@ -308,15 +308,15 @@ on(type: SensorId.GRAVITY, callback: Callback&lt;GravityResponse&gt;,options?: O
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.GRAVITY, function (data) { sensor.on(sensor.SensorId.GRAVITY, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -348,15 +348,15 @@ on(type: SensorId.GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;,options ...@@ -348,15 +348,15 @@ on(type: SensorId.GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;,options
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.GYROSCOPE, function (data) { sensor.on(sensor.SensorId.GYROSCOPE, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -389,18 +389,18 @@ on(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback&lt;GyroscopeUncalib ...@@ -389,18 +389,18 @@ on(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback&lt;GyroscopeUncalib
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, function (data) { sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking on. X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking on. Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking on. Z-coordinate bias: ' + data.biasZ);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -430,13 +430,13 @@ on(type: SensorId.HALL, callback: Callback&lt;HallResponse&gt;, options?: Option ...@@ -430,13 +430,13 @@ on(type: SensorId.HALL, callback: Callback&lt;HallResponse&gt;, options?: Option
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.HALL, function (data) { sensor.on(sensor.SensorId.HALL, function (data) {
console.info('Hall status: ' + data.status); console.info('Succeeded in invoking on. Hall status: ' + data.status);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -468,13 +468,13 @@ on(type: SensorId.HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;,option ...@@ -468,13 +468,13 @@ on(type: SensorId.HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;,option
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.HEART_RATE, function (data) { sensor.on(sensor.SensorId.HEART_RATE, function (data) {
console.info('Heart rate: ' + data.heartRate); console.info('Succeeded in invoking on. Heart rate: ' + data.heartRate);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -504,13 +504,13 @@ on(type: SensorId.HUMIDITY, callback: Callback&lt;HumidityResponse&gt;,options?: ...@@ -504,13 +504,13 @@ on(type: SensorId.HUMIDITY, callback: Callback&lt;HumidityResponse&gt;,options?:
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.HUMIDITY, function (data) { sensor.on(sensor.SensorId.HUMIDITY, function (data) {
console.info('Humidity: ' + data.humidity); console.info('Succeeded in invoking on. Humidity: ' + data.humidity);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -543,15 +543,15 @@ on(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback&lt;LinearAcceleromete ...@@ -543,15 +543,15 @@ on(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback&lt;LinearAcceleromete
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, function (data) { sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -581,15 +581,15 @@ on(type: SensorId.MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt ...@@ -581,15 +581,15 @@ on(type: SensorId.MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.MAGNETIC_FIELD, function (data) { sensor.on(sensor.SensorId.MAGNETIC_FIELD, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -619,18 +619,18 @@ on(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback&lt;MagneticFie ...@@ -619,18 +619,18 @@ on(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback&lt;MagneticFie
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, function (data) { sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking on. X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking on. Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking on. Z-coordinate bias: ' + data.biasZ);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -660,15 +660,15 @@ on(type: SensorId.ORIENTATION, callback: Callback&lt;OrientationResponse&gt;,opt ...@@ -660,15 +660,15 @@ on(type: SensorId.ORIENTATION, callback: Callback&lt;OrientationResponse&gt;,opt
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.ORIENTATION, function (data) { sensor.on(sensor.SensorId.ORIENTATION, function (data) {
console.info('The device rotates at an angle around the Z axis: ' + data.alpha); console.info('Succeeded in the device rotating at an angle around the Z axis: ' + data.alpha);
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('Succeeded in the device rotating 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('Succeeded in the device rotating at an angle around the Y axis: ' + data.gamma);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -700,13 +700,13 @@ on(type: SensorId.PEDOMETER, callback: Callback&lt;PedometerResponse&gt;, option ...@@ -700,13 +700,13 @@ on(type: SensorId.PEDOMETER, callback: Callback&lt;PedometerResponse&gt;, option
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.PEDOMETER, function (data) { sensor.on(sensor.SensorId.PEDOMETER, function (data) {
console.info('Step count: ' + data.steps); console.info('Succeeded in invoking on. Step count: ' + data.steps);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -739,13 +739,13 @@ on(type: SensorId.PEDOMETER_DETECTION, callback: Callback&lt;PedometerDetectionR ...@@ -739,13 +739,13 @@ on(type: SensorId.PEDOMETER_DETECTION, callback: Callback&lt;PedometerDetectionR
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.PEDOMETER_DETECTION, function (data) { sensor.on(sensor.SensorId.PEDOMETER_DETECTION, function (data) {
console.info('Pedometer scalar: ' + data.scalar); console.info('Succeeded in invoking on. Pedometer scalar: ' + data.scalar);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -775,13 +775,13 @@ on(type: SensorId.PROXIMITY, callback: Callback&lt;ProximityResponse&gt;, option ...@@ -775,13 +775,13 @@ on(type: SensorId.PROXIMITY, callback: Callback&lt;ProximityResponse&gt;, option
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.PROXIMITY, function (data) { sensor.on(sensor.SensorId.PROXIMITY, function (data) {
console.info('Distance: ' + data.distance); console.info('Succeeded in invoking on. Distance: ' + data.distance);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -812,16 +812,16 @@ on(type: SensorId.ROTATION_VECTOR, callback: Callback&lt;RotationVectorResponse& ...@@ -812,16 +812,16 @@ on(type: SensorId.ROTATION_VECTOR, callback: Callback&lt;RotationVectorResponse&
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.ROTATION_VECTOR, function (data) { sensor.on(sensor.SensorId.ROTATION_VECTOR, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('Scalar quantity: ' + data.w); console.info('Succeeded in invoking on. Scalar quantity: ' + data.w);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -852,13 +852,13 @@ on(type: SensorId.SIGNIFICANT_MOTION, callback: Callback&lt;SignificantMotionRes ...@@ -852,13 +852,13 @@ on(type: SensorId.SIGNIFICANT_MOTION, callback: Callback&lt;SignificantMotionRes
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, function (data) { sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, function (data) {
console.info('Scalar data: ' + data.scalar); console.info('Succeeded in invoking on. Scalar data: ' + data.scalar);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -889,13 +889,13 @@ on(type: SensorId.WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt ...@@ -889,13 +889,13 @@ on(type: SensorId.WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt
**示例:** **示例:**
```js ```ts
try { try {
sensor.on(sensor.SensorId.WEAR_DETECTION, function (data) { sensor.on(sensor.SensorId.WEAR_DETECTION, function (data) {
console.info('Wear status: ' + data.value); console.info('Succeeded in invoking on. Wear status: ' + data.value);
}, { interval: 100000000 }); }, { interval: 100000000 });
} catch (err) { } catch (error) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke on. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -928,15 +928,15 @@ once(type: SensorId.ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&g ...@@ -928,15 +928,15 @@ once(type: SensorId.ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&g
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.ACCELEROMETER, function (data) { sensor.once(sensor.SensorId.ACCELEROMETER, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -967,18 +967,18 @@ once(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback&lt;Accelerome ...@@ -967,18 +967,18 @@ once(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback&lt;Accelerome
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, function (data) { sensor.once(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking once. X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking once. Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking once. Z-coordinate bias: ' + data.biasZ);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1007,13 +1007,13 @@ once(type: SensorId.AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;): voi ...@@ -1007,13 +1007,13 @@ once(type: SensorId.AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;): voi
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.AMBIENT_LIGHT, function (data) { sensor.once(sensor.SensorId.AMBIENT_LIGHT, function (data) {
console.info('The ambient light intensity: ' + data.intensity); console.info('Succeeded in invoking once. the ambient light intensity: ' + data.intensity);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1042,13 +1042,13 @@ once(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback&lt;AmbientTemperatur ...@@ -1042,13 +1042,13 @@ once(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback&lt;AmbientTemperatur
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.AMBIENT_TEMPERATURE, function (data) { sensor.once(sensor.SensorId.AMBIENT_TEMPERATURE, function (data) {
console.info('Temperature: ' + data.temperature); console.info('Succeeded in invoking once. Temperature: ' + data.temperature);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1077,13 +1077,13 @@ once(type: SensorId.BAROMETER, callback: Callback&lt;BarometerResponse&gt;): voi ...@@ -1077,13 +1077,13 @@ once(type: SensorId.BAROMETER, callback: Callback&lt;BarometerResponse&gt;): voi
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function (data) { sensor.once(sensor.SensorId.BAROMETER, function (data) {
console.info('Atmospheric pressure: ' + data.pressure); console.info('Succeeded in invoking once. Atmospheric pressure: ' + data.pressure);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1112,15 +1112,15 @@ once(type: SensorId.GRAVITY, callback: Callback&lt;GravityResponse&gt;): void ...@@ -1112,15 +1112,15 @@ once(type: SensorId.GRAVITY, callback: Callback&lt;GravityResponse&gt;): void
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.GRAVITY, function (data) { sensor.once(sensor.SensorId.GRAVITY, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1151,15 +1151,17 @@ once(type: SensorId.GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;): voi ...@@ -1151,15 +1151,17 @@ once(type: SensorId.GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;): voi
**示例:** **示例:**
```js ```ts
import sensor from '@ohos.sensor';
try { try {
sensor.once(sensor.SensorId.GYROSCOPE, function (data) { sensor.once(sensor.SensorId.GYROSCOPE, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1190,18 +1192,18 @@ once(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback&lt;GyroscopeUncal ...@@ -1190,18 +1192,18 @@ once(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback&lt;GyroscopeUncal
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.GYROSCOPE_UNCALIBRATED, function (data) { sensor.once(sensor.SensorId.GYROSCOPE_UNCALIBRATED, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking once. X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking once. Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking once. Z-coordinate bias: ' + data.biasZ);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1230,13 +1232,13 @@ once(type: SensorId.HALL, callback: Callback&lt;HallResponse&gt;): void ...@@ -1230,13 +1232,13 @@ once(type: SensorId.HALL, callback: Callback&lt;HallResponse&gt;): void
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.HALL, function (data) { sensor.once(sensor.SensorId.HALL, function (data) {
console.info('Status: ' + data.status); console.info('Succeeded in invoking once. Status: ' + data.status);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1267,13 +1269,13 @@ once(type: SensorId.HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;): vo ...@@ -1267,13 +1269,13 @@ once(type: SensorId.HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;): vo
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.HEART_RATE, function (data) { sensor.once(sensor.SensorId.HEART_RATE, function (data) {
console.info('Heart rate: ' + data.heartRate); console.info('Succeeded in invoking once. Heart rate: ' + data.heartRate);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1302,13 +1304,13 @@ once(type: SensorId.HUMIDITY, callback: Callback&lt;HumidityResponse&gt;): void ...@@ -1302,13 +1304,13 @@ once(type: SensorId.HUMIDITY, callback: Callback&lt;HumidityResponse&gt;): void
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.HUMIDITY, function (data) { sensor.once(sensor.SensorId.HUMIDITY, function (data) {
console.info('Humidity: ' + data.humidity); console.info('Succeeded in invoking once. Humidity: ' + data.humidity);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1339,15 +1341,15 @@ once(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback&lt;LinearAccelerome ...@@ -1339,15 +1341,15 @@ once(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback&lt;LinearAccelerome
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.LINEAR_ACCELEROMETER, function (data) { sensor.once(sensor.SensorId.LINEAR_ACCELEROMETER, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1376,15 +1378,15 @@ once(type: SensorId.MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse& ...@@ -1376,15 +1378,15 @@ once(type: SensorId.MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.MAGNETIC_FIELD, function (data) { sensor.once(sensor.SensorId.MAGNETIC_FIELD, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1413,18 +1415,18 @@ once(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback&lt;MagneticF ...@@ -1413,18 +1415,18 @@ once(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback&lt;MagneticF
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, function (data) { sensor.once(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking once. X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking once. Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking once. Z-coordinate bias: ' + data.biasZ);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1453,15 +1455,15 @@ once(type: SensorId.ORIENTATION, callback: Callback&lt;OrientationResponse&gt;): ...@@ -1453,15 +1455,15 @@ once(type: SensorId.ORIENTATION, callback: Callback&lt;OrientationResponse&gt;):
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.ORIENTATION, function (data) { sensor.once(sensor.SensorId.ORIENTATION, function (data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('Succeeded in the device rotating 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('Succeeded in the device rotating at an angle around the Y axis: ' + data.gamma);
console.info('The device rotates at an angle around the Z axis: ' + data.alpha); console.info('Succeeded in the device rotating at an angle around the Z axis: ' + data.alpha);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1492,13 +1494,13 @@ once(type: SensorId.PEDOMETER, callback: Callback&lt;PedometerResponse&gt;): voi ...@@ -1492,13 +1494,13 @@ once(type: SensorId.PEDOMETER, callback: Callback&lt;PedometerResponse&gt;): voi
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.PEDOMETER, function (data) { sensor.once(sensor.SensorId.PEDOMETER, function (data) {
console.info('Step count: ' + data.steps); console.info('Succeeded in invoking once. Step count: ' + data.steps);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1529,13 +1531,13 @@ once(type: SensorId.PEDOMETER_DETECTION, callback: Callback&lt;PedometerDetectio ...@@ -1529,13 +1531,13 @@ once(type: SensorId.PEDOMETER_DETECTION, callback: Callback&lt;PedometerDetectio
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.PEDOMETER_DETECTION, function (data) { sensor.once(sensor.SensorId.PEDOMETER_DETECTION, function (data) {
console.info('Scalar data: ' + data.scalar); console.info('Succeeded in invoking once. Scalar data: ' + data.scalar);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1564,13 +1566,13 @@ once(type: SensorId.PROXIMITY, callback: Callback&lt;ProximityResponse&gt;): voi ...@@ -1564,13 +1566,13 @@ once(type: SensorId.PROXIMITY, callback: Callback&lt;ProximityResponse&gt;): voi
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.PROXIMITY, function (data) { sensor.once(sensor.SensorId.PROXIMITY, function (data) {
console.info('Distance: ' + data.distance); console.info('Succeeded in invoking once. Distance: ' + data.distance);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1599,16 +1601,16 @@ once(type: SensorId.ROTATION_VECTOR, callback: Callback&lt;RotationVectorRespons ...@@ -1599,16 +1601,16 @@ once(type: SensorId.ROTATION_VECTOR, callback: Callback&lt;RotationVectorRespons
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.ROTATION_VECTOR, function (data) { sensor.once(sensor.SensorId.ROTATION_VECTOR, function (data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('Scalar quantity: ' + data.w); console.info('Succeeded in invoking once. Scalar quantity: ' + data.w);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1637,13 +1639,13 @@ once(type: SensorId.SIGNIFICANT_MOTION, callback: Callback&lt;SignificantMotionR ...@@ -1637,13 +1639,13 @@ once(type: SensorId.SIGNIFICANT_MOTION, callback: Callback&lt;SignificantMotionR
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.SIGNIFICANT_MOTION, function (data) { sensor.once(sensor.SensorId.SIGNIFICANT_MOTION, function (data) {
console.info('Scalar data: ' + data.scalar); console.info('Succeeded in invoking once. Scalar data: ' + data.scalar);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1672,13 +1674,13 @@ once(type: SensorId.WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse& ...@@ -1672,13 +1674,13 @@ once(type: SensorId.WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&
**示例:** **示例:**
```js ```ts
try { try {
sensor.once(sensor.SensorId.WEAR_DETECTION, function (data) { sensor.once(sensor.SensorId.WEAR_DETECTION, function (data) {
console.info("Wear status: " + data.value); console.info('Succeeded in invoking once. Wear status: ' + data.value);
}); });
} catch (err) { } catch (error) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1703,13 +1705,15 @@ off(type: SensorId.COLOR, callback?: Callback\<ColorResponse>): void ...@@ -1703,13 +1705,15 @@ off(type: SensorId.COLOR, callback?: Callback\<ColorResponse>): void
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.COLOR, callback1); sensor.on(sensor.SensorId.COLOR, callback1);
sensor.on(sensor.SensorId.COLOR, callback2); sensor.on(sensor.SensorId.COLOR, callback2);
...@@ -1717,8 +1721,8 @@ try { ...@@ -1717,8 +1721,8 @@ try {
sensor.off(sensor.SensorId.COLOR, callback1); sensor.off(sensor.SensorId.COLOR, callback1);
// 取消注册SensorId.COLOR的所有回调 // 取消注册SensorId.COLOR的所有回调
sensor.off(sensor.SensorId.COLOR); sensor.off(sensor.SensorId.COLOR);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1741,13 +1745,15 @@ off(type: SensorId.SAR, callback?: Callback\<SarResponse>): void ...@@ -1741,13 +1745,15 @@ off(type: SensorId.SAR, callback?: Callback\<SarResponse>): void
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.SAR, callback1); sensor.on(sensor.SensorId.SAR, callback1);
sensor.on(sensor.SensorId.SAR, callback2); sensor.on(sensor.SensorId.SAR, callback2);
...@@ -1755,8 +1761,8 @@ try { ...@@ -1755,8 +1761,8 @@ try {
sensor.off(sensor.SensorId.SAR, callback1); sensor.off(sensor.SensorId.SAR, callback1);
// 取消注册SensorId.SAR的所有回调 // 取消注册SensorId.SAR的所有回调
sensor.off(sensor.SensorId.SAR); sensor.off(sensor.SensorId.SAR);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1779,13 +1785,15 @@ off(type: SensorId.ACCELEROMETER, callback?: Callback&lt;AccelerometerResponse&g ...@@ -1779,13 +1785,15 @@ off(type: SensorId.ACCELEROMETER, callback?: Callback&lt;AccelerometerResponse&g
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.ACCELEROMETER, callback1); sensor.on(sensor.SensorId.ACCELEROMETER, callback1);
sensor.on(sensor.SensorId.ACCELEROMETER, callback2); sensor.on(sensor.SensorId.ACCELEROMETER, callback2);
...@@ -1793,8 +1801,8 @@ try { ...@@ -1793,8 +1801,8 @@ try {
sensor.off(sensor.SensorId.ACCELEROMETER, callback1); sensor.off(sensor.SensorId.ACCELEROMETER, callback1);
// 取消SensorId.ACCELEROMETER类型的所有回调 // 取消SensorId.ACCELEROMETER类型的所有回调
sensor.off(sensor.SensorId.ACCELEROMETER); sensor.off(sensor.SensorId.ACCELEROMETER);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1817,13 +1825,15 @@ off(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback?: Callback&lt;Accelerome ...@@ -1817,13 +1825,15 @@ off(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback?: Callback&lt;Accelerome
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback1); sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback1);
sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback2); sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback2);
...@@ -1831,8 +1841,8 @@ try { ...@@ -1831,8 +1841,8 @@ try {
sensor.off(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback1); sensor.off(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback1);
// 取消注册SensorId.ACCELEROMETER_UNCALIBRATED类型的所有回调 // 取消注册SensorId.ACCELEROMETER_UNCALIBRATED类型的所有回调
sensor.off(sensor.SensorId.ACCELEROMETER_UNCALIBRATED); sensor.off(sensor.SensorId.ACCELEROMETER_UNCALIBRATED);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1853,22 +1863,24 @@ off(type: SensorId.AMBIENT_LIGHT, callback?: Callback&lt;LightResponse&gt;): voi ...@@ -1853,22 +1863,24 @@ off(type: SensorId.AMBIENT_LIGHT, callback?: Callback&lt;LightResponse&gt;): voi
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback1); sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback1);
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback2); sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback2);
// 仅取消callback1的注册 // 仅取消callback1的注册
sensor.off(sensor.SensorId.AMBIENT_LIGHT, callback1); sensor.off(sensor.SensorId.AMBIENT_LIGHT, callback1);
// 取消注册SensorId.AMBIENT_LIGHT的所有回调 // 取消注册SensorId.AMBIENT_LIGHT
sensor.off(sensor.SensorId.AMBIENT_LIGHT); sensor.off(sensor.SensorId.AMBIENT_LIGHT);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1889,13 +1901,15 @@ off(type: SensorId.AMBIENT_TEMPERATURE, callback?: Callback&lt;AmbientTemperatur ...@@ -1889,13 +1901,15 @@ off(type: SensorId.AMBIENT_TEMPERATURE, callback?: Callback&lt;AmbientTemperatur
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, callback1); sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, callback1);
sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, callback2); sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, callback2);
...@@ -1903,8 +1917,8 @@ try { ...@@ -1903,8 +1917,8 @@ try {
sensor.off(sensor.SensorId.AMBIENT_TEMPERATURE, callback1); sensor.off(sensor.SensorId.AMBIENT_TEMPERATURE, callback1);
// 取消注册SensorId.AMBIENT_TEMPERATURE的所有回调 // 取消注册SensorId.AMBIENT_TEMPERATURE的所有回调
sensor.off(sensor.SensorId.AMBIENT_TEMPERATURE); sensor.off(sensor.SensorId.AMBIENT_TEMPERATURE);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1925,13 +1939,15 @@ off(type: SensorId.BAROMETER, callback?: Callback&lt;BarometerResponse&gt;): voi ...@@ -1925,13 +1939,15 @@ off(type: SensorId.BAROMETER, callback?: Callback&lt;BarometerResponse&gt;): voi
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.BAROMETER, callback1); sensor.on(sensor.SensorId.BAROMETER, callback1);
sensor.on(sensor.SensorId.BAROMETER, callback2); sensor.on(sensor.SensorId.BAROMETER, callback2);
...@@ -1939,8 +1955,8 @@ try { ...@@ -1939,8 +1955,8 @@ try {
sensor.off(sensor.SensorId.BAROMETER, callback1); sensor.off(sensor.SensorId.BAROMETER, callback1);
// 取消注册SensorId.BAROMETER的所有回调 // 取消注册SensorId.BAROMETER的所有回调
sensor.off(sensor.SensorId.BAROMETER); sensor.off(sensor.SensorId.BAROMETER);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1961,13 +1977,15 @@ off(type: SensorId.GRAVITY, callback?: Callback&lt;GravityResponse&gt;): void ...@@ -1961,13 +1977,15 @@ off(type: SensorId.GRAVITY, callback?: Callback&lt;GravityResponse&gt;): void
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.GRAVITY, callback1); sensor.on(sensor.SensorId.GRAVITY, callback1);
sensor.on(sensor.SensorId.GRAVITY, callback2); sensor.on(sensor.SensorId.GRAVITY, callback2);
...@@ -1975,8 +1993,8 @@ try { ...@@ -1975,8 +1993,8 @@ try {
sensor.off(sensor.SensorId.GRAVITY, callback1); sensor.off(sensor.SensorId.GRAVITY, callback1);
// 取消注册SensorId.GRAVITY的所有回调 // 取消注册SensorId.GRAVITY的所有回调
sensor.off(sensor.SensorId.GRAVITY); sensor.off(sensor.SensorId.GRAVITY);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -1999,13 +2017,15 @@ off(type: SensorId.GYROSCOPE, callback?: Callback&lt;GyroscopeResponse&gt;): voi ...@@ -1999,13 +2017,15 @@ off(type: SensorId.GYROSCOPE, callback?: Callback&lt;GyroscopeResponse&gt;): voi
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.GYROSCOPE, callback1); sensor.on(sensor.SensorId.GYROSCOPE, callback1);
sensor.on(sensor.SensorId.GYROSCOPE, callback2); sensor.on(sensor.SensorId.GYROSCOPE, callback2);
...@@ -2013,8 +2033,8 @@ try { ...@@ -2013,8 +2033,8 @@ try {
sensor.off(sensor.SensorId.GYROSCOPE, callback1); sensor.off(sensor.SensorId.GYROSCOPE, callback1);
// 取消注册SensorId.GYROSCOPE的所有回调 // 取消注册SensorId.GYROSCOPE的所有回调
sensor.off(sensor.SensorId.GYROSCOPE); sensor.off(sensor.SensorId.GYROSCOPE);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2037,13 +2057,15 @@ off(type: SensorId.GYROSCOPE_UNCALIBRATED, callback?: Callback&lt;GyroscopeUncal ...@@ -2037,13 +2057,15 @@ off(type: SensorId.GYROSCOPE_UNCALIBRATED, callback?: Callback&lt;GyroscopeUncal
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback1); sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback1);
sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback2); sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback2);
...@@ -2051,8 +2073,8 @@ try { ...@@ -2051,8 +2073,8 @@ try {
sensor.off(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback1); sensor.off(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback1);
// 取消注册SensorId.GYROSCOPE_UNCALIBRATED的所有回调 // 取消注册SensorId.GYROSCOPE_UNCALIBRATED的所有回调
sensor.off(sensor.SensorId.GYROSCOPE_UNCALIBRATED); sensor.off(sensor.SensorId.GYROSCOPE_UNCALIBRATED);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2073,13 +2095,15 @@ off(type: SensorId.HALL, callback?: Callback&lt;HallResponse&gt;): void ...@@ -2073,13 +2095,15 @@ off(type: SensorId.HALL, callback?: Callback&lt;HallResponse&gt;): void
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.HALL, callback1); sensor.on(sensor.SensorId.HALL, callback1);
sensor.on(sensor.SensorId.HALL, callback2); sensor.on(sensor.SensorId.HALL, callback2);
...@@ -2087,8 +2111,8 @@ try { ...@@ -2087,8 +2111,8 @@ try {
sensor.off(sensor.SensorId.HALL, callback1); sensor.off(sensor.SensorId.HALL, callback1);
// 取消注册SensorId.HALL的所有回调 // 取消注册SensorId.HALL的所有回调
sensor.off(sensor.SensorId.HALL); sensor.off(sensor.SensorId.HALL);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2111,13 +2135,15 @@ off(type: SensorId.HEART_RATE, callback?: Callback&lt;HeartRateResponse&gt;): vo ...@@ -2111,13 +2135,15 @@ off(type: SensorId.HEART_RATE, callback?: Callback&lt;HeartRateResponse&gt;): vo
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.HEART_RATE, callback1); sensor.on(sensor.SensorId.HEART_RATE, callback1);
sensor.on(sensor.SensorId.HEART_RATE, callback2); sensor.on(sensor.SensorId.HEART_RATE, callback2);
...@@ -2125,8 +2151,8 @@ try { ...@@ -2125,8 +2151,8 @@ try {
sensor.off(sensor.SensorId.HEART_RATE, callback1); sensor.off(sensor.SensorId.HEART_RATE, callback1);
// 取消注册SensorId.HEART_RATE的所有回调 // 取消注册SensorId.HEART_RATE的所有回调
sensor.off(sensor.SensorId.HEART_RATE); sensor.off(sensor.SensorId.HEART_RATE);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2147,13 +2173,15 @@ off(type: SensorId.HUMIDITY, callback?: Callback&lt;HumidityResponse&gt;): void ...@@ -2147,13 +2173,15 @@ off(type: SensorId.HUMIDITY, callback?: Callback&lt;HumidityResponse&gt;): void
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.HUMIDITY, callback1); sensor.on(sensor.SensorId.HUMIDITY, callback1);
sensor.on(sensor.SensorId.HUMIDITY, callback2); sensor.on(sensor.SensorId.HUMIDITY, callback2);
...@@ -2161,8 +2189,8 @@ try { ...@@ -2161,8 +2189,8 @@ try {
sensor.off(sensor.SensorId.HUMIDITY, callback1); sensor.off(sensor.SensorId.HUMIDITY, callback1);
// 取消注册SensorId.HUMIDITY的所有回调 // 取消注册SensorId.HUMIDITY的所有回调
sensor.off(sensor.SensorId.HUMIDITY); sensor.off(sensor.SensorId.HUMIDITY);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2185,13 +2213,15 @@ off(type: SensorId.LINEAR_ACCELEROMETER, callback?: Callback&lt;LinearAccelerome ...@@ -2185,13 +2213,15 @@ off(type: SensorId.LINEAR_ACCELEROMETER, callback?: Callback&lt;LinearAccelerome
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, callback1); sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, callback1);
sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, callback2); sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, callback2);
...@@ -2199,8 +2229,8 @@ try { ...@@ -2199,8 +2229,8 @@ try {
sensor.off(sensor.SensorId.LINEAR_ACCELEROMETER, callback1); sensor.off(sensor.SensorId.LINEAR_ACCELEROMETER, callback1);
// 取消注册SensorId.LINEAR_ACCELEROMETER的所有回调 // 取消注册SensorId.LINEAR_ACCELEROMETER的所有回调
sensor.off(sensor.SensorId.LINEAR_ACCELEROMETER); sensor.off(sensor.SensorId.LINEAR_ACCELEROMETER);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2221,13 +2251,15 @@ off(type: SensorId.MAGNETIC_FIELD, callback?: Callback&lt;MagneticFieldResponse& ...@@ -2221,13 +2251,15 @@ off(type: SensorId.MAGNETIC_FIELD, callback?: Callback&lt;MagneticFieldResponse&
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback1); sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback1);
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback2); sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback2);
...@@ -2235,8 +2267,8 @@ try { ...@@ -2235,8 +2267,8 @@ try {
sensor.off(sensor.SensorId.MAGNETIC_FIELD, callback1); sensor.off(sensor.SensorId.MAGNETIC_FIELD, callback1);
// 取消注册SensorId.MAGNETIC_FIELD的所有回调 // 取消注册SensorId.MAGNETIC_FIELD的所有回调
sensor.off(sensor.SensorId.MAGNETIC_FIELD); sensor.off(sensor.SensorId.MAGNETIC_FIELD);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2257,13 +2289,15 @@ off(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback&lt;MagneticF ...@@ -2257,13 +2289,15 @@ off(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback&lt;MagneticF
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback1); sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback1);
sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback2); sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback2);
...@@ -2271,8 +2305,8 @@ try { ...@@ -2271,8 +2305,8 @@ try {
sensor.off(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback1); sensor.off(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback1);
// 取消注册SensorId.MAGNETIC_FIELD_UNCALIBRATED的所有回调 // 取消注册SensorId.MAGNETIC_FIELD_UNCALIBRATED的所有回调
sensor.off(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED); sensor.off(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2293,13 +2327,15 @@ off(type: SensorId.ORIENTATION, callback?: Callback&lt;OrientationResponse&gt;): ...@@ -2293,13 +2327,15 @@ off(type: SensorId.ORIENTATION, callback?: Callback&lt;OrientationResponse&gt;):
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.ORIENTATION, callback1); sensor.on(sensor.SensorId.ORIENTATION, callback1);
sensor.on(sensor.SensorId.ORIENTATION, callback2); sensor.on(sensor.SensorId.ORIENTATION, callback2);
...@@ -2307,8 +2343,8 @@ try { ...@@ -2307,8 +2343,8 @@ try {
sensor.off(sensor.SensorId.ORIENTATION, callback1); sensor.off(sensor.SensorId.ORIENTATION, callback1);
// 取消注册SensorId.ORIENTATION的所有回调 // 取消注册SensorId.ORIENTATION的所有回调
sensor.off(sensor.SensorId.ORIENTATION); sensor.off(sensor.SensorId.ORIENTATION);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2331,13 +2367,15 @@ off(type: SensorId.PEDOMETER, callback?: Callback&lt;PedometerResponse&gt;): voi ...@@ -2331,13 +2367,15 @@ off(type: SensorId.PEDOMETER, callback?: Callback&lt;PedometerResponse&gt;): voi
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.PEDOMETER, callback1); sensor.on(sensor.SensorId.PEDOMETER, callback1);
sensor.on(sensor.SensorId.PEDOMETER, callback2); sensor.on(sensor.SensorId.PEDOMETER, callback2);
...@@ -2345,8 +2383,8 @@ try { ...@@ -2345,8 +2383,8 @@ try {
sensor.off(sensor.SensorId.PEDOMETER, callback1); sensor.off(sensor.SensorId.PEDOMETER, callback1);
// 取消注册SensorId.PEDOMETER的所有回调 // 取消注册SensorId.PEDOMETER的所有回调
sensor.off(sensor.SensorId.PEDOMETER); sensor.off(sensor.SensorId.PEDOMETER);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2369,13 +2407,15 @@ off(type: SensorId.PEDOMETER_DETECTION, callback?: Callback&lt;PedometerDetectio ...@@ -2369,13 +2407,15 @@ off(type: SensorId.PEDOMETER_DETECTION, callback?: Callback&lt;PedometerDetectio
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback1); sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback1);
sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback2); sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback2);
...@@ -2383,8 +2423,8 @@ try { ...@@ -2383,8 +2423,8 @@ try {
sensor.off(sensor.SensorId.PEDOMETER_DETECTION, callback1); sensor.off(sensor.SensorId.PEDOMETER_DETECTION, callback1);
// 取消注册SensorId.PEDOMETER_DETECTION的所有回调 // 取消注册SensorId.PEDOMETER_DETECTION的所有回调
sensor.off(sensor.SensorId.PEDOMETER_DETECTION); sensor.off(sensor.SensorId.PEDOMETER_DETECTION);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2405,13 +2445,15 @@ off(type: SensorId.PROXIMITY, callback?: Callback&lt;ProximityResponse&gt;): voi ...@@ -2405,13 +2445,15 @@ off(type: SensorId.PROXIMITY, callback?: Callback&lt;ProximityResponse&gt;): voi
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.PROXIMITY, callback1); sensor.on(sensor.SensorId.PROXIMITY, callback1);
sensor.on(sensor.SensorId.PROXIMITY, callback2); sensor.on(sensor.SensorId.PROXIMITY, callback2);
...@@ -2419,8 +2461,8 @@ try { ...@@ -2419,8 +2461,8 @@ try {
sensor.off(sensor.SensorId.PROXIMITY, callback1); sensor.off(sensor.SensorId.PROXIMITY, callback1);
// 取消注册SensorId.PROXIMITY的所有回调 // 取消注册SensorId.PROXIMITY的所有回调
sensor.off(sensor.SensorId.PROXIMITY); sensor.off(sensor.SensorId.PROXIMITY);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2441,13 +2483,15 @@ off(type: SensorId.ROTATION_VECTOR, callback?: Callback&lt;RotationVectorRespons ...@@ -2441,13 +2483,15 @@ off(type: SensorId.ROTATION_VECTOR, callback?: Callback&lt;RotationVectorRespons
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.ROTATION_VECTOR, callback1); sensor.on(sensor.SensorId.ROTATION_VECTOR, callback1);
sensor.on(sensor.SensorId.ROTATION_VECTOR, callback2); sensor.on(sensor.SensorId.ROTATION_VECTOR, callback2);
...@@ -2455,8 +2499,8 @@ try { ...@@ -2455,8 +2499,8 @@ try {
sensor.off(sensor.SensorId.ROTATION_VECTOR, callback1); sensor.off(sensor.SensorId.ROTATION_VECTOR, callback1);
// 取消注册SensorId.ROTATION_VECTOR的所有回调 // 取消注册SensorId.ROTATION_VECTOR的所有回调
sensor.off(sensor.SensorId.ROTATION_VECTOR); sensor.off(sensor.SensorId.ROTATION_VECTOR);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2477,13 +2521,15 @@ off(type: SensorId.SIGNIFICANT_MOTION, callback?: Callback&lt;SignificantMotionR ...@@ -2477,13 +2521,15 @@ off(type: SensorId.SIGNIFICANT_MOTION, callback?: Callback&lt;SignificantMotionR
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, callback1); sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, callback1);
sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, callback2); sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, callback2);
...@@ -2491,8 +2537,8 @@ try { ...@@ -2491,8 +2537,8 @@ try {
sensor.off(sensor.SensorId.SIGNIFICANT_MOTION, callback1); sensor.off(sensor.SensorId.SIGNIFICANT_MOTION, callback1);
// 取消注册SensorId.SIGNIFICANT_MOTION的所有回调 // 取消注册SensorId.SIGNIFICANT_MOTION的所有回调
sensor.off(sensor.SensorId.SIGNIFICANT_MOTION); sensor.off(sensor.SensorId.SIGNIFICANT_MOTION);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2513,13 +2559,15 @@ off(type: SensorId.WEAR_DETECTION, callback?: Callback&lt;WearDetectionResponse& ...@@ -2513,13 +2559,15 @@ off(type: SensorId.WEAR_DETECTION, callback?: Callback&lt;WearDetectionResponse&
**示例:** **示例:**
```js ```ts
function callback1(data) { function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
} }
function callback2(data) { function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data)); console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
} }
try { try {
sensor.on(sensor.SensorId.WEAR_DETECTION, callback1); sensor.on(sensor.SensorId.WEAR_DETECTION, callback1);
sensor.on(sensor.SensorId.WEAR_DETECTION, callback2); sensor.on(sensor.SensorId.WEAR_DETECTION, callback2);
...@@ -2527,8 +2575,8 @@ try { ...@@ -2527,8 +2575,8 @@ try {
sensor.off(sensor.SensorId.WEAR_DETECTION, callback1); sensor.off(sensor.SensorId.WEAR_DETECTION, callback1);
// 取消注册SensorId.WEAR_DETECTION的所有回调 // 取消注册SensorId.WEAR_DETECTION的所有回调
sensor.off(sensor.SensorId.WEAR_DETECTION); sensor.off(sensor.SensorId.WEAR_DETECTION);
} catch (err) { } catch (error) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2558,23 +2606,23 @@ getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number, callbac ...@@ -2558,23 +2606,23 @@ getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number, callbac
**示例:** **示例:**
```js ```ts
try { try {
sensor.getGeomagneticInfo({ latitude: 80, longitude: 0, altitude: 0 }, 1580486400000, function (err, data) { sensor.getGeomagneticInfo({ latitude: 80, longitude: 0, altitude: 0 }, 1580486400000, function (err, data) {
if (err) { if (err) {
console.error('Get geomagneticInfo failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get geomagneticInfo. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info("GeomagneticInfo x" + data.x); console.info("Succeeded in getting geomagneticInfo x" + data.x);
console.info("GeomagneticInfo y" + data.y); console.info("Succeeded in getting geomagneticInfo y" + data.y);
console.info("GeomagneticInfo z" + data.z); console.info("Succeeded in getting geomagneticInfo z" + data.z);
console.info("GeomagneticInfo geomagneticDip" + data.geomagneticDip); console.info("Succeeded in getting geomagneticInfo geomagneticDip" + data.geomagneticDip);
console.info("GeomagneticInfo deflectionAngle" + data.deflectionAngle); console.info("Succeeded in getting geomagneticInfo deflectionAngle" + data.deflectionAngle);
console.info("GeomagneticInfo levelIntensity" + data.levelIntensity); console.info("Succeeded in getting geomagneticInfo levelIntensity" + data.levelIntensity);
console.info("GeomagneticInfo totalIntensity" + data.totalIntensity); console.info("Succeeded in getting geomagneticInfo totalIntensity" + data.totalIntensity);
}); });
} catch (err) { } catch (error) {
console.error('Get geomagneticInfo failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get geomagneticInfo. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2609,22 +2657,22 @@ getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number): Promis ...@@ -2609,22 +2657,22 @@ getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number): Promis
**示例:** **示例:**
```js ```ts
try { try {
const promise = sensor.getGeomagneticInfo({ latitude: 80, longitude: 0, altitude: 0 }, 1580486400000); const promise = sensor.getGeomagneticInfo({ latitude: 80, longitude: 0, altitude: 0 }, 1580486400000);
promise.then((data) => { promise.then((data) => {
console.info("GeomagneticInfo x" + data.x); console.info("Succeeded in getting geomagneticInfo x" + data.x);
console.info("GeomagneticInfo y" + data.y); console.info("Succeeded in getting geomagneticInfo y" + data.y);
console.info("GeomagneticInfo z" + data.z); console.info("Succeeded in getting geomagneticInfo z" + data.z);
console.info("GeomagneticInfo geomagneticDip" + data.geomagneticDip); console.info("Succeeded in getting geomagneticInfo geomagneticDip" + data.geomagneticDip);
console.info("GeomagneticInfo deflectionAngle" + data.deflectionAngle); console.info("Succeeded in getting geomagneticInfo deflectionAngle" + data.deflectionAngle);
console.info("GeomagneticInfo levelIntensity" + data.levelIntensity); console.info("Succeeded in getting geomagneticInfo levelIntensity" + data.levelIntensity);
console.info("GeomagneticInfo totalIntensity" + data.totalIntensity); console.info("Succeeded in getting geomagneticInfo totalIntensity" + data.totalIntensity);
}, (err)=>{ }, (err) => {
console.error('Get geomagneticInfo failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get geomagneticInfo. Code: ${err.code}, message: ${err.message}`);
}); });
} catch (err) { } catch (error) {
console.error('Get geomagneticInfo. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get geomagneticInfo. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2654,19 +2702,19 @@ getDeviceAltitude(seaPressure: number, currentPressure: number, callback: AsyncC ...@@ -2654,19 +2702,19 @@ getDeviceAltitude(seaPressure: number, currentPressure: number, callback: AsyncC
**示例:** **示例:**
```js ```ts
try { try {
let seaPressure = 1013.2; let seaPressure = 1013.2;
let currentPressure = 1500.0; let currentPressure = 1500.0;
sensor.getDeviceAltitude(seaPressure, currentPressure, function (err, data) { sensor.getDeviceAltitude(seaPressure, currentPressure, function (err, data) {
if (err) { if (err) {
console.error('Get altitude failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get altitude. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info('altitude: ' + data); console.info('Succeeded in getting altitude: ' + data);
}); });
} catch (err) { } catch (error) {
console.error('Get altitude failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get altitude. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2701,18 +2749,18 @@ getDeviceAltitude(seaPressure: number, currentPressure: number): Promise&lt;numb ...@@ -2701,18 +2749,18 @@ getDeviceAltitude(seaPressure: number, currentPressure: number): Promise&lt;numb
**示例:** **示例:**
```js ```ts
try { try {
let seaPressure = 1013.2; let seaPressure = 1013.2;
let currentPressure = 1500.0; let currentPressure = 1500.0;
const promise = sensor.getDeviceAltitude(seaPressure, currentPressure); const promise = sensor.getDeviceAltitude(seaPressure, currentPressure);
promise.then((data) => { promise.then((data) => {
console.info('sensor_getDeviceAltitude_Promise success', data); console.info('Succeeded in getting sensor_getDeviceAltitude_Promise', data);
}, (err) => { }, (err) => {
console.error('Get altitude failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get altitude. Code: ${err.code}, message: ${err.message}`);
}); });
} catch (err) { } catch (error) {
console.error('Get altitude failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get altitude. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2741,7 +2789,7 @@ getInclination(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallback&l ...@@ -2741,7 +2789,7 @@ getInclination(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallback&l
**示例:** **示例:**
```js ```ts
try { try {
// inclinationMatrix可以为3*3,或者4*4 // inclinationMatrix可以为3*3,或者4*4
let inclinationMatrix = [ let inclinationMatrix = [
...@@ -2751,13 +2799,13 @@ try { ...@@ -2751,13 +2799,13 @@ try {
] ]
sensor.getInclination(inclinationMatrix, function (err, data) { sensor.getInclination(inclinationMatrix, function (err, data) {
if (err) { if (err) {
console.error('Get inclination failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get inclination. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info('Inclination: ' + data); console.info('Succeeded in getting inclination: ' + data);
}) })
} catch (err) { } catch (error) {
console.error('Get inclination failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get inclination. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2791,7 +2839,7 @@ try { ...@@ -2791,7 +2839,7 @@ try {
**示例:** **示例:**
```js ```ts
try { try {
// inclinationMatrix可以为3*3,或者4*4 // inclinationMatrix可以为3*3,或者4*4
let inclinationMatrix = [ let inclinationMatrix = [
...@@ -2801,12 +2849,12 @@ try { ...@@ -2801,12 +2849,12 @@ try {
] ]
const promise = sensor.getInclination(inclinationMatrix); const promise = sensor.getInclination(inclinationMatrix);
promise.then((data) => { promise.then((data) => {
console.info('Inclination: ' + data); console.info('Succeeded in getting inclination: ' + data);
}, (err) => { }, (err) => {
console.error('Get inclination failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get inclination. Code: ${err.code}, message: ${err.message}`);
}); });
} catch (err) { } catch (error) {
console.error('Get inclination failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get inclination. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2837,7 +2885,7 @@ try { ...@@ -2837,7 +2885,7 @@ try {
**示例:** **示例:**
```js ```ts
try { try {
// 旋转矩阵可以为3*3,或者4*4 // 旋转矩阵可以为3*3,或者4*4
let currentRotationMatrix = [ let currentRotationMatrix = [
...@@ -2852,18 +2900,18 @@ try { ...@@ -2852,18 +2900,18 @@ try {
]; ];
sensor.getAngleVariation(currentRotationMatrix, preRotationMatrix, function (err, data) { sensor.getAngleVariation(currentRotationMatrix, preRotationMatrix, function (err, data) {
if (err) { if (err) {
console.error('Get angle variation failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get angle variation. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
if (data.length < 3) { if (data.length < 3) {
console.error("Get angle variation failed, length" + data.length); console.error("Failed to get angle variation, length" + data.length);
} }
console.info("Z: " + data[0]); console.info("Z: " + data[0]);
console.info("X: " + data[1]); console.info("X: " + data[1]);
console.info("Y : " + data[2]); console.info("Y : " + data[2]);
}) })
} catch (err) { } catch (error) {
console.error('Get angle variation failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get angle variation. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2898,7 +2946,7 @@ getAngleVariation(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: ...@@ -2898,7 +2946,7 @@ getAngleVariation(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix:
**示例:** **示例:**
```js ```ts
try { try {
// 旋转矩阵可以为3*3,或者4*4 // 旋转矩阵可以为3*3,或者4*4
let currentRotationMatrix = [ let currentRotationMatrix = [
...@@ -2914,16 +2962,16 @@ try { ...@@ -2914,16 +2962,16 @@ try {
const promise = sensor.getAngleVariation(currentRotationMatrix, preRotationMatrix); const promise = sensor.getAngleVariation(currentRotationMatrix, preRotationMatrix);
promise.then((data) => { promise.then((data) => {
if (data.length < 3) { if (data.length < 3) {
console.error("Get angle variation failed, length" + data.length); console.error("Failed to get angle variation, length" + data.length);
} }
console.info("Z: " + data[0]); console.info("Z: " + data[0]);
console.info("X: " + data[1]); console.info("X: " + data[1]);
console.info("Y : " + data[2]); console.info("Y : " + data[2]);
}, (err) => { }, (err) => {
console.error('Get angle variation failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get angle variation. Code: ${err.code}, message: ${err.message}`);
}); });
} catch (err) { } catch (error) {
console.error('Get angle variation failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get angle variation. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2952,20 +3000,20 @@ getRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&l ...@@ -2952,20 +3000,20 @@ getRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&l
**示例:** **示例:**
```js ```ts
try { try {
let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877]; let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
sensor.getRotationMatrix(rotationVector, function (err, data) { sensor.getRotationMatrix(rotationVector, function (err, data) {
if (err) { if (err) {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get rotationMatrix. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + data[i]); console.info('Succeeded in getting data[' + i + ']: ' + data[i]);
} }
}) })
} catch (err) { } catch (error) {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get rotationMatrix. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -2999,19 +3047,19 @@ getRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;numb ...@@ -2999,19 +3047,19 @@ getRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;numb
**示例:** **示例:**
```js ```ts
try { try {
let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877]; let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
const promise = sensor.getRotationMatrix(rotationVector); const promise = sensor.getRotationMatrix(rotationVector);
promise.then((data) => { promise.then((data) => {
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + data[i]); console.info('Succeeded in getting data[' + i + ']: ' + data[i]);
} }
}, (err) => { }, (err) => {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get rotationMatrix. Code: ${err.code}, message: ${err.message}`);
}); });
} catch (err) { } catch (error) {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get rotationMatrix. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -3042,7 +3090,7 @@ transformRotationMatrix(inRotationVector: Array&lt;number&gt;, coordinates: Coor ...@@ -3042,7 +3090,7 @@ transformRotationMatrix(inRotationVector: Array&lt;number&gt;, coordinates: Coor
**示例:** **示例:**
```js ```ts
try { try {
let rotationMatrix = [ let rotationMatrix = [
1, 0, 0, 1, 0, 0,
...@@ -3051,15 +3099,15 @@ try { ...@@ -3051,15 +3099,15 @@ try {
]; ];
sensor.transformRotationMatrix(rotationMatrix, { x: 1, y: 3 }, function (err, data) { sensor.transformRotationMatrix(rotationMatrix, { x: 1, y: 3 }, function (err, data) {
if (err) { if (err) {
console.error('Transform rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to transform rotationMatrix. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info('data[' + i + '] = ' + data[i]); console.info('Succeeded in getting data[' + i + '] = ' + data[i]);
} }
}) })
} catch (err) { } catch (error) {
console.error('Transform rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to transform rotationMatrix. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -3094,7 +3142,7 @@ transformRotationMatrix(inRotationVector: Array&lt;number&gt;, coordinates: Coor ...@@ -3094,7 +3142,7 @@ transformRotationMatrix(inRotationVector: Array&lt;number&gt;, coordinates: Coor
**示例:** **示例:**
```js ```ts
try { try {
let rotationMatrix = [ let rotationMatrix = [
1, 0, 0, 1, 0, 0,
...@@ -3104,13 +3152,13 @@ try { ...@@ -3104,13 +3152,13 @@ try {
const promise = sensor.transformRotationMatrix(rotationMatrix, { x: 1, y: 3 }); const promise = sensor.transformRotationMatrix(rotationMatrix, { x: 1, y: 3 });
promise.then((data) => { promise.then((data) => {
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + data[i]); console.info('Succeeded in getting data[' + i + ']: ' + data[i]);
} }
}, (err) => { }, (err) => {
console.error('Transform rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to transform rotationMatrix. Code: ${err.code}, message: ${err.message}`);
}); });
} catch (err) { } catch (error) {
console.error('Transform rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to transform rotationMatrix. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -3139,20 +3187,20 @@ getQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt;Ar ...@@ -3139,20 +3187,20 @@ getQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt;Ar
**示例:** **示例:**
```js ```ts
try { try {
let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877]; let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
sensor.getQuaternion(rotationVector, function (err, data) { sensor.getQuaternion(rotationVector, function (err, data) {
if (err) { if (err) {
console.error('Get quaternion failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get quaternion. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + data[i]); console.info('Succeeded in getting data[' + i + ']: ' + data[i]);
} }
}) })
} catch (err) { } catch (error) {
console.error('Get quaternion failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get quaternion. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -3186,19 +3234,19 @@ getQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;number&g ...@@ -3186,19 +3234,19 @@ getQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;number&g
**示例:** **示例:**
```js ```ts
try { try {
let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877]; let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
const promise = sensor.getQuaternion(rotationVector); const promise = sensor.getQuaternion(rotationVector);
promise.then((data) => { promise.then((data) => {
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + data[i]); console.info('Succeeded in getting data[' + i + ']: ' + data[i]);
} }
}, (err) => { }, (err) => {
console.error('Get quaternion failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get quaternion. Code: ${err.code}, message: ${err.message}`);
}); });
} catch (err) { } catch (error) {
console.error('Get quaternion failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get quaternion. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -3227,7 +3275,7 @@ getOrientation(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;A ...@@ -3227,7 +3275,7 @@ getOrientation(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;A
**示例:** **示例:**
```js ```ts
try { try {
let preRotationMatrix = [ let preRotationMatrix = [
1, 0, 0, 1, 0, 0,
...@@ -3236,18 +3284,18 @@ try { ...@@ -3236,18 +3284,18 @@ try {
]; ];
sensor.getOrientation(preRotationMatrix, function (err, data) { sensor.getOrientation(preRotationMatrix, function (err, data) {
if (err) { if (err) {
console.error('Get orientation failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get orientation. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
if (data.length < 3) { if (data.length < 3) {
console.error("Get orientation failed, length" + data.length); console.error("Failed to get orientation, length" + data.length);
} }
console.info("Z: " + data[0]); console.info("Succeeded in getting data. Z: " + data[0]);
console.info("X: " + data[1]); console.info("Succeeded in getting data. X: " + data[1]);
console.info("Y : " + data[2]); console.info("Succeeded in getting data. Y: " + data[2]);
}) })
} catch (err) { } catch (error) {
console.error('Get orientation failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get orientation. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -3281,7 +3329,7 @@ getOrientation(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number& ...@@ -3281,7 +3329,7 @@ getOrientation(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&
**示例:** **示例:**
```js ```ts
try { try {
let preRotationMatrix = [ let preRotationMatrix = [
1, 0, 0, 1, 0, 0,
...@@ -3291,13 +3339,13 @@ try { ...@@ -3291,13 +3339,13 @@ try {
const promise = sensor.getOrientation(preRotationMatrix); const promise = sensor.getOrientation(preRotationMatrix);
promise.then((data) => { promise.then((data) => {
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + data[i]); console.info('Succeeded in getting data[' + i + ']: ' + data[i]);
} }
}, (err) => { }, (err) => {
console.error('getOrientation failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to getOrientatin. Code: ${err.code}, message: ${err.message}`);
}); });
} catch (err) { } catch (error) {
console.error('getOrientation failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to getOrientatin Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -3327,19 +3375,19 @@ getRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt; ...@@ -3327,19 +3375,19 @@ getRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt;
**示例:** **示例:**
```js ```ts
try { try {
let gravity = [-0.27775216, 0.5351276, 9.788099]; let gravity = [-0.27775216, 0.5351276, 9.788099];
let geomagnetic = [210.87253, -78.6096, -111.44444]; let geomagnetic = [210.87253, -78.6096, -111.44444];
sensor.getRotationMatrix(gravity, geomagnetic, function (err, data) { sensor.getRotationMatrix(gravity, geomagnetic, function (err, data) {
if (err) { if (err) {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get rotationMatrix. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info('RotationMatrix' + JSON.stringify(data)); console.info('Succeeded in getting rotationMatrix' + JSON.stringify(data));
}) })
} catch (err) { } catch (error) {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get rotationMatrix. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -3374,18 +3422,18 @@ getRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt; ...@@ -3374,18 +3422,18 @@ getRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt;
**示例:** **示例:**
```js ```ts
try { try {
let gravity = [-0.27775216, 0.5351276, 9.788099]; let gravity = [-0.27775216, 0.5351276, 9.788099];
let geomagnetic = [210.87253, -78.6096, -111.44444]; let geomagnetic = [210.87253, -78.6096, -111.44444];
const promise = sensor.getRotationMatrix(gravity, geomagnetic); const promise = sensor.getRotationMatrix(gravity, geomagnetic);
promise.then((data) => { promise.then((data) => {
console.info('RotationMatrix' + JSON.stringify(data)); console.info('Succeeded in getting rotationMatrix' + JSON.stringify(data));
}, (err) => { }, (err) => {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get rotationMatrix. Code: ${err.code}, message: ${err.message}`);
}); });
} catch (err) { } catch (error) {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get rotationMatrix. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -3413,19 +3461,19 @@ getSensorList(callback: AsyncCallback&lt;Array&lt;Sensor&gt;&gt;): void ...@@ -3413,19 +3461,19 @@ getSensorList(callback: AsyncCallback&lt;Array&lt;Sensor&gt;&gt;): void
**示例:** **示例:**
```js ```ts
try { try {
sensor.getSensorList((err, data) => { sensor.getSensorList((err, data) => {
if (err) { if (err) {
console.error('Get sensorList failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get sensorList. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + JSON.stringify(data[i])); console.info('Succeeded in getting data[' + i + ']: ' + JSON.stringify(data[i]));
} }
}); });
} catch (err) { } catch (error) {
console.error('Get sensorList failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get sensorList. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -3453,17 +3501,17 @@ try { ...@@ -3453,17 +3501,17 @@ try {
**示例:** **示例:**
```js ```ts
try { try {
sensor.getSensorList().then((data) => { sensor.getSensorList().then((data) => {
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + JSON.stringify(data[i])); console.info('Succeeded in getting data[' + i + ']: ' + JSON.stringify(data[i]));
} }
}, (err) => { }, (err) => {
console.error('Get sensorList failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get sensorList. Code: ${err.code}, message: ${err.message}`);
}); });
} catch (err) { } catch (error) {
console.error('Get sensorList failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get sensorList. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -3492,17 +3540,17 @@ getSingleSensor(type: SensorId, callback: AsyncCallback&lt;Sensor&gt;): void ...@@ -3492,17 +3540,17 @@ getSingleSensor(type: SensorId, callback: AsyncCallback&lt;Sensor&gt;): void
**示例:** **示例:**
```js ```ts
try { try {
sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER, (err, data) => { sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER, (err, data) => {
if (err) { if (err) {
console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get singleSensor. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info('Sensor: ' + JSON.stringify(data)); console.info('Succeeded in getting sensor: ' + JSON.stringify(data));
}); });
} catch (err) { } catch (error) {
console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get singleSensor. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -3536,15 +3584,15 @@ try { ...@@ -3536,15 +3584,15 @@ try {
**示例:** **示例:**
```js ```ts
try { try {
sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER).then((data) => { sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER).then((data) => {
console.info('Sensor: ' + JSON.stringify(data)); console.info('Succeeded in getting sensor: ' + JSON.stringify(data));
}, (err) => { }, (err) => {
console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get singleSensor . Code: ${err.code}, message: ${err.message}`);
}); });
} catch (err) { } catch (error) {
console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message); console.error(`Failed to get singleSensor . Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -4033,15 +4081,15 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Acceler ...@@ -4033,15 +4081,15 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Acceler
**示例:** **示例:**
```js ```ts
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('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, },
{interval: 100000000} { interval: 100000000 }
); );
``` ```
### LINEAR_ACCELERATION<sup>(deprecated)</sup> ### LINEAR_ACCELERATION<sup>(deprecated)</sup>
...@@ -4084,18 +4132,19 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback ...@@ -4084,18 +4132,19 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:** **示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){ ```ts
console.info('X-coordinate component: ' + data.x); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function (data) {
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking on. X-coordinate bias: ' + data.biasX);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking on. Y-coordinate bias: ' + data.biasY);
}, console.info('Succeeded in invoking on. Z-coordinate bias: ' + data.biasZ);
{interval: 100000000} },
); { interval: 100000000 }
``` );
```
### GRAVITY<sup>(deprecated)</sup> ### GRAVITY<sup>(deprecated)</sup>
...@@ -4117,15 +4166,15 @@ on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespons ...@@ -4117,15 +4166,15 @@ on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespons
**示例:** **示例:**
```js ```ts
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('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, },
{interval: 100000000} { interval: 100000000 }
); );
``` ```
### GYROSCOPE<sup>(deprecated)</sup> ### GYROSCOPE<sup>(deprecated)</sup>
...@@ -4148,15 +4197,16 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeRes ...@@ -4148,15 +4197,16 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeRes
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:** **示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){ ```ts
console.info('X-coordinate component: ' + data.x); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function (data) {
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
}, console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
{interval: 100000000} },
); { interval: 100000000 }
``` );
```
### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup> ### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup>
...@@ -4179,18 +4229,19 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback&lt;G ...@@ -4179,18 +4229,19 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback&lt;G
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:** **示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){ ```ts
console.info('X-coordinate component: ' + data.x); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function (data) {
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking on. X-coordinate bias: ' + data.biasX);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking on. Y-coordinate bias: ' + data.biasY);
}, console.info('Succeeded in invoking on. Z-coordinate bias: ' + data.biasZ);
{interval: 100000000} },
); { interval: 100000000 }
``` );
```
### SIGNIFICANT_MOTION<sup>(deprecated)</sup> ### SIGNIFICANT_MOTION<sup>(deprecated)</sup>
...@@ -4211,13 +4262,14 @@ on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback&lt;Sig ...@@ -4211,13 +4262,14 @@ on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback&lt;Sig
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:** **示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){ ```ts
console.info('Scalar data: ' + data.scalar); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function (data) {
}, console.info('Succeeded in invoking on. Scalar data: ' + data.scalar);
{interval: 100000000} },
); { interval: 100000000 }
``` );
```
### PEDOMETER_DETECTION<sup>(deprecated)</sup> ### PEDOMETER_DETECTION<sup>(deprecated)</sup>
...@@ -4240,13 +4292,14 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback&lt;Pe ...@@ -4240,13 +4292,14 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback&lt;Pe
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:** **示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){ ```ts
console.info('Scalar data: ' + data.scalar); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function (data) {
}, console.info('Succeeded in invoking on. Scalar data: ' + data.scalar);
{interval: 100000000} },
); { interval: 100000000 }
``` );
```
### PEDOMETER<sup>(deprecated)</sup> ### PEDOMETER<sup>(deprecated)</sup>
...@@ -4269,13 +4322,14 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerRes ...@@ -4269,13 +4322,14 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerRes
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:** **示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){ ```ts
console.info('Steps: ' + data.steps); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function (data) {
}, console.info('Succeeded in invoking on. Steps: ' + data.steps);
{interval: 100000000} },
); { interval: 100000000 }
``` );
```
### AMBIENT_TEMPERATURE<sup>(deprecated)</sup> ### AMBIENT_TEMPERATURE<sup>(deprecated)</sup>
...@@ -4297,13 +4351,13 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback&lt;Ambi ...@@ -4297,13 +4351,13 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback&lt;Ambi
**示例:** **示例:**
```js ```ts
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('Succeeded in invoking on. Temperature: ' + data.temperature);
}, },
{interval: 100000000} { interval: 100000000 }
); );
``` ```
### MAGNETIC_FIELD<sup>(deprecated)</sup> ### MAGNETIC_FIELD<sup>(deprecated)</sup>
...@@ -4325,15 +4379,15 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magneti ...@@ -4325,15 +4379,15 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magneti
**示例:** **示例:**
```js ```ts
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('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, },
{interval: 100000000} { interval: 100000000 }
); );
``` ```
### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup> ### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup>
...@@ -4354,18 +4408,19 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callbac ...@@ -4354,18 +4408,19 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callbac
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:** **示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){ ```ts
console.info('X-coordinate component: ' + data.x); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function (data) {
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking on. X-coordinate bias: ' + data.biasX);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking on. Y-coordinate bias: ' + data.biasY);
}, console.info('Succeeded in invoking on. Z-coordinate bias: ' + data.biasZ);
{interval: 100000000} },
); { interval: 100000000 }
``` );
```
### PROXIMITY<sup>(deprecated)</sup> ### PROXIMITY<sup>(deprecated)</sup>
...@@ -4386,13 +4441,14 @@ on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityRes ...@@ -4386,13 +4441,14 @@ on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityRes
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:** **示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){ ```ts
console.info('Distance: ' + data.distance); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function (data) {
}, console.info('Succeeded in invoking on. Distance: ' + data.distance);
{interval: 100000000} },
); { interval: 100000000 }
``` );
```
### HUMIDITY<sup>(deprecated)</sup> ### HUMIDITY<sup>(deprecated)</sup>
...@@ -4414,13 +4470,13 @@ on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRespo ...@@ -4414,13 +4470,13 @@ on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRespo
**示例:** **示例:**
```js ```ts
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('Succeeded in invoking on. Humidity: ' + data.humidity);
}, },
{interval: 100000000} { interval: 100000000 }
); );
``` ```
### BAROMETER<sup>(deprecated)</sup> ### BAROMETER<sup>(deprecated)</sup>
...@@ -4442,13 +4498,13 @@ on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerRes ...@@ -4442,13 +4498,13 @@ on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerRes
**示例:** **示例:**
```js ```ts
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('Succeeded in invoking on. Atmospheric pressure: ' + data.pressure);
}, },
{interval: 100000000} { interval: 100000000 }
); );
``` ```
### HALL<sup>(deprecated)</sup> ### HALL<sup>(deprecated)</sup>
...@@ -4469,13 +4525,14 @@ on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;, ...@@ -4469,13 +4525,14 @@ on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;,
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:** **示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){ ```ts
console.info('Status: ' + data.status); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, function (data) {
}, console.info('Succeeded in invoking on. Status: ' + data.status);
{interval: 100000000} },
); { interval: 100000000 }
``` );
```
### AMBIENT_LIGHT<sup>(deprecated)</sup> ### AMBIENT_LIGHT<sup>(deprecated)</sup>
...@@ -4497,13 +4554,13 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightRes ...@@ -4497,13 +4554,13 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightRes
**示例:** **示例:**
```js ```ts
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('Succeeded in invoking on. Illumination: ' + data.intensity);
}, },
{interval: 100000000} { interval: 100000000 }
); );
``` ```
### ORIENTATION<sup>(deprecated)</sup> ### ORIENTATION<sup>(deprecated)</sup>
...@@ -4524,15 +4581,16 @@ on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientatio ...@@ -4524,15 +4581,16 @@ on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientatio
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:** **示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){ ```ts
console.info('The device rotates at an angle around the X axis: ' + data.beta); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function (data) {
console.info('The device rotates at an angle around the Y axis: ' + data.gamma); console.info('Succeeded in the device rotating at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Z axis: ' + data.alpha); console.info('Succeeded in the device rotating at an angle around the Y axis: ' + data.gamma);
}, console.info('Succeeded in the device rotating at an angle around the Z axis: ' + data.alpha);
{interval: 100000000} },
); { interval: 100000000 }
``` );
```
### HEART_RATE<sup>(deprecated)</sup> ### HEART_RATE<sup>(deprecated)</sup>
...@@ -4573,16 +4631,17 @@ on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback&lt;Rotatio ...@@ -4573,16 +4631,17 @@ on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback&lt;Rotatio
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:** **示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){ ```ts
console.info('X-coordinate component: ' + data.x); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function (data) {
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Scalar quantity: ' + data.w); console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, console.info('Succeeded in invoking on. Scalar quantity: ' + data.w);
{interval: 100000000} },
); { interval: 100000000 }
``` );
```
### WEAR_DETECTION<sup>(deprecated)</sup> ### WEAR_DETECTION<sup>(deprecated)</sup>
...@@ -4603,13 +4662,14 @@ on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDet ...@@ -4603,13 +4662,14 @@ on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDet
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:** **示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){ ```ts
console.info('Wear status: ' + data.value); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function (data) {
}, console.info('Succeeded in invoking on. Wear status: ' + data.value);
{interval: 100000000} },
); { interval: 100000000 }
``` );
```
## sensor.once<sup>(deprecated)</sup> ## sensor.once<sup>(deprecated)</sup>
...@@ -4633,14 +4693,14 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Accele ...@@ -4633,14 +4693,14 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Accele
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | | callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ ```ts
console.info('X-coordinate component: ' + data.x); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function (data) {
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
} console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
); });
``` ```
### LINEAR_ACCELERATION<sup>(deprecated)</sup> ### LINEAR_ACCELERATION<sup>(deprecated)</sup>
...@@ -4681,17 +4741,17 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callba ...@@ -4681,17 +4741,17 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callba
| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | 是 | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | | callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | 是 | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 |
**示例:** **示例:**
```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function(data) { ```ts
console.info('X-coordinate component: ' + data.x); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function (data) {
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking once. X-coordinate bias: ' + data.biasX);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking once. Y-coordinate bias: ' + data.biasY);
} console.info('Succeeded in invoking once. Z-coordinate bias: ' + data.biasZ);
); });
``` ```
### GRAVITY<sup>(deprecated)</sup> ### GRAVITY<sup>(deprecated)</sup>
...@@ -4711,14 +4771,14 @@ once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespo ...@@ -4711,14 +4771,14 @@ once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespo
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 | | callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) { ```ts
console.info('X-coordinate component: ' + data.x); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function (data) {
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
} console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
); });
``` ```
### GYROSCOPE<sup>(deprecated)</sup> ### GYROSCOPE<sup>(deprecated)</sup>
...@@ -4740,14 +4800,14 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeR ...@@ -4740,14 +4800,14 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeR
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | | callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) { ```ts
console.info('X-coordinate component: ' + data.x); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function (data) {
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
} console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
); });
``` ```
### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup> ### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup>
...@@ -4769,17 +4829,16 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&l ...@@ -4769,17 +4829,16 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&l
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | | callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |
**示例:** **示例:**
```js ```ts
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('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking once. X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking once. Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking once. Z-coordinate bias: ' + data.biasZ);
} });
); ```
```
### SIGNIFICANT_MOTION<sup>(deprecated)</sup> ### SIGNIFICANT_MOTION<sup>(deprecated)</sup>
...@@ -4799,12 +4858,12 @@ once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback&lt;Si ...@@ -4799,12 +4858,12 @@ once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback&lt;Si
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | | callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) { ```ts
console.info('Scalar data: ' + data.scalar); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function (data) {
} console.info('Succeeded in invoking once. Scalar data: ' + data.scalar);
); });
``` ```
### PEDOMETER_DETECTION<sup>(deprecated)</sup> ### PEDOMETER_DETECTION<sup>(deprecated)</sup>
...@@ -4826,12 +4885,12 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback&lt;P ...@@ -4826,12 +4885,12 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback&lt;P
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | | callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) { ```ts
console.info('Scalar data: ' + data.scalar); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function (data) {
} console.info('Succeeded in invoking once. Scalar data: ' + data.scalar);
); });
``` ```
### PEDOMETER<sup>(deprecated)</sup> ### PEDOMETER<sup>(deprecated)</sup>
...@@ -4853,12 +4912,12 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerR ...@@ -4853,12 +4912,12 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerR
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 | | callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) { ```ts
console.info('Steps: ' + data.steps); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function (data) {
} console.info('Succeeded in invoking once. Steps: ' + data.steps);
); });
``` ```
### AMBIENT_TEMPERATURE<sup>(deprecated)</sup> ### AMBIENT_TEMPERATURE<sup>(deprecated)</sup>
...@@ -4878,12 +4937,12 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback&lt;A ...@@ -4878,12 +4937,12 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback&lt;A
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | | callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) { ```ts
console.info('Temperature: ' + data.temperature); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function (data) {
} console.info('Succeeded in invoking once. Temperature: ' + data.temperature);
); });
``` ```
### MAGNETIC_FIELD<sup>(deprecated)</sup> ### MAGNETIC_FIELD<sup>(deprecated)</sup>
...@@ -4903,14 +4962,14 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magne ...@@ -4903,14 +4962,14 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magne
| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | | callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) { ```ts
console.info('X-coordinate component: ' + data.x); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function (data) {
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
} console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
); });
``` ```
### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup> ### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup>
...@@ -4930,17 +4989,17 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callb ...@@ -4930,17 +4989,17 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callb
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | | callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) { ```ts
console.info('X-coordinate component: ' + data.x); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function (data) {
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking once. X-coordinate bias: ' + data.biasX);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking once. Y-coordinate bias: ' + data.biasY);
} console.info('Succeeded in invoking once. Z-coordinate bias: ' + data.biasZ);
); });
``` ```
### PROXIMITY<sup>(deprecated)</sup> ### PROXIMITY<sup>(deprecated)</sup>
...@@ -4960,12 +5019,13 @@ once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityR ...@@ -4960,12 +5019,13 @@ once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityR
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | | callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(data) { ```ts
console.info('Distance: ' + data.distance); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function (data) {
} console.info('Succeeded in invoking once. Distance: ' + data.distance);
); }
``` );
```
### HUMIDITY<sup>(deprecated)</sup> ### HUMIDITY<sup>(deprecated)</sup>
...@@ -4985,12 +5045,12 @@ once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRes ...@@ -4985,12 +5045,12 @@ once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRes
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | | callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) { ```ts
console.info('Humidity: ' + data.humidity); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function (data) {
} console.info('Succeeded in invoking once. Humidity: ' + data.humidity);
); });
``` ```
### BAROMETER<sup>(deprecated)</sup> ### BAROMETER<sup>(deprecated)</sup>
...@@ -5010,12 +5070,12 @@ once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerR ...@@ -5010,12 +5070,12 @@ once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerR
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | | callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) { ```ts
console.info('Atmospheric pressure: ' + data.pressure); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function (data) {
} console.info('Succeeded in invoking once. Atmospheric pressure: ' + data.pressure);
); });
``` ```
### HALL<sup>(deprecated)</sup> ### HALL<sup>(deprecated)</sup>
...@@ -5035,12 +5095,12 @@ once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt ...@@ -5035,12 +5095,12 @@ once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 | | callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) { ```ts
console.info('Status: ' + data.status); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function (data) {
} console.info('Succeeded in invoking once. Status: ' + data.status);
); });
``` ```
### AMBIENT_LIGHT<sup>(deprecated)</sup> ### AMBIENT_LIGHT<sup>(deprecated)</sup>
...@@ -5061,12 +5121,11 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightR ...@@ -5061,12 +5121,11 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightR
**示例:** **示例:**
```js ```ts
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('Succeeded in invoking once. invoking once. Illumination: ' + data.intensity);
} });
); ```
```
### ORIENTATION<sup>(deprecated)</sup> ### ORIENTATION<sup>(deprecated)</sup>
...@@ -5086,14 +5145,14 @@ once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientat ...@@ -5086,14 +5145,14 @@ once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientat
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 | | callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) { ```ts
console.info('The device rotates at an angle around the X axis: ' + data.beta); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function (data) {
console.info('The device rotates at an angle around the Y axis: ' + data.gamma); console.info('Succeeded in invoking the device rotateing at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Z axis: ' + data.alpha); console.info('Succeeded in invoking the device rotateing at an angle around the Y axis: ' + data.gamma);
} console.info('Succeeded in invoking the device rotateing at an angle around the Z axis: ' + data.alpha);
); });
``` ```
### ROTATION_VECTOR<sup>(deprecated)</sup> ### ROTATION_VECTOR<sup>(deprecated)</sup>
...@@ -5113,15 +5172,15 @@ once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback&lt;Rota ...@@ -5113,15 +5172,15 @@ once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback&lt;Rota
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | | callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |
**示例:** **示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) { ```ts
console.info('X-coordinate component: ' + data.x); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function (data) {
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Scalar quantity: ' + data.w); console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
} console.info('Succeeded in invoking once. Scalar quantity: ' + data.w);
); });
``` ```
### HEART_RATE<sup>(deprecated)</sup> ### HEART_RATE<sup>(deprecated)</sup>
...@@ -5160,12 +5219,11 @@ once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearD ...@@ -5160,12 +5219,11 @@ once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearD
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | | callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |
**示例:** **示例:**
```js ```ts
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("Succeeded in invoking once. Wear status: " + data.value);
} });
); ```
```
## sensor.off<sup>(deprecated)</sup> ## sensor.off<sup>(deprecated)</sup>
...@@ -5190,12 +5248,13 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback&lt;Accele ...@@ -5190,12 +5248,13 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback&lt;Accele
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('x-coordinate component: ' + data.x); console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback);
``` ```
...@@ -5220,15 +5279,16 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callb ...@@ -5220,15 +5279,16 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callb
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking off. X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking off. Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking off. Z-coordinate bias: ' + data.biasZ);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback);
``` ```
...@@ -5251,10 +5311,11 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback&lt;LightR ...@@ -5251,10 +5311,11 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback&lt;LightR
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info(' Illumination: ' + data.intensity); console.info('Succeeded in invoking off. Illumination: ' + data.intensity);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
``` ```
...@@ -5277,10 +5338,11 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback&lt; ...@@ -5277,10 +5338,11 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback&lt;
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('Temperature: ' + data.temperature); console.info('Succeeded in invoking off. Temperature: ' + data.temperature);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback);
``` ```
...@@ -5303,10 +5365,11 @@ off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback&lt;BarometerR ...@@ -5303,10 +5365,11 @@ off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback&lt;BarometerR
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('Atmospheric pressure: ' + data.pressure); console.info('Succeeded in invoking off. Atmospheric pressure: ' + data.pressure);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback);
``` ```
...@@ -5329,13 +5392,14 @@ off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback&lt;GravityRespo ...@@ -5329,13 +5392,14 @@ off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback&lt;GravityRespo
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
} }
sensor.off( sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
``` ```
### GYROSCOPE<sup>(deprecated)</sup> ### GYROSCOPE<sup>(deprecated)</sup>
...@@ -5359,12 +5423,13 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback&lt;GyroscopeR ...@@ -5359,12 +5423,13 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback&lt;GyroscopeR
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback);
``` ```
...@@ -5389,12 +5454,13 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback& ...@@ -5389,12 +5454,13 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback&
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback);
``` ```
...@@ -5417,10 +5483,11 @@ off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback&lt;HallResponse&gt ...@@ -5417,10 +5483,11 @@ off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback&lt;HallResponse&gt
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('Status: ' + data.status); console.info('Succeeded in invoking off. Status: ' + data.status);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback);
``` ```
...@@ -5462,10 +5529,11 @@ off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityRes ...@@ -5462,10 +5529,11 @@ off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityRes
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('Humidity: ' + data.humidity); console.info('Succeeded in invoking off. Humidity: ' + data.humidity);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback);
``` ```
...@@ -5507,12 +5575,13 @@ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback&lt; ...@@ -5507,12 +5575,13 @@ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback&lt;
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback);
``` ```
...@@ -5535,15 +5604,16 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); ...@@ -5535,15 +5604,16 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback);
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX); console.info('Succeeded in invoking off. X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY); console.info('Succeeded in invoking off. Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ); console.info('Succeeded in invoking off. Z-coordinate bias: ' + data.biasZ);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback);
``` ```
...@@ -5566,12 +5636,13 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callbac ...@@ -5566,12 +5636,13 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callbac
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('Succeeded in invoking off. 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('Succeeded in invoking off. The device rotates at an angle around the Y axis: ' + data.gamma);
console.info('The device rotates at an angle around the Z axis: ' + data.alpha); console.info('Succeeded in invoking off. The device rotates at an angle around the Z axis: ' + data.alpha);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback);
``` ```
...@@ -5596,10 +5667,11 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerR ...@@ -5596,10 +5667,11 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerR
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('Steps: ' + data.steps); console.info('Succeeded in invoking off. Steps: ' + data.steps);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
``` ```
...@@ -5624,10 +5696,11 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback&lt; ...@@ -5624,10 +5696,11 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback&lt;
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('Scalar data: ' + data.scalar); console.info('Succeeded in invoking off. Scalar data: ' + data.scalar);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback);
``` ```
...@@ -5650,10 +5723,11 @@ off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback&lt;ProximityR ...@@ -5650,10 +5723,11 @@ off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback&lt;ProximityR
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('Distance: ' + data.distance); console.info('Succeeded in invoking off. Distance: ' + data.distance);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, callback);
``` ```
...@@ -5676,13 +5750,14 @@ off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback&lt;Rota ...@@ -5676,13 +5750,14 @@ off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback&lt;Rota
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z); console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
console.info('Scalar quantity: ' + data.w); console.info('Succeeded in invoking off. Scalar quantity: ' + data.w);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback);
``` ```
...@@ -5705,10 +5780,11 @@ off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback&lt;S ...@@ -5705,10 +5780,11 @@ off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback&lt;S
**示例:** **示例:**
```js ```ts
function callback(data) { function callback(data) {
console.info('Scalar data: ' + data.scalar); console.info('Succeeded in invoking off. Scalar data: ' + data.scalar);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback);
``` ```
...@@ -5731,10 +5807,11 @@ off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback&lt;WearD ...@@ -5731,10 +5807,11 @@ off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback&lt;WearD
**示例:** **示例:**
```js ```ts
function accCallback(data) { function accCallback(data) {
console.info('Wear status: ' + data.value); console.info('Succeeded in invoking off. Wear status: ' + data.value);
} }
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, accCallback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, accCallback);
``` ```
...@@ -5758,17 +5835,17 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co ...@@ -5758,17 +5835,17 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co
**示例:** **示例:**
```js ```ts
sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y: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(`Failed to operate. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info("Operation succeeded. Data obtained: " + data); console.info("Succeeded in starting Operation. 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("Succeeded in getting transformCoordinateSystem data[ " + i + "] = " + data[i]);
} }
}) })
``` ```
## sensor.transformCoordinateSystem<sup>(deprecated)</sup> ## sensor.transformCoordinateSystem<sup>(deprecated)</sup>
...@@ -5795,15 +5872,15 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co ...@@ -5795,15 +5872,15 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co
**示例:** **示例:**
```js ```ts
const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y: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 succeeded."); console.info("Succeeded in starting Operation");
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("Succeeded in getting transformCoordinateSystem data[ " + i + "] = " + data[i]);
} }
}).catch((err) => { }).catch((err) => {
console.info("Operation failed"); console.error(`Failed to operate.`);
}) })
``` ```
...@@ -5826,13 +5903,14 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callba ...@@ -5826,13 +5903,14 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callba
| callback | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 是 | 返回磁场信息。 | | callback | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 是 | 返回磁场信息。 |
**示例:** **示例:**
```js
sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000, function(err, data) { ```ts
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(`Failed to operate. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info('sensor_getGeomagneticField_callback x: ' + data.x + ',y: ' + data.y + ',z: ' + console.info('Succeeded in getting sensor_getGeomagneticField_callback x: ' + data.x + ',y: ' + data.y + ',z: ' +
data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
}); });
...@@ -5860,16 +5938,17 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promi ...@@ -5860,16 +5938,17 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promi
| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 返回磁场信息。 | | Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 返回磁场信息。 |
**示例:** **示例:**
```js
const promise = sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000); ```ts
promise.then((data) => { const promise = sensor.getGeomagneticField({ latitude: 80, longitude: 0, altitude: 0 }, 1580486400000);
console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' + promise.then((data) => {
console.info('Succeeded in getting 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 +
',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
}).catch((reason) => { }).catch((reason) => {
console.info('Operation failed.'); console.error(`Failed to operate.`);
}) })
``` ```
## sensor.getAltitude<sup>(deprecated)</sup> ## sensor.getAltitude<sup>(deprecated)</sup>
...@@ -5891,16 +5970,15 @@ getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallbac ...@@ -5891,16 +5970,15 @@ getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallbac
**示例:** **示例:**
```js ```ts
sensor.getAltitude(0, 200, function(err, data) { sensor.getAltitude(0, 200, function (err, data) {
if (err) { if (err) {
console.error( console.error(`Failed to operate. Code: ${err.code}, message: ${err.message}`);
"Operation failed. Error code: " + err.code + ", message: " + err.message);
return; return;
} }
console.info("Succeeded to get getAltitude interface get data: " + data); console.info("Succeeded in getting getAltitude interface get data: " + data);
}); });
``` ```
## sensor.getAltitude<sup>(deprecated)</sup> ## sensor.getAltitude<sup>(deprecated)</sup>
...@@ -5927,14 +6005,14 @@ getAltitude(seaPressure: number, currentPressure: number): Promise&lt;number&gt; ...@@ -5927,14 +6005,14 @@ getAltitude(seaPressure: number, currentPressure: number): Promise&lt;number&gt;
**示例:** **示例:**
```js ```ts
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('Succeeded in getting sensor_getAltitude_Promise success', data);
}).catch((err) => { }).catch((err) => {
console.error("Operation failed"); console.error(`Failed to operate.`);
}) })
``` ```
## sensor.getGeomagneticDip<sup>(deprecated)</sup> ## sensor.getGeomagneticDip<sup>(deprecated)</sup>
...@@ -5956,16 +6034,15 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallbac ...@@ -5956,16 +6034,15 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallbac
**示例:** **示例:**
```js ```ts
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('SensorJsAPI--->Failed to register data, error code is:' + err.code + ', message: ' + console.error(`Failed to register data. Code: ${err.code}, message: ${err.message}`);
err.message);
return; return;
} }
console.info("Succeeded to get getGeomagneticDip interface get data: " + data); console.info("Succeeded in getting getGeomagneticDip interface get data: " + data);
}) })
``` ```
## sensor.getGeomagneticDip<sup>(deprecated)</sup> ## sensor.getGeomagneticDip<sup>(deprecated)</sup>
...@@ -5991,14 +6068,14 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;): Promise&lt;number&gt; ...@@ -5991,14 +6068,14 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;): Promise&lt;number&gt;
**示例:** **示例:**
```js ```ts
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 succeeded', data); console.info('Succeeded in get GeomagneticDip_promise', data);
}).catch((err) => { }).catch((err) => {
console.error("Operation failed"); console.error(`Failed to operate.`);
}) })
``` ```
## sensor. getAngleModify<sup>(deprecated)</sup> ## sensor. getAngleModify<sup>(deprecated)</sup>
...@@ -6020,19 +6097,17 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar ...@@ -6020,19 +6097,17 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar
**示例:** **示例:**
```js ```ts
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('Failed to register data, error code is: ' + err.code + ', message: ' + console.error(`Failed to register data. Code: ${err.code}, message: ${err.message}`);
err.message);
return; return;
} }
for (var i=0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
} }
}) })
``` ```
## sensor. getAngleModify<sup>(deprecated)</sup> ## sensor. getAngleModify<sup>(deprecated)</sup>
...@@ -6059,18 +6134,17 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar ...@@ -6059,18 +6134,17 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar
**示例:** **示例:**
```js ```ts
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('getAngleModify_promise success'); console.info('Succeeded in getting AngleModify_promise.');
for (var i=0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]); console.info("Succeeded in getting data[" + i + "]: " + data[i]);
} }
}).catch((reason) => { }).catch((reason) => {
console.info("promise::catch", reason); console.info("Succeeded in getting promise::catch", reason);
}) })
``` ```
## sensor.createRotationMatrix<sup>(deprecated)</sup> ## sensor.createRotationMatrix<sup>(deprecated)</sup>
...@@ -6091,19 +6165,17 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallbac ...@@ -6091,19 +6165,17 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallbac
**示例:** **示例:**
```js ```ts
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('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error(`Failed to register data. Code: ${err.code}, message: ${err.message}`);
err.message);
return; return;
} }
for (var i=0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]); console.info("Succeeded in getting data[" + i + "]: " + data[i]);
} }
}) })
``` ```
## sensor.createRotationMatrix<sup>(deprecated)</sup> ## sensor.createRotationMatrix<sup>(deprecated)</sup>
...@@ -6129,18 +6201,17 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;n ...@@ -6129,18 +6201,17 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;n
**示例:** **示例:**
```js ```ts
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('createRotationMatrix_promise success'); console.info('Succeeded in getting createRotationMatrix_promise');
for (var i=0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
} }
}).catch((reason) => { }).catch((reason) => {
console.info("promise::catch", reason); console.info("Succeeded in getting promise::catch", reason);
}) })
``` ```
## sensor.createQuaternion<sup>(deprecated)</sup> ## sensor.createQuaternion<sup>(deprecated)</sup>
...@@ -6161,19 +6232,17 @@ createQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt ...@@ -6161,19 +6232,17 @@ createQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt
**示例:** **示例:**
```js ```ts
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('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error(`Failed to register data. Code: ${err.code}, message: ${err.message}`);
err.message);
return; return;
} }
for (var i=0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]); console.info("Succeeded in getting data[" + i + "]: " + data[i]);
} }
}) })
``` ```
## sensor.createQuaternion<sup>(deprecated)</sup> ## sensor.createQuaternion<sup>(deprecated)</sup>
...@@ -6199,18 +6268,17 @@ createQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;numbe ...@@ -6199,18 +6268,17 @@ createQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;numbe
**示例:** **示例:**
```js ```ts
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 succeeded'); console.info('Succeeded in getting createQuaternion_promise');
for (var i=0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
} }
}).catch((err) => { }).catch((err) => {
console.info('promise failed'); console.info(`Failed to get promise.`);
}) })
``` ```
## sensor.getDirection<sup>(deprecated)</sup> ## sensor.getDirection<sup>(deprecated)</sup>
...@@ -6231,20 +6299,18 @@ getDirection(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Arr ...@@ -6231,20 +6299,18 @@ getDirection(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Arr
**示例:** **示例:**
```js ```ts
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('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error(`Failed to register data. Code: ${err.code}, message: ${err.message}`);
err.message);
return; return;
} }
console.info("SensorJsAPI--->Succeeded to get getDirection interface get data: " + data); console.info("Succeeded in getting getDirection interface get data: " + data);
for (var i = 1; i < data.length; i++) { for (var i = 1; i < data.length; i++) {
console.info("sensor_getDirection_callback" + data[i]); console.info("Succeeded in getting sensor_getDirection_callback" + data[i]);
} }
}) })
``` ```
## sensor.getDirection<sup>(deprecated)</sup> ## sensor.getDirection<sup>(deprecated)</sup>
...@@ -6270,18 +6336,17 @@ getDirection(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt ...@@ -6270,18 +6336,17 @@ getDirection(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt
**示例:** **示例:**
```js ```ts
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); console.info('Succeeded in getting sensor_getAltitude_Promise', data);
for (var i = 1; i < data.length; i++) { for (var i = 1; i < data.length; i++) {
console.info("sensor_getDirection_promise" + data[i]); console.info("Succeeded in getting sensor_getDirection_promise" + data[i]);
} }
}).catch((err) => { }).catch((err) => {
console.info('promise failed'); console.info(`Failed to get promise.`);
}) })
``` ```
## sensor.createRotationMatrix<sup>(deprecated)</sup> ## sensor.createRotationMatrix<sup>(deprecated)</sup>
...@@ -6303,16 +6368,15 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number& ...@@ -6303,16 +6368,15 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&
**示例:** **示例:**
```js ```ts
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('error code is: ' + err.code + ', message: ' + err.message); console.error(`Failed to get create rotationMatrix. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.info(JSON.stringify(data)); console.info(JSON.stringify(data));
}) })
``` ```
## sensor.createRotationMatrix<sup>(deprecated)</sup> ## sensor.createRotationMatrix<sup>(deprecated)</sup>
...@@ -6339,11 +6403,11 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number& ...@@ -6339,11 +6403,11 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&
**示例:** **示例:**
```js ```ts
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(JSON.stringify(data)); console.info(JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.info('promise failed'); console.info(`Failed to get promise.`);
}) })
``` ```
...@@ -615,7 +615,7 @@ hasSimCard\(slotId: number, callback: AsyncCallback\<boolean\>\): void ...@@ -615,7 +615,7 @@ hasSimCard\(slotId: number, callback: AsyncCallback\<boolean\>\): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | -------------------------------------- | | -------- | --------------------------- | ---- | -------------------------------------- |
| slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 | | slotId | number | 是 | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调返回指定卡槽是否插卡,如果插卡返回true。 |
**错误码:** **错误码:**
......
...@@ -37,16 +37,16 @@ import sensor from '@system.sensor'; ...@@ -37,16 +37,16 @@ import sensor from '@system.sensor';
**示例:** **示例:**
```js ```ts
sensor.subscribeAccelerometer({ sensor.subscribeAccelerometer({
interval: 'normal', interval: 'normal',
success: function(ret) { success: function (ret) {
console.log('X-axis data: ' + ret.x); console.info('Succeeded in subscribing. X-axis data: ' + ret.x);
console.log('Y-axis data: ' + ret.y); console.info('Succeeded in subscribing. Y-axis data: ' + ret.y);
console.log('Z-axis data: ' + ret.z); console.info('Succeeded in subscribing. Z-axis data: ' + ret.z);
}, },
fail: function(data, code) { fail: function (data, code) {
console.error('Subscription failed. Code: ' + code + '; Data: ' + data); console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
}, },
}); });
``` ```
...@@ -66,7 +66,7 @@ unsubscribeAccelerometer(): void ...@@ -66,7 +66,7 @@ unsubscribeAccelerometer(): void
**示例:** **示例:**
```js ```ts
sensor.unsubscribeAccelerometer(); sensor.unsubscribeAccelerometer();
``` ```
...@@ -86,13 +86,13 @@ sensor.unsubscribeAccelerometer(); ...@@ -86,13 +86,13 @@ sensor.unsubscribeAccelerometer();
**示例:** **示例:**
```js ```ts
sensor.subscribeCompass({ sensor.subscribeCompass({
success: function(ret) { success: function (ret) {
console.log('Get data direction:' + ret.direction); console.info('Succeeded in subscribing. Get data direction:' + ret.direction);
}, },
fail: function(data, code) { fail: function (data, code) {
console.error('Subscription failed. Code: ' + code + '; Data: ' + data); console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
}, },
}); });
``` ```
...@@ -110,7 +110,7 @@ unsubscribeCompass(): void ...@@ -110,7 +110,7 @@ unsubscribeCompass(): void
**示例:** **示例:**
```js ```ts
sensor.unsubscribeCompass(); sensor.unsubscribeCompass();
``` ```
...@@ -130,13 +130,14 @@ sensor.unsubscribeCompass(); ...@@ -130,13 +130,14 @@ sensor.unsubscribeCompass();
**示例:** **示例:**
```js ```ts
sensor.subscribeProximity({ sensor.subscribeProximity({
success: function(ret) { success: function (ret) {
console.log('Get data distance:' + ret.distance); console.info('Succeeded in subscribing. Get data distance:' + ret.distance);
}, },
fail: function(data, code) { fail: function (data, code) {
console.error('Subscription failed. Code: ' + code + '; Data: ' + data); console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
}, },
}); });
``` ```
...@@ -154,7 +155,7 @@ unsubscribeProximity(): void ...@@ -154,7 +155,7 @@ unsubscribeProximity(): void
**示例:** **示例:**
```js ```ts
sensor.unsubscribeProximity(); sensor.unsubscribeProximity();
``` ```
...@@ -174,13 +175,13 @@ sensor.unsubscribeProximity(); ...@@ -174,13 +175,13 @@ sensor.unsubscribeProximity();
**示例:** **示例:**
```js ```ts
sensor.subscribeLight({ sensor.subscribeLight({
success: function(ret) { success: function (ret) {
console.log('Get data intensity:' + ret.intensity); console.info('Succeeded in subscribing. Get data intensity:' + ret.intensity);
}, },
fail: function(data, code) { fail: function (data, code) {
console.error('Subscription failed. Code: ' + code + '; Data: ' + data); console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
}, },
}); });
``` ```
...@@ -198,7 +199,7 @@ unsubscribeLight(): void ...@@ -198,7 +199,7 @@ unsubscribeLight(): void
**示例:** **示例:**
```js ```ts
sensor.unsubscribeLight(); sensor.unsubscribeLight();
``` ```
...@@ -220,13 +221,13 @@ sensor.unsubscribeLight(); ...@@ -220,13 +221,13 @@ sensor.unsubscribeLight();
**示例:** **示例:**
```js ```ts
sensor.subscribeStepCounter({ sensor.subscribeStepCounter({
success: function(ret) { success: function (ret) {
console.log('Get step value:' + ret.steps); console.info('Succeeded in subscribing. Get step value:' + ret.steps);
}, },
fail: function(data, code) { fail: function (data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data); console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
}, },
}); });
``` ```
...@@ -246,7 +247,7 @@ unsubscribeStepCounter(): void ...@@ -246,7 +247,7 @@ unsubscribeStepCounter(): void
**示例:** **示例:**
```js ```ts
sensor.unsubscribeStepCounter(); sensor.unsubscribeStepCounter();
``` ```
...@@ -267,13 +268,13 @@ subscribeBarometer(options: SubscribeBarometerOptions): void ...@@ -267,13 +268,13 @@ subscribeBarometer(options: SubscribeBarometerOptions): void
**示例:** **示例:**
```js ```ts
sensor.subscribeBarometer({ sensor.subscribeBarometer({
success: function(ret) { success: function (ret) {
console.log('Get data value:' + ret.pressure); console.info('Succeeded in subscribing. Get data value:' + ret.pressure);
}, },
fail: function(data, code) { fail: function (data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data); console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
}, },
}); });
``` ```
...@@ -292,7 +293,7 @@ unsubscribeBarometer(): void ...@@ -292,7 +293,7 @@ unsubscribeBarometer(): void
**示例:** **示例:**
```js ```ts
sensor.unsubscribeBarometer(); sensor.unsubscribeBarometer();
``` ```
...@@ -315,13 +316,13 @@ sensor.unsubscribeBarometer(); ...@@ -315,13 +316,13 @@ sensor.unsubscribeBarometer();
**示例:** **示例:**
```js ```ts
sensor.subscribeHeartRate({ sensor.subscribeHeartRate({
success: function(ret) { success: function (ret) {
console.log('Get heartrate value:' + ret.heartRate); console.info('Succeeded in subscribing. Get heartrate value:' + ret.heartRate);
}, },
fail: function(data, code) { fail: function (data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data); console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
}, },
}); });
``` ```
...@@ -342,7 +343,7 @@ unsubscribeHeartRate(): void ...@@ -342,7 +343,7 @@ unsubscribeHeartRate(): void
**示例:** **示例:**
```js ```ts
sensor.unsubscribeHeartRate(); sensor.unsubscribeHeartRate();
``` ```
...@@ -362,13 +363,13 @@ sensor.unsubscribeHeartRate(); ...@@ -362,13 +363,13 @@ sensor.unsubscribeHeartRate();
**示例:** **示例:**
```js ```ts
sensor.subscribeOnBodyState({ sensor.subscribeOnBodyState({
success: function(ret) { success: function (ret) {
console.log('Get on-body state value:' + ret.value); console.info('Succeeded in subscribing. Get on-body state value:' + ret.value);
}, },
fail: function(data, code) { fail: function (data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data); console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
}, },
}); });
``` ```
...@@ -386,7 +387,7 @@ unsubscribeOnBodyState(): void ...@@ -386,7 +387,7 @@ unsubscribeOnBodyState(): void
**示例:** **示例:**
```js ```ts
sensor.unsubscribeOnBodyState(); sensor.unsubscribeOnBodyState();
``` ```
...@@ -406,13 +407,13 @@ sensor.unsubscribeOnBodyState(); ...@@ -406,13 +407,13 @@ sensor.unsubscribeOnBodyState();
**示例:** **示例:**
```js ```ts
sensor.getOnBodyState({ sensor.getOnBodyState({
success: function(ret) { success: function (ret) {
console.log('On body state: ' + ret.value); console.info('Succeeded in subscribing. On body state: ' + ret.value);
}, },
fail: function(data, code) { fail: function (data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data); console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
}, },
}); });
``` ```
...@@ -435,16 +436,16 @@ sensor.getOnBodyState({ ...@@ -435,16 +436,16 @@ sensor.getOnBodyState({
**示例:** **示例:**
```js ```ts
sensor.subscribeDeviceOrientation({ sensor.subscribeDeviceOrientation({
interval: 'normal', interval: 'normal',
success: function(ret) { success: function (ret) {
console.log('Alpha data: ' + ret.alpha); console.info('Succeeded in subscribing. Alpha data: ' + ret.alpha);
console.log('Beta data: ' + ret.beta); console.info('Succeeded in subscribing. Beta data: ' + ret.beta);
console.log('Gamma data: ' + ret.gamma); console.info('Succeeded in subscribing. Gamma data: ' + ret.gamma);
}, },
fail: function(data, code) { fail: function (data, code) {
console.error('Subscription failed. Code: ' + code + '; Data: ' + data); console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
} }
}); });
``` ```
...@@ -462,7 +463,7 @@ unsubscribeDeviceOrientation(): void ...@@ -462,7 +463,7 @@ unsubscribeDeviceOrientation(): void
**示例:** **示例:**
```js ```ts
sensor.unsubscribeDeviceOrientation(); sensor.unsubscribeDeviceOrientation();
``` ```
...@@ -486,16 +487,16 @@ sensor.unsubscribeDeviceOrientation(); ...@@ -486,16 +487,16 @@ sensor.unsubscribeDeviceOrientation();
**示例:** **示例:**
```js ```ts
sensor.subscribeGyroscope({ sensor.subscribeGyroscope({
interval: 'normal', interval: 'normal',
success: function(ret) { success: function (ret) {
console.log('X-axis data: ' + ret.x); console.info('Succeeded in subscribing. X-axis data: ' + ret.x);
console.log('Y-axis data: ' + ret.y); console.info('Succeeded in subscribing. Y-axis data: ' + ret.y);
console.log('Z-axis data: ' + ret.z); console.info('Succeeded in subscribing. Z-axis data: ' + ret.z);
}, },
fail: function(data, code) { fail: function (data, code) {
console.error('Subscription failed. Code: ' + code + '; data: ' + data); console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
} }
}); });
``` ```
...@@ -515,7 +516,7 @@ unsubscribeGyroscope(): void ...@@ -515,7 +516,7 @@ unsubscribeGyroscope(): void
**示例:** **示例:**
```js ```ts
sensor.unsubscribeGyroscope(); sensor.unsubscribeGyroscope();
``` ```
......
...@@ -36,17 +36,17 @@ import vibrator from '@system.vibrator'; ...@@ -36,17 +36,17 @@ import vibrator from '@system.vibrator';
**示例:** **示例:**
```js ```ts
vibrator.vibrate({ vibrator.vibrate({
mode: 'short', mode: 'short',
success: function() { success: function() {
console.log('vibrate is successful'); console.info('Succeed in vibrating');
}, },
fail: function(data, code) { fail: function(data, code) {
console.log("vibrate is failed, data: " + data + ", code: " + code); console.info(`Failed to vibrate. Data: ${data}, code: ${code}`);
}, },
complete: function() { complete: function() {
console.log('vibrate is completed'); console.info('completed in vibrating');
} }
}); });
``` ```
......
...@@ -2080,7 +2080,7 @@ let result = that.encodeSync(array); ...@@ -2080,7 +2080,7 @@ let result = that.encodeSync(array);
### encodeToStringSync<sup>9+</sup> ### encodeToStringSync<sup>9+</sup>
encodeToStringSync(src: Uint8Array): string encodeToStringSync(src: Uint8Array, options?: Type): string
通过输入参数编码后输出对应文本。 通过输入参数编码后输出对应文本。
...@@ -2091,6 +2091,7 @@ encodeToStringSync(src: Uint8Array): string ...@@ -2091,6 +2091,7 @@ encodeToStringSync(src: Uint8Array): string
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------- | ---- | ------------------- | | ------ | ---------- | ---- | ------------------- |
| src | Uint8Array | 是 | 编码输入Uint8数组。 | | src | Uint8Array | 是 | 编码输入Uint8数组。 |
| options<sup>10+</sup> | [Type](#type10) | 否 | 从API version 10开始支持该参数,表示对应的编码格式。<br/>此参数可选,可选值为:util.Type.BASIC和util.Type.MIME,默认值为:util.Type.BASIC。<br/>- 当参数取值为util.Type.BASIC时,输出结果包含:64个可打印字符,包括大写字母A-Z、小写字母a-z、数字0-9共62个字符,再加上另外2个'+'和'/',没有回车符、换行符。<br/>- 当参数取值为util.Type.MIME时,输出结果包含:64个可打印字符,包括大写字母A-Z、小写字母a-z、数字0-9共62个字符,再加上另外2个'+'和'/',编码输出每一行不超过76个字符,而且每行以'\r\n'符结束。|
**返回值:** **返回值:**
...@@ -2102,14 +2103,14 @@ encodeToStringSync(src: Uint8Array): string ...@@ -2102,14 +2103,14 @@ encodeToStringSync(src: Uint8Array): string
```js ```js
let that = new util.Base64Helper(); let that = new util.Base64Helper();
let array = new Uint8Array([115,49,51]); let array = new Uint8Array([77,97,110,105,115,100,105,115,116,105,110,103,117,105,115,104,101,100,110,111,116,111,110,108,121,98,121,104,105,115,114,101,97,115,111,110,98,117,116,98,121,116,104,105,115,115,105,110,103,117,108,97,114,112,97,115,115,105,111,110,102,114,111,109,111,116,104,101,114,97,110,105,109,97,108,115,119,104,105,99,104,105,115,97,108,117,115,116,111,102,116,104,101,109,105,110,100,101,120,99,101,101,100,115,116,104,101,115,104,111,114,116,118,101,104,101,109,101,110,99,101,111,102,97,110,121,99,97,114,110,97,108,112,108,101,97,115,117,114,101]);
let result = that.encodeToStringSync(array); let result = that.encodeToStringSync(array, util.Type.MIME);
``` ```
### decodeSync<sup>9+</sup> ### decodeSync<sup>9+</sup>
decodeSync(src: Uint8Array | string): Uint8Array decodeSync(src: Uint8Array | string, options?: Type): Uint8Array
通过输入参数解码后输出对应文本。 通过输入参数解码后输出对应文本。
...@@ -2120,6 +2121,7 @@ decodeSync(src: Uint8Array | string): Uint8Array ...@@ -2120,6 +2121,7 @@ decodeSync(src: Uint8Array | string): Uint8Array
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------------ | ---- | ----------------------------- | | ------ | ------------------------------ | ---- | ----------------------------- |
| src | Uint8Array&nbsp;\|&nbsp;string | 是 | 解码输入Uint8数组或者字符串。 | | src | Uint8Array&nbsp;\|&nbsp;string | 是 | 解码输入Uint8数组或者字符串。 |
| options<sup>10+</sup> | [Type](#type10) | 否 | 从API version 10开始支持该参数,表示对应的编码格式。<br/>此参数可选,可选值为:util.Type.BASIC和util.Type.MIME,默认值为:util.Type.BASIC。<br/>- 当参数取值为util.Type.BASIC时,表示入参包含:64个可打印字符,包括大写字母A-Z、小写字母a-z、数字0-9共62个字符,再加上另外2个'+'和'/',没有回车符、换行符。<br/>- 当参数取值为util.Type.MIME时,表示入参包含:64个可打印字符,包括大写字母A-Z、小写字母a-z、数字0-9共62个字符,再加上另外2个'+'和'/',每一行不超过76个字符,而且每行以'\r\n'符结束。 |
**返回值:** **返回值:**
...@@ -2131,8 +2133,8 @@ decodeSync(src: Uint8Array | string): Uint8Array ...@@ -2131,8 +2133,8 @@ decodeSync(src: Uint8Array | string): Uint8Array
```js ```js
let that = new util.Base64Helper(); let that = new util.Base64Helper();
let buff = 'czEz'; let buff = 'TWFuaXNkaXN0aW5ndWlzaGVkbm90b25seWJ5aGlzcmVhc29uYnV0Ynl0aGlzc2luZ3VsYXJwYXNz\r\naW9uZnJvbW90aGVyYW5pbWFsc3doaWNoaXNhbHVzdG9mdGhlbWluZGV4Y2VlZHN0aGVzaG9ydHZl\r\naGVtZW5jZW9mYW55Y2FybmFscGxlYXN1cmU=\r\n';
let result = that.decodeSync(buff); let result = that.decodeSync(buff, util.Type.MIME);
``` ```
...@@ -2172,7 +2174,7 @@ that.encode(array).then(val=>{ ...@@ -2172,7 +2174,7 @@ that.encode(array).then(val=>{
### encodeToString<sup>9+</sup> ### encodeToString<sup>9+</sup>
encodeToString(src: Uint8Array): Promise&lt;string&gt; encodeToString(src: Uint8Array, options?: Type): Promise&lt;string&gt;
通过输入参数异步编码后输出对应文本。 通过输入参数异步编码后输出对应文本。
...@@ -2183,6 +2185,7 @@ encodeToString(src: Uint8Array): Promise&lt;string&gt; ...@@ -2183,6 +2185,7 @@ encodeToString(src: Uint8Array): Promise&lt;string&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------- | ---- | ----------------------- | | ------ | ---------- | ---- | ----------------------- |
| src | Uint8Array | 是 | 异步编码输入Uint8数组。 | | src | Uint8Array | 是 | 异步编码输入Uint8数组。 |
| options<sup>10+</sup> | [Type](#type10) | 否 | 从API version 10开始支持该参数,表示对应的编码格式。<br/>此参数可选,可选值为:util.Type.BASIC和util.Type.MIME,默认值为:util.Type.BASIC。<br/>- 当参数取值为util.Type.BASIC时,输出结果包含:64个可打印字符,包括大写字母A-Z、小写字母a-z、数字0-9共62个字符,再加上另外2个'+'和'/',没有回车符、换行符。<br/>- 当参数取值为util.Type.MIME时,输出结果包含:64个可打印字符,包括大写字母A-Z、小写字母a-z、数字0-9共62个字符,再加上另外2个'+'和'/',编码输出每一行不超过76个字符,而且每行以'\r\n'符结束。 |
**返回值:** **返回值:**
...@@ -2194,16 +2197,16 @@ encodeToString(src: Uint8Array): Promise&lt;string&gt; ...@@ -2194,16 +2197,16 @@ encodeToString(src: Uint8Array): Promise&lt;string&gt;
```js ```js
let that = new util.Base64Helper(); let that = new util.Base64Helper();
let array = new Uint8Array([115,49,51]); let array = new Uint8Array([77,97,110,105,115,100,105,115,116,105,110,103,117,105,115,104,101,100,110,111,116,111,110,108,121,98,121,104,105,115,114,101,97,115,111,110,98,117,116,98,121,116,104,105,115,115,105,110,103,117,108,97,114,112,97,115,115,105,111,110,102,114,111,109,111,116,104,101,114,97,110,105,109,97,108,115,119,104,105,99,104,105,115,97,108,117,115,116,111,102,116,104,101,109,105,110,100,101,120,99,101,101,100,115,116,104,101,115,104,111,114,116,118,101,104,101,109,101,110,99,101,111,102,97,110,121,99,97,114,110,97,108,112,108,101,97,115,117,114,101]);
that.encodeToString(array).then(val=>{ that.encodeToString(array, util.Type.MIME).then(val=>{
console.log(val) // 根据开发者需求进行添加。
}) })
``` ```
### decode<sup>9+</sup> ### decode<sup>9+</sup>
decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt; decode(src: Uint8Array | string, options?: Type): Promise&lt;Uint8Array&gt;
通过输入参数异步解码后输出对应文本。 通过输入参数异步解码后输出对应文本。
...@@ -2214,6 +2217,7 @@ decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt; ...@@ -2214,6 +2217,7 @@ decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------------ | ---- | --------------------------------- | | ------ | ------------------------------ | ---- | --------------------------------- |
| src | Uint8Array&nbsp;\|&nbsp;string | 是 | 异步解码输入Uint8数组或者字符串。 | | src | Uint8Array&nbsp;\|&nbsp;string | 是 | 异步解码输入Uint8数组或者字符串。 |
| options<sup>10+</sup> | [Type](#type10) | 否 | 从API version 10开始支持该参数,表示对应的编码格式。<br/>此参数可选,可选值为:util.Type.BASIC和util.Type.MIME,默认值为:util.Type.BASIC。<br/>- 当参数取值为util.Type.BASIC时,表示入参包含:64个可打印字符,包括大写字母A-Z、小写字母a-z、数字0-9共62个字符,再加上另外2个'+'和'/',没有回车符、换行符。<br/>- 当参数取值为util.Type.MIME时,表示入参包含:64个可打印字符,包括大写字母A-Z、小写字母a-z、数字0-9共62个字符,再加上另外2个'+'和'/',每一行不超过76个字符,而且每行以'\r\n'符结束。 |
**返回值:** **返回值:**
...@@ -2225,15 +2229,25 @@ decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt; ...@@ -2225,15 +2229,25 @@ decode(src: Uint8Array | string): Promise&lt;Uint8Array&gt;
```js ```js
let that = new util.Base64Helper(); let that = new util.Base64Helper();
let array = new Uint8Array([99,122,69,122]); let array = 'TWFuaXNkaXN0aW5ndWlzaGVkbm90b25seWJ5aGlzcmVhc29uYnV0Ynl0aGlzc2luZ3VsYXJwYXNz\r\naW9uZnJvbW90aGVyYW5pbWFsc3doaWNoaXNhbHVzdG9mdGhlbWluZGV4Y2VlZHN0aGVzaG9ydHZl\r\naGVtZW5jZW9mYW55Y2FybmFscGxlYXN1cmU=\r\n';
let rarray = new Uint8Array([115,49,51]); that.decode(array, util.Type.MIME).then(val=>{
that.decode(array).then(val=>{ // 根据开发者需求进行添加。
for (var i = 0; i < rarray.length; i++) {
console.log(val[i].toString())
}
}) })
``` ```
## Type<sup>10+</sup>
Base64编码格式枚举。
**系统能力:** SystemCapability.Utils.Lang
| 名称 | 值 | 说明 |
| -------- | ------------------------ | ---------------- |
| BASIC | 0 | 表示BASIC编码格式 |
| MIME | 1 | 表示MIME编码格式。 |
## types<sup>8+</sup> ## types<sup>8+</sup>
types为不同类型的内置对象提供类型检查,可以避免由于类型错误导致的异常或崩溃。该模块包含了多个工具函数,用于判断JS对象是否属于各种类型例如:ArrayBuffer、Map、Set等。 types为不同类型的内置对象提供类型检查,可以避免由于类型错误导致的异常或崩溃。该模块包含了多个工具函数,用于判断JS对象是否属于各种类型例如:ArrayBuffer、Map、Set等。
......
...@@ -9,7 +9,7 @@ vibrator模块提供控制马达振动启、停的能力。 ...@@ -9,7 +9,7 @@ vibrator模块提供控制马达振动启、停的能力。
## 导入模块 ## 导入模块
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
``` ```
...@@ -41,8 +41,9 @@ startVibration(effect: VibrateEffect, attribute: VibrateAttribute, callback: Asy ...@@ -41,8 +41,9 @@ startVibration(effect: VibrateEffect, attribute: VibrateAttribute, callback: Asy
示例: 示例:
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
try { try {
vibrator.startVibration({ vibrator.startVibration({
type: 'time', type: 'time',
...@@ -52,13 +53,13 @@ try { ...@@ -52,13 +53,13 @@ try {
usage: 'alarm' usage: 'alarm'
}, (error) => { }, (error) => {
if (error) { if (error) {
console.error('Vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message); console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
return; return;
} }
console.log('Callback returned to indicate a successful vibration.'); console.info('Succeed in starting vibration');
}); });
} catch (err) { } catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`An unexpected error occurred. Code: ${err.code}, message: ${err.message}`);
} }
``` ```
...@@ -95,8 +96,9 @@ startVibration(effect: VibrateEffect, attribute: VibrateAttribute): Promise&lt;v ...@@ -95,8 +96,9 @@ startVibration(effect: VibrateEffect, attribute: VibrateAttribute): Promise&lt;v
**示例:** **示例:**
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
try { try {
vibrator.startVibration({ vibrator.startVibration({
type: 'time', type: 'time',
...@@ -105,14 +107,14 @@ try { ...@@ -105,14 +107,14 @@ try {
id: 0, id: 0,
usage: 'alarm' usage: 'alarm'
}).then(() => { }).then(() => {
console.log('Promise returned to indicate a successful vibration'); console.info('Succeed in starting vibration');
}, (error) => { }, (error) => {
console.error('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
}); });
} catch (err) { } catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`An unexpected error occurred. Code: ${err.code}, message: ${err.message}`);
} }
``` ```
## vibrator.stopVibration<sup>9+</sup> ## vibrator.stopVibration<sup>9+</sup>
...@@ -133,8 +135,9 @@ stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback&lt;void&gt;): ...@@ -133,8 +135,9 @@ stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback&lt;void&gt;):
**示例:** **示例:**
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
try { try {
// 按照固定时长振动 // 按照固定时长振动
vibrator.startVibration({ vibrator.startVibration({
...@@ -145,28 +148,28 @@ try { ...@@ -145,28 +148,28 @@ try {
usage: 'alarm' usage: 'alarm'
}, (error) => { }, (error) => {
if (error) { if (error) {
console.error('Vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message); console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
return; return;
} }
console.log('Callback returned to indicate a successful vibration.'); console.info('Succeed in starting vibration');
}); });
} catch (err) { } catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`An unexpected error occurred. Code: ${err.code}, message: ${err.message}`);
} }
try { try {
// 按照VIBRATOR_STOP_MODE_TIME模式停止振动 // 按照VIBRATOR_STOP_MODE_TIME模式停止振动
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) { vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) {
if (error) { if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
return; return;
} }
console.log('Callback returned to indicate successful.'); console.info('Succeed in stopping vibration');
}) })
} catch (err) { } catch (err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`An unexpected error occurred. Code: ${err.code}, message: ${err.message}`);
} }
``` ```
## vibrator.stopVibration<sup>9+</sup> ## vibrator.stopVibration<sup>9+</sup>
...@@ -192,8 +195,9 @@ stopVibration(stopMode: VibratorStopMode): Promise&lt;void&gt; ...@@ -192,8 +195,9 @@ stopVibration(stopMode: VibratorStopMode): Promise&lt;void&gt;
**示例:** **示例:**
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
try { try {
// 按照固定时长振动 // 按照固定时长振动
vibrator.startVibration({ vibrator.startVibration({
...@@ -203,25 +207,25 @@ try { ...@@ -203,25 +207,25 @@ try {
id: 0, id: 0,
usage: 'alarm' usage: 'alarm'
}).then(() => { }).then(() => {
console.log('Promise returned to indicate a successful vibration'); console.info('Succeed in starting vibration');
}, (error) => { }, (error) => {
console.error('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
}); });
} catch (err) { } catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`An unexpected error occurred. Code: ${err.code}, message: ${err.message}`);
} }
try { try {
// 按照VIBRATOR_STOP_MODE_TIME模式停止振动 // 按照VIBRATOR_STOP_MODE_TIME模式停止振动
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(() => { vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(() => {
console.log('Promise returned to indicate a successful vibration.'); console.info('Succeed in stopping vibration');
}, (error) => { }, (error) => {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
}); });
} catch (err) { } catch (err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message); console.error(`An unexpected error occurred. Code: ${err.code}, message: ${err.message}`);
} }
``` ```
## vibrator.stopVibration<sup>10+</sup> ## vibrator.stopVibration<sup>10+</sup>
...@@ -241,8 +245,9 @@ stopVibration(callback: AsyncCallback&lt;void&gt;): void ...@@ -241,8 +245,9 @@ stopVibration(callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
try { try {
// 按照固定时长振动 // 按照固定时长振动
vibrator.startVibration({ vibrator.startVibration({
...@@ -253,28 +258,28 @@ try { ...@@ -253,28 +258,28 @@ try {
usage: 'alarm' usage: 'alarm'
}, (error) => { }, (error) => {
if (error) { if (error) {
console.error('Vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message); console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
return; return;
} }
console.log('Callback returned to indicate a successful vibration.'); console.info('Succeed in starting vibration');
}); });
} catch (error) { } catch (error) {
console.error('errCode: ' + error.code + ' ,msg: ' + error.message); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
} }
try { try {
// 停止所有模式的马达振动 // 停止所有模式的马达振动
vibrator.stopVibration(function (error) { vibrator.stopVibration(function (error) {
if (error) { if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
return; return;
} }
console.log('Callback returned to indicate successful.'); console.info('Succeed in stopping vibration');
}) })
} catch (error) { } catch (error) {
console.info('errCode: ' + error.code + ' ,msg: ' + error.message); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
## vibrator.stopVibration<sup>10+</sup> ## vibrator.stopVibration<sup>10+</sup>
...@@ -294,8 +299,9 @@ stopVibration(): Promise&lt;void&gt; ...@@ -294,8 +299,9 @@ stopVibration(): Promise&lt;void&gt;
**示例:** **示例:**
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
try { try {
// 按照固定时长振动 // 按照固定时长振动
vibrator.startVibration({ vibrator.startVibration({
...@@ -305,25 +311,25 @@ try { ...@@ -305,25 +311,25 @@ try {
id: 0, id: 0,
usage: 'alarm' usage: 'alarm'
}).then(() => { }).then(() => {
console.log('Promise returned to indicate a successful vibration'); console.info('Succeed in starting vibration');
}, (error) => { }, (error) => {
console.error('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
}); });
} catch (error) { } catch (error) {
console.error('errCode: ' + error.code + ' ,msg: ' + error.message); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
} }
try { try {
// 停止所有模式的马达振动 // 停止所有模式的马达振动
vibrator.stopVibration().then(() => { vibrator.stopVibration().then(() => {
console.log('Promise returned to indicate a successful vibration.'); console.info('Succeed in stopping vibration');
}, (error) => { }, (error) => {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
}); });
} catch (error) { } catch (error) {
console.info('errCode: ' + error.code + ' ,msg: ' + error.message); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
## vibrator.isSupportEffect<sup>10+</sup> ## vibrator.isSupportEffect<sup>10+</sup>
...@@ -342,16 +348,17 @@ isSupportEffect(effectId: string, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -342,16 +348,17 @@ isSupportEffect(effectId: string, callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
try { try {
// 查询是否支持'haptic.clock.timer' // 查询是否支持'haptic.clock.timer'
vibrator.isSupportEffect('haptic.clock.timer', function (err, state) { vibrator.isSupportEffect('haptic.clock.timer', function (err, state) {
if (err) { if (err) {
console.error('isSupportEffect failed, error:' + JSON.stringify(err)); console.error(`Failed to query effect. Code: ${err.code}, message: ${err.message}`);
return; return;
} }
console.log('The effectId is ' + (state ? 'supported' : 'unsupported')); console.info('Succeed in querying effect');
if (state) { if (state) {
try { try {
vibrator.startVibration({ // 使用startVibration需要添加ohos.permission.VIBRATE权限 vibrator.startVibration({ // 使用startVibration需要添加ohos.permission.VIBRATE权限
...@@ -361,21 +368,21 @@ try { ...@@ -361,21 +368,21 @@ try {
}, { }, {
usage: 'unknown' usage: 'unknown'
}, (error) => { }, (error) => {
if(error) { if (error) {
console.error('haptic.clock.timer vibrator error:' + JSON.stringify(error)); console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
} else { } else {
console.log('haptic.clock.timer vibrator success'); console.info('Succeed in starting vibration');
} }
}); });
} catch (error) { } catch (error) {
console.error('Exception in, error:' + JSON.stringify(error)); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
} }
} }
}) })
} catch (error) { } catch (error) {
console.error('Exception in, error:' + JSON.stringify(error)); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
## vibrator.isSupportEffect<sup>10+</sup> ## vibrator.isSupportEffect<sup>10+</sup>
...@@ -399,12 +406,13 @@ isSupportEffect(effectId: string): Promise&lt;boolean&gt; ...@@ -399,12 +406,13 @@ isSupportEffect(effectId: string): Promise&lt;boolean&gt;
**示例:** **示例:**
```js ```ts
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
try { try {
// 查询是否支持'haptic.clock.timer' // 查询是否支持'haptic.clock.timer'
vibrator.isSupportEffect('haptic.clock.timer').then((state) => { vibrator.isSupportEffect('haptic.clock.timer').then((state) => {
console.log('The effectId is ' + (state ? 'supported' : 'unsupported')); console.info(`The query result is ${state}`);
if (state) { if (state) {
try { try {
vibrator.startVibration({ vibrator.startVibration({
...@@ -413,22 +421,22 @@ try { ...@@ -413,22 +421,22 @@ try {
count: 1, count: 1,
}, { }, {
usage: 'unknown' usage: 'unknown'
}).then(()=>{ }).then(() => {
console.log('Promise returned to indicate a successful vibration'); console.info('Succeed in starting vibration');
}).catch((error)=>{ }).catch((error) => {
console.error('Promise returned to indicate a failed vibration:' + JSON.stringify(error)); console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
}); });
} catch (error) { } catch (error) {
console.error('Exception in, error:' + JSON.stringify(error)); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
} }
} }
}, (error) => { }, (error) => {
console.error('isSupportEffect failed, error:' + JSON.stringify(error)); console.error(`Failed to query effect. Code: ${error.code}, message: ${error.message}`);
}) })
} catch (error) { } catch (error) {
console.error('Exception in, error:' + JSON.stringify(error)); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
## EffectId ## EffectId
...@@ -489,7 +497,7 @@ try { ...@@ -489,7 +497,7 @@ try {
## VibrateFromFile<sup>10+</sup> ## VibrateFromFile<sup>10+</sup>
自定义振动类型,仅部分设备支持。 自定义振动类型,仅部分设备支持,当设备不支持此振动类型时,返回[设备不支持错误码](../errorcodes/errorcode-universal.md)
**系统能力**:SystemCapability.Sensors.MiscDevice **系统能力**:SystemCapability.Sensors.MiscDevice
...@@ -565,13 +573,13 @@ vibrate(duration: number): Promise&lt;void&gt; ...@@ -565,13 +573,13 @@ vibrate(duration: number): Promise&lt;void&gt;
**示例:** **示例:**
```js ```ts
vibrator.vibrate(1000).then(() => { vibrator.vibrate(1000).then(() => {
console.log('Promise returned to indicate a successful vibration.'); console.info('Succeed in vibrating');
}, (error) => { }, (error) => {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to vibrate. Code: ${error.code}, message: ${error.message}`);
}); });
``` ```
## vibrator.vibrate<sup>(deprecated)</sup> ## vibrator.vibrate<sup>(deprecated)</sup>
...@@ -594,15 +602,15 @@ vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void ...@@ -594,15 +602,15 @@ vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```ts
vibrator.vibrate(1000, function (error) { vibrator.vibrate(1000, function (error) {
if (error) { if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to vibrate. Code: ${error.code}, message: ${error.message}`);
} else { } else {
console.log('Callback returned to indicate a successful vibration.'); console.info('Succeed in vibrating');
} }
}) })
``` ```
## vibrator.vibrate<sup>(deprecated)</sup> ## vibrator.vibrate<sup>(deprecated)</sup>
...@@ -631,13 +639,13 @@ vibrate(effectId: EffectId): Promise&lt;void&gt; ...@@ -631,13 +639,13 @@ vibrate(effectId: EffectId): Promise&lt;void&gt;
**示例:** **示例:**
```js ```ts
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(() => { vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(() => {
console.log('Promise returned to indicate a successful vibration.'); console.info('Succeed in vibrating');
}, (error) => { }, (error) => {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to vibrate. Code: ${error.code}, message: ${error.message}`);
}); });
``` ```
## vibrator.vibrate<sup>(deprecated)</sup> ## vibrator.vibrate<sup>(deprecated)</sup>
...@@ -661,15 +669,15 @@ vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void ...@@ -661,15 +669,15 @@ vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```ts
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function (error) { vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function (error) {
if (error) { if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to vibrate. Code: ${error.code}, message: ${error.message}`);
} else { } else {
console.log('Callback returned to indicate a successful vibration.'); console.info('Succeed in vibrating');
} }
}) })
``` ```
## vibrator.stop<sup>(deprecated)</sup> ## vibrator.stop<sup>(deprecated)</sup>
...@@ -697,22 +705,22 @@ stop(stopMode: VibratorStopMode): Promise&lt;void&gt; ...@@ -697,22 +705,22 @@ stop(stopMode: VibratorStopMode): Promise&lt;void&gt;
**示例:** **示例:**
```js ```ts
// 按照effectId类型启动振动 // 按照effectId类型启动振动
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function (error) { vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function (error) {
if (error) { if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to vibrate. Code: ${error.code}, message: ${error.message}`);
} else { } else {
console.log('Callback returned to indicate a successful vibration.'); console.info('Succeed in vibrating');
} }
}) })
// 使用VIBRATOR_STOP_MODE_PRESET模式停止振动 // 使用VIBRATOR_STOP_MODE_PRESET模式停止振动
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(() => { vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(() => {
console.log('Promise returned to indicate a successful vibration.'); console.info('Succeed in stopping');
}, (error) => { }, (error) => {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to stop. Code: ${error.code}, message: ${error.message}`);
}); });
``` ```
## vibrator.stop<sup>(deprecated)</sup> ## vibrator.stop<sup>(deprecated)</sup>
...@@ -736,21 +744,21 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void ...@@ -736,21 +744,21 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```ts
// 按照effectId类型启动振动 // 按照effectId类型启动振动
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function (error) { vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function (error) {
if (error) { if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to vibrate. Code: ${error.code}, message: ${error.message}`);
} else { } else {
console.log('Callback returned to indicate a successful vibration.'); console.info('Succeed in vibrating');
} }
}) })
// 使用VIBRATOR_STOP_MODE_PRESET模式停止振动 // 使用VIBRATOR_STOP_MODE_PRESET模式停止振动
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function (error) { vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function (error) {
if (error) { if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.error(`Failed to stop. Code: ${error.code}, message: ${error.message}`);
} else { } else {
console.log('Callback returned to indicate successful.'); onsole.info('Succeed in stopping');
} }
}) })
``` ```
...@@ -3414,6 +3414,41 @@ onRequestSelected(callback: () => void) ...@@ -3414,6 +3414,41 @@ onRequestSelected(callback: () => void)
} }
``` ```
### onOverScroll<sup>10+</sup>
onOverScroll(callback: (event: {xOffset: number, yOffset: number}) => void)
通知网页过滚动偏移量。
**参数:**
| 参数名 | 参数类型 | 参数描述 |
| ------- | ------ | ------------ |
| xOffset | number | 以网页最左端为基准,水平过滚动偏移量。 |
| yOffset | number | 以网页最上端为基准,竖直过滚动偏移量。 |
**示例:**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.onOverScroll((event) => {
console.info("x = " + event.xOffset)
console.info("y = " + event.yOffset)
})
}
}
}
```
## ConsoleMessage ## ConsoleMessage
Web组件获取控制台信息对象。示例代码参考[onConsole事件](#onconsole) Web组件获取控制台信息对象。示例代码参考[onConsole事件](#onconsole)
......
...@@ -82,7 +82,7 @@ SubTabBarStyle的静态构造函数。 ...@@ -82,7 +82,7 @@ SubTabBarStyle的静态构造函数。
| -------- | -------- | -------- | -------------------------------- | | -------- | -------- | -------- | -------------------------------- |
| color | [ResourceColor](ts-types.md#resourcecolor) | 否 | 下划线的颜色和背板颜色。<br/>默认值:#FF007DFF | | color | [ResourceColor](ts-types.md#resourcecolor) | 否 | 下划线的颜色和背板颜色。<br/>默认值:#FF007DFF |
| height | [Length](ts-types.md#length) | 否 | 下划线的高度(不支持百分比设置)。<br/>默认值:2.0<br/>单位:vp | | height | [Length](ts-types.md#length) | 否 | 下划线的高度(不支持百分比设置)。<br/>默认值:2.0<br/>单位:vp |
| width | [Length](ts-types.md#length) | 否 | 下划线的宽度(不支持百分比设置)。<br/>默认值:0.0<br/>单位:vp | | width | [Length](ts-types.md#length) | 否 | 下划线的宽度(不支持百分比设置)。<br/>默认值:0.0<br/>单位:vp <br/>**说明:** <br/>宽度设置为0时,按页签文本宽度显示。|
| borderRadius | [Length](ts-types.md#length) | 否 | 下划线的圆角半径(不支持百分比设置)。<br/>默认值:0.0<br/>单位:vp | | borderRadius | [Length](ts-types.md#length) | 否 | 下划线的圆角半径(不支持百分比设置)。<br/>默认值:0.0<br/>单位:vp |
| marginTop | [Length](ts-types.md#length) | 否 | 下划线与文字的间距(不支持百分比设置)。<br/>默认值:8.0<br/>单位:vp | | marginTop | [Length](ts-types.md#length) | 否 | 下划线与文字的间距(不支持百分比设置)。<br/>默认值:8.0<br/>单位:vp |
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
- [Memory](memory.md) - [Memory](memory.md)
- [UsbDdk](_usb_ddk.md) - [UsbDdk](_usb_ddk.md)
- [Hitrace](_hitrace.md) - [Hitrace](_hitrace.md)
- [Vulkan](_vulkan.md)
- 头文件 - 头文件
- [drawing_bitmap.h](drawing__bitmap_8h.md) - [drawing_bitmap.h](drawing__bitmap_8h.md)
- [drawing_brush.h](drawing__brush_8h.md) - [drawing_brush.h](drawing__brush_8h.md)
...@@ -92,6 +93,7 @@ ...@@ -92,6 +93,7 @@
- [usb_ddk_api.h](usb__ddk__api_8h.md) - [usb_ddk_api.h](usb__ddk__api_8h.md)
- [usb_ddk_types.h](usb__ddk__types_8h.md) - [usb_ddk_types.h](usb__ddk__types_8h.md)
- [trace.h](trace_8h.md) - [trace.h](trace_8h.md)
- [vulkan_ohos.h](vulkan__ohos_8h.md)
- 结构体 - 结构体
- [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) - [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md)
- [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) - [OH_NativeBuffer_Config](_o_h___native_buffer___config.md)
...@@ -148,3 +150,10 @@ ...@@ -148,3 +150,10 @@
- [UsbEndpointDescriptor](_usb_endpoint_descriptor.md) - [UsbEndpointDescriptor](_usb_endpoint_descriptor.md)
- [UsbInterfaceDescriptor](_usb_interface_descriptor.md) - [UsbInterfaceDescriptor](_usb_interface_descriptor.md)
- [UsbRequestPipe](_usb_request_pipe.md) - [UsbRequestPipe](_usb_request_pipe.md)
- [VkExternalFormatOHOS](_vk_external_format_o_h_o_s.md)
- [VkImportNativeBufferInfoOHOS](_vk_import_native_buffer_info_o_h_o_s.md)
- [VkMemoryGetNativeBufferInfoOHOS](_vk_memory_get_native_buffer_info_o_h_o_s.md)
- [VkNativeBufferFormatPropertiesOHOS](_vk_native_buffer_format_properties_o_h_o_s.md)
- [VkNativeBufferPropertiesOHOS](_vk_native_buffer_properties_o_h_o_s.md)
- [VkNativeBufferUsageOHOS](_vk_native_buffer_usage_o_h_o_s.md)
- [VkSurfaceCreateInfoOHOS](_vk_surface_create_info_o_h_o_s.md)
# VkExternalFormatOHOS
## 概述
表示外部定义的格式标识符。
**起始版本:**
10
**相关模块:**
[Vulkan](_vulkan.md)
## 汇总
### 成员变量
| 名称 | 描述 |
| -------- | -------- |
| [sType](_vulkan.md#stype-77) | 结构体类型。 |
| [pNext](_vulkan.md#pnext-77) | 下一级结构体指针。 |
| [externalFormat](_vulkan.md#externalformat-22) | 外部定义的格式标识符。 |
# VkImportNativeBufferInfoOHOS
## 概述
包含了OH_NativeBuffer结构体的指针。
**起始版本:**
10
**相关模块:**
[Vulkan](_vulkan.md)
## 汇总
### 成员变量
| 名称 | 描述 |
| -------- | -------- |
| [sType](_vulkan.md#stype-57) | 结构体类型。 |
| [pNext](_vulkan.md#pnext-57) | 下一级结构体指针。 |
| [buffer](_vulkan.md#buffer) | OH_NativeBuffer结构体的指针。 |
# VkMemoryGetNativeBufferInfoOHOS
## 概述
用于从Vulkan内存中获取OH_NativeBuffer。
**起始版本:**
10
**相关模块:**
[Vulkan](_vulkan.md)
## 汇总
### 成员变量
| 名称 | 描述 |
| -------- | -------- |
| [sType](_vulkan.md#stype-67) | 结构体类型。 |
| [pNext](_vulkan.md#pnext-67) | 下一级结构体指针。 |
| [memory](_vulkan.md#memory) | VkDeviceMemory对象。 |
# VkNativeBufferFormatPropertiesOHOS
## 概述
包含了NaitveBuffer的一些格式属性。
**起始版本:**
10
**相关模块:**
[Vulkan](_vulkan.md)
## 汇总
### 成员变量
| 名称 | 描述 |
| -------- | -------- |
| [sType](_vulkan.md#stype-47) | 结构体类型。 |
| [pNext](_vulkan.md#pnext-47) | 下一级结构体指针。 |
| [format](_vulkan.md#format) | 格式说明。 |
| [externalFormat](_vulkan.md#externalformat-12) | 外部定义的格式标识符。 |
| [formatFeatures](_vulkan.md#formatfeatures) | 描述了与externalFormat对应的能力。 |
| [samplerYcbcrConversionComponents](_vulkan.md#samplerycbcrconversioncomponents) | 表示一组VkComponentSwizzle。 |
| [suggestedYcbcrModel](_vulkan.md#suggestedycbcrmodel) | 色彩模型。 |
| [suggestedYcbcrRange](_vulkan.md#suggestedycbcrrange) | 色彩数值范围。 |
| [suggestedXChromaOffset](_vulkan.md#suggestedxchromaoffset) | X色度偏移。 |
| [suggestedYChromaOffset](_vulkan.md#suggestedychromaoffset) | Y色度偏移。 |
# VkNativeBufferPropertiesOHOS
## 概述
包含了NaitveBuffer的属性。
**起始版本:**
10
**相关模块:**
[Vulkan](_vulkan.md)
## 汇总
### 成员变量
| 名称 | 描述 |
| -------- | -------- |
| [sType](_vulkan.md#stype-37) | 结构体类型。 |
| [pNext](_vulkan.md#pnext-37) | 下一级结构体指针 |
| [allocationSize](_vulkan.md#allocationsize) | 占用的内存大小。 |
| [memoryTypeBits](_vulkan.md#memorytypebits) | 内存类型。 |
# VkNativeBufferUsageOHOS
## 概述
提供OpenHarmony NativeBuffer用途的说明。
**起始版本:**
10
**相关模块:**
[Vulkan](_vulkan.md)
## 汇总
### 成员变量
| 名称 | 描述 |
| -------- | -------- |
| [sType](_vulkan.md#stype-27) | 结构体类型。 |
| [pNext](_vulkan.md#pnext-27) | 下一级结构体指针。 |
| [OHOSNativeBufferUsage](_vulkan.md#ohosnativebufferusage) | NativeBuffer的用途说明。 |
# VkSurfaceCreateInfoOHOS
## 概述
包含创建Vulkan Surface时必要的参数。
**起始版本:**
10
**相关模块:**
[Vulkan](_vulkan.md)
## 汇总
### 成员变量
| 名称 | 描述 |
| -------- | -------- |
| [sType](_vulkan.md#stype-17) | 结构体类型。 |
| [pNext](_vulkan.md#pnext-17) | 下一级结构体指针。 |
| [flags](_vulkan.md#flags) | 预留的标志类型参数。 |
| [window](_vulkan.md#window) | OHNativeWindow指针。 |
# Vulkan
## 概述
提供OpenHarmony平台扩展的Vulkan能力,扩展了使用OHNativeWindow创建Vulkan Surface的能力,以及获取OH_NativeBuffer和OH_NativeBuffer属性的能力。
\@syscap SystemCapability.Graphic.Vulkan
**起始版本:**
10
## 汇总
### 文件
| 名称 | 描述 |
| -------- | -------- |
| [vulkan_ohos.h](vulkan__ohos_8h.md) | 定义了OpenHarmony平台扩展的Vulkan接口。<br/>引用文件:&lt;vulkan/vulkan.h&gt;。 |
### 结构体
| 名称 | 描述 |
| -------- | -------- |
| [VkSurfaceCreateInfoOHOS](_vk_surface_create_info_o_h_o_s.md) | 包含创建Vulkan Surface时必要的参数。 |
| [VkNativeBufferUsageOHOS](_vk_native_buffer_usage_o_h_o_s.md) | 提供OpenHarmony NativeBuffer用途的说明。 |
| [VkNativeBufferPropertiesOHOS](_vk_native_buffer_properties_o_h_o_s.md) | 包含了NaitveBuffer的属性。 |
| [VkNativeBufferFormatPropertiesOHOS](_vk_native_buffer_format_properties_o_h_o_s.md) | 包含了NaitveBuffer的一些格式属性。 |
| [VkImportNativeBufferInfoOHOS](_vk_import_native_buffer_info_o_h_o_s.md) | 包含了OH_NativeBuffer结构体的指针。 |
| [VkMemoryGetNativeBufferInfoOHOS](_vk_memory_get_native_buffer_info_o_h_o_s.md) | 用于从Vulkan内存中获取OH_NativeBuffer。 |
| [VkExternalFormatOHOS](_vk_external_format_o_h_o_s.md) | 表示外部定义的格式标识符。 |
### 宏定义
| 名称 | 描述 |
| -------- | -------- |
| [VK_OHOS_surface](#vk_ohos_surface) 1 | OpenHarmony平台Surface扩展宏定义。 |
| [VK_OHOS_SURFACE_SPEC_VERSION](#vk_ohos_surface_spec_version) 1 | OpenHarmony平台Surface扩展版本号。 |
| [VK_OHOS_SURFACE_EXTENSION_NAME](#vk_ohos_surface_extension_name) "VK_OHOS_surface" | OpenHarmony平台Surface扩展名。 |
| [VK_OHOS_external_memory](#vk_ohos_external_memory) 1 | OpenHarmony平台external_memory扩展宏定义。 |
| [VK_OHOS_EXTERNAL_MEMORY_SPEC_VERSION](#vk_ohos_external_memory_spec_version) 1 | OpenHarmony平台external_memory扩展版本号。 |
| [VK_OHOS_EXTERNAL_MEMORY_EXTENSION_NAME](#vk_ohos_external_memory_extension_name) "VK_OHOS_external_memory" | OpenHarmony平台external_memory扩展名。 |
### 类型定义
| 名称 | 描述 |
| -------- | -------- |
| [OHNativeWindow](#ohnativewindow) | OH本地窗口。 |
| [VkSurfaceCreateFlagsOHOS](#vksurfacecreateflagsohos) | 用于Vulkan Surface创建时使用到的VkFlags类型位掩码,预留的标志类型。 |
| [VkSurfaceCreateInfoOHOS](#vksurfacecreateinfoohos) | 包含创建Vulkan Surface时必要的参数。 |
| VkResult ([VKAPI_PTR *PFN_vkCreateSurfaceOHOS](#pfn_vkcreatesurfaceohos)) (VkInstance instance, const [VkSurfaceCreateInfoOHOS](_vk_surface_create_info_o_h_o_s.md) \*pCreateInfo, const VkAllocationCallbacks \*pAllocator, VkSurfaceKHR \*pSurface) | 创建Vulkan Surface的函数指针定义。 |
| [VkNativeBufferUsageOHOS](#vknativebufferusageohos) | 提供OpenHarmony NativeBuffer用途的说明。 |
| [VkNativeBufferPropertiesOHOS](#vknativebufferpropertiesohos) | 包含了NaitveBuffer的属性。 |
| [VkNativeBufferFormatPropertiesOHOS](#vknativebufferformatpropertiesohos) | 包含了NaitveBuffer的一些格式属性。 |
| [VkImportNativeBufferInfoOHOS](#vkimportnativebufferinfoohos) | 包含了OH_NativeBuffer结构体的指针。 |
| [VkMemoryGetNativeBufferInfoOHOS](#vkmemorygetnativebufferinfoohos) | 用于从Vulkan内存中获取OH_NativeBuffer。 |
| [VkExternalFormatOHOS](#vkexternalformatohos) | 表示外部定义的格式标识符。 |
| VkResult ([VKAPI_PTR *PFN_vkGetNativeBufferPropertiesOHOS](#pfn_vkgetnativebufferpropertiesohos)) (VkDevice device, const struct OH_NativeBuffer \*buffer, [VkNativeBufferPropertiesOHOS](_vk_native_buffer_properties_o_h_o_s.md) \*pProperties) | 获取OH_NativeBuffer属性的函数指针定义。 |
| VkResult ([VKAPI_PTR *PFN_vkGetMemoryNativeBufferOHOS](#pfn_vkgetmemorynativebufferohos)) (VkDevice device, const [VkMemoryGetNativeBufferInfoOHOS](_vk_memory_get_native_buffer_info_o_h_o_s.md) \*pInfo, struct OH_NativeBuffer \*\*pBuffer) | 获取OH_NativeBuffer的函数指针定义。 |
### 函数
| 名称 | 描述 |
| -------- | -------- |
| [vkCreateSurfaceOHOS](#vkcreatesurfaceohos) (VkInstance instance, const VkSurfaceCreateInfoOHOS \*pCreateInfo, const VkAllocationCallbacks \*pAllocator, VkSurfaceKHR \*pSurface) | 创建Vulkan Surface。 |
| [vkGetNativeBufferPropertiesOHOS](#vkgetnativebufferpropertiesohos) (VkDevice device, const struct OH_NativeBuffer \*buffer, VkNativeBufferPropertiesOHOS \*pProperties) | 获取OH_NativeBuffer属性。 |
| [vkGetMemoryNativeBufferOHOS](#vkgetmemorynativebufferohos) (VkDevice device, const VkMemoryGetNativeBufferInfoOHOS \*pInfo, struct OH_NativeBuffer \*\*pBuffer) | 获取OH_NativeBuffer。 |
### 变量
| 名称 | 描述 |
| -------- | -------- |
| [VkSurfaceCreateInfoOHOS::sType](#stype-17) | 结构体类型。 |
| [VkSurfaceCreateInfoOHOS::pNext](#pnext-17) | 下一级结构体指针。 |
| [VkSurfaceCreateInfoOHOS::flags](#flags) | 预留的标志类型参数。 |
| [VkSurfaceCreateInfoOHOS::window](#window) | OHNativeWindow指针。 |
| [VkNativeBufferUsageOHOS::sType](#stype-27) | 结构体类型。 |
| [VkNativeBufferUsageOHOS::pNext](#pnext-27) | 下一级结构体指针。 |
| [VkNativeBufferUsageOHOS::OHOSNativeBufferUsage](#ohosnativebufferusage) | NativeBuffer的用途说明。 |
| [VkNativeBufferPropertiesOHOS::sType](#stype-37) | 结构体类型。 |
| [VkNativeBufferPropertiesOHOS::pNext](#pnext-37) | 下一级结构体指针。 |
| [VkNativeBufferPropertiesOHOS::allocationSize](#allocationsize) | 占用的内存大小。 |
| [VkNativeBufferPropertiesOHOS::memoryTypeBits](#memorytypebits) | 内存类型。 |
| [VkNativeBufferFormatPropertiesOHOS::sType](#stype-47) | 结构体类型。 |
| [VkNativeBufferFormatPropertiesOHOS::pNext](#pnext-47) | 下一级结构体指针。 |
| [VkNativeBufferFormatPropertiesOHOS::format](#format) | 格式说明。 |
| [VkNativeBufferFormatPropertiesOHOS::externalFormat](#externalformat-12) | 外部定义的格式标识符。 |
| [VkNativeBufferFormatPropertiesOHOS::formatFeatures](#formatfeatures) | 描述了与externalFormat对应的能力。 |
| [VkNativeBufferFormatPropertiesOHOS::samplerYcbcrConversionComponents](#samplerycbcrconversioncomponents) | 表示一组VkComponentSwizzle。 |
| [VkNativeBufferFormatPropertiesOHOS::suggestedYcbcrModel](#suggestedycbcrmodel) | 色彩模型。 |
| [VkNativeBufferFormatPropertiesOHOS::suggestedYcbcrRange](#suggestedycbcrrange) | 色彩数值范围。 |
| [VkNativeBufferFormatPropertiesOHOS::suggestedXChromaOffset](#suggestedxchromaoffset) | X色度偏移。 |
| [VkNativeBufferFormatPropertiesOHOS::suggestedYChromaOffset](#suggestedychromaoffset) | Y色度偏移。 |
| [VkImportNativeBufferInfoOHOS::sType](#stype-57) | 结构体类型。 |
| [VkImportNativeBufferInfoOHOS::pNext](#pnext-57) | 下一级结构体指针。 |
| [VkImportNativeBufferInfoOHOS::buffer](#buffer) | OH_NativeBuffer结构体的指针。 |
| [VkMemoryGetNativeBufferInfoOHOS::sType](#stype-67) | 结构体类型。 |
| [VkMemoryGetNativeBufferInfoOHOS::pNext](#pnext-67) | 下一级结构体指针。 |
| [VkMemoryGetNativeBufferInfoOHOS::memory](#memory) | VkDeviceMemory对象。 |
| [VkExternalFormatOHOS::sType](#stype-77) | 结构体类型。 |
| [VkExternalFormatOHOS::pNext](#pnext-77) | 下一级结构体指针。 |
| [VkExternalFormatOHOS::externalFormat](#externalformat-22) | 外部定义的格式标识符。 |
## 宏定义说明
### VK_OHOS_external_memory
```
#define VK_OHOS_external_memory 1
```
**描述:**
OpenHarmony平台external_memory扩展宏定义。
### VK_OHOS_EXTERNAL_MEMORY_EXTENSION_NAME
```
#define VK_OHOS_EXTERNAL_MEMORY_EXTENSION_NAME "VK_OHOS_external_memory"
```
**描述:**
OpenHarmony平台external_memory扩展名。
### VK_OHOS_EXTERNAL_MEMORY_SPEC_VERSION
```
#define VK_OHOS_EXTERNAL_MEMORY_SPEC_VERSION 1
```
**描述:**
OpenHarmony平台external_memory扩展版本号。
### VK_OHOS_surface
```
#define VK_OHOS_surface 1
```
**描述:**
OpenHarmony平台Surface扩展宏定义。
### VK_OHOS_SURFACE_EXTENSION_NAME
```
#define VK_OHOS_SURFACE_EXTENSION_NAME "VK_OHOS_surface"
```
**描述:**
OpenHarmony平台Surface扩展名。
### VK_OHOS_SURFACE_SPEC_VERSION
```
#define VK_OHOS_SURFACE_SPEC_VERSION 1
```
**描述:**
OpenHarmony平台Surface扩展版本号。
## 类型定义说明
### OHNativeWindow
```
typedef struct NativeWindow OHNativeWindow
```
**描述:**
OH本地窗口。
### PFN_vkCreateSurfaceOHOS
```
typedef VkResult(VKAPI_PTR * PFN_vkCreateSurfaceOHOS) (VkInstance instance, const VkSurfaceCreateInfoOHOS *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
```
**描述:**
创建Vulkan Surface的函数指针定义。
\@syscap SystemCapability.Graphic.Vulkan
**参数:**
| 名称 | 描述 |
| -------- | -------- |
| instance | Vulkan实例。 |
| pCreateInfo | 一个VkSurfaceCreateInfoOHOS结构体的指针,包含创建Vulkan Surface时必要的参数。 |
| pAllocator | 用户自定义内存分配的回调函数,如果不需要可以传入NULL,接口会使用默认的内存分配函数。 |
| pSurface | 出参,用于接收创建的Vulkan Surface,类型为VkSurfaceKHR。 |
**返回:**
返回一个VkResult类型的错误码,返回值为VK_SUCCESS表示执行成功。
### PFN_vkGetMemoryNativeBufferOHOS
```
typedef VkResult(VKAPI_PTR * PFN_vkGetMemoryNativeBufferOHOS) (VkDevice device, const VkMemoryGetNativeBufferInfoOHOS *pInfo, struct OH_NativeBuffer **pBuffer)
```
**描述:**
获取OH_NativeBuffer的函数指针定义。
\@syscap SystemCapability.Graphic.Vulkan
**参数:**
| 名称 | 描述 |
| -------- | -------- |
| device | VkDevice对象。 |
| pInfo | VkMemoryGetNativeBufferInfoOHOS结构体对象。 |
| pBuffer | 用于接收获取到的OH_NativeBuffer。 |
**返回:**
返回一个VkResult类型的错误码,返回值为VK_SUCCESS表示执行成功。
### PFN_vkGetNativeBufferPropertiesOHOS
```
typedef VkResult(VKAPI_PTR * PFN_vkGetNativeBufferPropertiesOHOS) (VkDevice device, const struct OH_NativeBuffer *buffer, VkNativeBufferPropertiesOHOS *pProperties)
```
**描述:**
获取OH_NativeBuffer属性的函数指针定义。
\@syscap SystemCapability.Graphic.Vulkan
**参数:**
| 名称 | 描述 |
| -------- | -------- |
| device | VkDevice对象。 |
| buffer | OH_NativeBuffer结构体指针。 |
| pProperties | 用于接收OH_NativeBuffer属性的结构体。 |
**返回:**
返回一个VkResult类型的错误码,返回值为VK_SUCCESS表示执行成功。
### VkExternalFormatOHOS
```
typedef struct VkExternalFormatOHOS VkExternalFormatOHOS
```
**描述:**
表示外部定义的格式标识符。
### VkImportNativeBufferInfoOHOS
```
typedef struct VkImportNativeBufferInfoOHOS VkImportNativeBufferInfoOHOS
```
**描述:**
包含了OH_NativeBuffer结构体的指针。
### VkMemoryGetNativeBufferInfoOHOS
```
typedef struct VkMemoryGetNativeBufferInfoOHOS VkMemoryGetNativeBufferInfoOHOS
```
**描述:**
用于从Vulkan内存中获取OH_NativeBuffer。
### VkNativeBufferFormatPropertiesOHOS
```
typedef struct VkNativeBufferFormatPropertiesOHOS VkNativeBufferFormatPropertiesOHOS
```
**描述:**
包含了NaitveBuffer的一些格式属性。
### VkNativeBufferPropertiesOHOS
```
typedef struct VkNativeBufferPropertiesOHOS VkNativeBufferPropertiesOHOS
```
**描述:**
包含了NaitveBuffer的属性。
### VkNativeBufferUsageOHOS
```
typedef struct VkNativeBufferUsageOHOS VkNativeBufferUsageOHOS
```
**描述:**
提供OpenHarmony NativeBuffer用途的说明。
### VkSurfaceCreateFlagsOHOS
```
typedef VkFlags VkSurfaceCreateFlagsOHOS
```
**描述:**
用于Vulkan Surface创建时使用到的VkFlags类型位掩码,预留的标志类型。
### VkSurfaceCreateInfoOHOS
```
typedef struct VkSurfaceCreateInfoOHOS VkSurfaceCreateInfoOHOS
```
**描述:**
包含创建Vulkan Surface时必要的参数。
## 函数说明
### vkCreateSurfaceOHOS()
```
VKAPI_ATTR VkResult VKAPI_CALL vkCreateSurfaceOHOS (VkInstance instance, const VkSurfaceCreateInfoOHOS * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkSurfaceKHR * pSurface )
```
**描述:**
创建Vulkan Surface。
\@syscap SystemCapability.Graphic.Vulkan
**参数:**
| 名称 | 描述 |
| -------- | -------- |
| instance | Vulkan实例。 |
| pCreateInfo | 一个VkSurfaceCreateInfoOHOS结构体的指针,包含创建Vulkan Surface时必要的参数。 |
| pAllocator | 用户自定义内存分配的回调函数,如果不需要可以传入NULL,接口会使用默认的内存分配函数。 |
| pSurface | 出参,用于接收创建的Vulkan Surface,类型为VkSurfaceKHR。 |
**返回:**
返回一个VkResult类型的错误码,返回值为VK_SUCCESS表示执行成功。
### vkGetMemoryNativeBufferOHOS()
```
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryNativeBufferOHOS (VkDevice device, const VkMemoryGetNativeBufferInfoOHOS * pInfo, struct OH_NativeBuffer ** pBuffer )
```
**描述:**
获取OH_NativeBuffer。
\@syscap SystemCapability.Graphic.Vulkan
**参数:**
| 名称 | 描述 |
| -------- | -------- |
| device | VkDevice对象。 |
| pInfo | VkMemoryGetNativeBufferInfoOHOS结构体对象。 |
| pBuffer | 用于接收获取到的OH_NativeBuffer。 |
**返回:**
返回一个VkResult类型的错误码,返回值为VK_SUCCESS表示执行成功。
### vkGetNativeBufferPropertiesOHOS()
```
VKAPI_ATTR VkResult VKAPI_CALL vkGetNativeBufferPropertiesOHOS (VkDevice device, const struct OH_NativeBuffer * buffer, VkNativeBufferPropertiesOHOS * pProperties )
```
**描述:**
获取OH_NativeBuffer属性。
\@syscap SystemCapability.Graphic.Vulkan
**参数:**
| 名称 | 描述 |
| -------- | -------- |
| device | VkDevice对象。 |
| buffer | OH_NativeBuffer结构体指针。 |
| pProperties | 用于接收OH_NativeBuffer属性的结构体。 |
**返回:**
返回一个VkResult类型的错误码,返回值为VK_SUCCESS表示执行成功。
## 变量说明
### allocationSize
```
VkDeviceSize VkNativeBufferPropertiesOHOS::allocationSize
```
**描述:**
占用的内存大小。
### buffer
```
struct OH_NativeBuffer* VkImportNativeBufferInfoOHOS::buffer
```
**描述:**
OH_NativeBuffer结构体的指针。
### externalFormat [1/2]
```
uint64_t VkNativeBufferFormatPropertiesOHOS::externalFormat
```
**描述:**
外部定义的格式标识符。
### externalFormat [2/2]
```
uint64_t VkExternalFormatOHOS::externalFormat
```
**描述:**
外部定义的格式标识符。
### flags
```
VkSurfaceCreateFlagsOHOS VkSurfaceCreateInfoOHOS::flags
```
**描述:**
预留的标志类型参数。
### format
```
VkFormat VkNativeBufferFormatPropertiesOHOS::format
```
**描述:**
格式说明。
### formatFeatures
```
VkFormatFeatureFlags VkNativeBufferFormatPropertiesOHOS::formatFeatures
```
**描述:**
描述了与externalFormat对应的能力。
### memory
```
VkDeviceMemory VkMemoryGetNativeBufferInfoOHOS::memory
```
**描述:**
VkDeviceMemory对象。
### memoryTypeBits
```
uint32_t VkNativeBufferPropertiesOHOS::memoryTypeBits
```
**描述:**
内存类型。
### OHOSNativeBufferUsage
```
uint64_t VkNativeBufferUsageOHOS::OHOSNativeBufferUsage
```
**描述:**
NativeBuffer的用途说明。
### pNext [1/7]
```
const void* VkSurfaceCreateInfoOHOS::pNext
```
**描述:**
下一级结构体指针。
### pNext [2/7]
```
void* VkNativeBufferUsageOHOS::pNext
```
**描述:**
下一级结构体指针。
### pNext [3/7]
```
void* VkNativeBufferPropertiesOHOS::pNext
```
**描述:**
下一级结构体指针。
### pNext [4/7]
```
void* VkNativeBufferFormatPropertiesOHOS::pNext
```
**描述:**
下一级结构体指针。
### pNext [5/7]
```
const void* VkImportNativeBufferInfoOHOS::pNext
```
**描述:**
下一级结构体指针。
### pNext [6/7]
```
const void* VkMemoryGetNativeBufferInfoOHOS::pNext
```
**描述:**
下一级结构体指针。
### pNext [7/7]
```
void* VkExternalFormatOHOS::pNext
```
**描述:**
下一级结构体指针。
### samplerYcbcrConversionComponents
```
VkComponentMapping VkNativeBufferFormatPropertiesOHOS::samplerYcbcrConversionComponents
```
**描述:**
表示一组VkComponentSwizzle。
### sType [1/7]
```
VkStructureType VkSurfaceCreateInfoOHOS::sType
```
**描述:**
结构体类型。
### sType [2/7]
```
VkStructureType VkNativeBufferUsageOHOS::sType
```
**描述:**
结构体类型。
### sType [3/7]
```
VkStructureType VkNativeBufferPropertiesOHOS::sType
```
**描述:**
结构体类型。
### sType [4/7]
```
VkStructureType VkNativeBufferFormatPropertiesOHOS::sType
```
**描述:**
结构体类型。
### sType [5/7]
```
VkStructureType VkImportNativeBufferInfoOHOS::sType
```
**描述:**
结构体类型。
### sType [6/7]
```
VkStructureType VkMemoryGetNativeBufferInfoOHOS::sType
```
**描述:**
结构体类型。
### sType [7/7]
```
VkStructureType VkExternalFormatOHOS::sType
```
**描述:**
结构体类型。
### suggestedXChromaOffset
```
VkChromaLocation VkNativeBufferFormatPropertiesOHOS::suggestedXChromaOffset
```
**描述:**
X色度偏移。
### suggestedYcbcrModel
```
VkSamplerYcbcrModelConversion VkNativeBufferFormatPropertiesOHOS::suggestedYcbcrModel
```
**描述:**
色彩模型。
### suggestedYcbcrRange
```
VkSamplerYcbcrRange VkNativeBufferFormatPropertiesOHOS::suggestedYcbcrRange
```
**描述:**
色彩数值范围。
### suggestedYChromaOffset
```
VkChromaLocation VkNativeBufferFormatPropertiesOHOS::suggestedYChromaOffset
```
**描述:**
Y色度偏移。
### window
```
OHNativeWindow* VkSurfaceCreateInfoOHOS::window
```
**描述:**
OHNativeWindow指针。
# vulkan_ohos.h
## 概述
定义了OpenHarmony平台扩展的Vulkan接口。引用文件:&lt;vulkan/vulkan.h&gt;
**起始版本:**
10
**相关模块:**
[Vulkan](_vulkan.md)
## 汇总
### 结构体
| 名称 | 描述 |
| -------- | -------- |
| [VkSurfaceCreateInfoOHOS](_vk_surface_create_info_o_h_o_s.md) | 包含创建Vulkan Surface时必要的参数。 |
| [VkNativeBufferUsageOHOS](_vk_native_buffer_usage_o_h_o_s.md) | 提供OpenHarmony NativeBuffer用途的说明。 |
| [VkNativeBufferPropertiesOHOS](_vk_native_buffer_properties_o_h_o_s.md) | 包含了NaitveBuffer的属性。 |
| [VkNativeBufferFormatPropertiesOHOS](_vk_native_buffer_format_properties_o_h_o_s.md) | 包含了NaitveBuffer的一些格式属性。 |
| [VkImportNativeBufferInfoOHOS](_vk_import_native_buffer_info_o_h_o_s.md) | 包含了OH_NativeBuffer结构体的指针。 |
| [VkMemoryGetNativeBufferInfoOHOS](_vk_memory_get_native_buffer_info_o_h_o_s.md) | 用于从Vulkan内存中获取OH_NativeBuffer。 |
| [VkExternalFormatOHOS](_vk_external_format_o_h_o_s.md) | 表示外部定义的格式标识符。 |
### 宏定义
| 名称 | 描述 |
| -------- | -------- |
| [VK_OHOS_surface](_vulkan.md#vk_ohos_surface) 1 | OpenHarmony平台Surface扩展宏定义。 |
| [VK_OHOS_SURFACE_SPEC_VERSION](_vulkan.md#vk_ohos_surface_spec_version) 1 | OpenHarmony平台Surface扩展版本号。 |
| [VK_OHOS_SURFACE_EXTENSION_NAME](_vulkan.md#vk_ohos_surface_extension_name) "VK_OHOS_surface" | OpenHarmony平台Surface扩展名。 |
| [VK_OHOS_external_memory](_vulkan.md#vk_ohos_external_memory) 1 | OpenHarmony平台external_memory扩展宏定义。 |
| [VK_OHOS_EXTERNAL_MEMORY_SPEC_VERSION](_vulkan.md#vk_ohos_external_memory_spec_version) 1 | OpenHarmony平台external_memory扩展版本号。 |
| [VK_OHOS_EXTERNAL_MEMORY_EXTENSION_NAME](_vulkan.md#vk_ohos_external_memory_extension_name) "VK_OHOS_external_memory" | OpenHarmony平台external_memory扩展名。 |
### 类型定义
| 名称 | 描述 |
| -------- | -------- |
| [OHNativeWindow](_vulkan.md#ohnativewindow) | OH本地窗口。 |
| [VkSurfaceCreateFlagsOHOS](_vulkan.md#vksurfacecreateflagsohos) | 用于Vulkan Surface创建时使用到的VkFlags类型位掩码,预留的标志类型。 |
| [VkSurfaceCreateInfoOHOS](_vulkan.md#vksurfacecreateinfoohos) | 包含创建Vulkan Surface时必要的参数。 |
| VkResult ([VKAPI_PTR *PFN_vkCreateSurfaceOHOS](_vulkan.md#pfn_vkcreatesurfaceohos)) (VkInstance instance, const [VkSurfaceCreateInfoOHOS](_vk_surface_create_info_o_h_o_s.md) \*pCreateInfo, const VkAllocationCallbacks \*pAllocator, VkSurfaceKHR \*pSurface) | 创建Vulkan Surface的函数指针定义。 |
| [VkNativeBufferUsageOHOS](_vulkan.md#vknativebufferusageohos) | 提供OpenHarmony NativeBuffer用途的说明。 |
| [VkNativeBufferPropertiesOHOS](_vulkan.md#vknativebufferpropertiesohos) | 包含了NaitveBuffer的属性。 |
| [VkNativeBufferFormatPropertiesOHOS](_vulkan.md#vknativebufferformatpropertiesohos) | 包含了NaitveBuffer的一些格式属性。 |
| [VkImportNativeBufferInfoOHOS](_vulkan.md#vkimportnativebufferinfoohos) | 包含了OH_NativeBuffer结构体的指针。 |
| [VkMemoryGetNativeBufferInfoOHOS](_vulkan.md#vkmemorygetnativebufferinfoohos) | 用于从Vulkan内存中获取OH_NativeBuffer。 |
| [VkExternalFormatOHOS](_vulkan.md#vkexternalformatohos) | 表示外部定义的格式标识符。 |
| VkResult ([VKAPI_PTR *PFN_vkGetNativeBufferPropertiesOHOS](_vulkan.md#pfn_vkgetnativebufferpropertiesohos)) (VkDevice device, const struct OH_NativeBuffer \*buffer, [VkNativeBufferPropertiesOHOS](_vk_native_buffer_properties_o_h_o_s.md) \*pProperties) | 获取OH_NativeBuffer属性的函数指针定义。 |
| VkResult ([VKAPI_PTR *PFN_vkGetMemoryNativeBufferOHOS](_vulkan.md#pfn_vkgetmemorynativebufferohos)) (VkDevice device, const [VkMemoryGetNativeBufferInfoOHOS](_vk_memory_get_native_buffer_info_o_h_o_s.md) \*pInfo, struct OH_NativeBuffer \*\*pBuffer) | 获取OH_NativeBuffer的函数指针定义。 |
### 函数
| 名称 | 描述 |
| -------- | -------- |
| [vkCreateSurfaceOHOS](_vulkan.md#vkcreatesurfaceohos) (VkInstance instance, const [VkSurfaceCreateInfoOHOS](_vk_surface_create_info_o_h_o_s.md) \*pCreateInfo, const VkAllocationCallbacks \*pAllocator, VkSurfaceKHR \*pSurface) | 创建Vulkan Surface。 |
| [vkGetNativeBufferPropertiesOHOS](_vulkan.md#vkgetnativebufferpropertiesohos) (VkDevice device, const struct OH_NativeBuffer \*buffer, [VkNativeBufferPropertiesOHOS](_vk_native_buffer_properties_o_h_o_s.md) \*pProperties) | 获取OH_NativeBuffer属性。 |
| [vkGetMemoryNativeBufferOHOS](_vulkan.md#vkgetmemorynativebufferohos) (VkDevice device, const [VkMemoryGetNativeBufferInfoOHOS](_vk_memory_get_native_buffer_info_o_h_o_s.md) \*pInfo, struct OH_NativeBuffer \*\*pBuffer) | 获取OH_NativeBuffer。 |
...@@ -1096,7 +1096,7 @@ ...@@ -1096,7 +1096,7 @@
- [@ohos.enterprise.dateTimeManager (系统时间管理)](reference/apis/js-apis-enterprise-dateTimeManager.md) - [@ohos.enterprise.dateTimeManager (系统时间管理)](reference/apis/js-apis-enterprise-dateTimeManager.md)
- [@ohos.enterprise.deviceControl (设备控制管理)](reference/apis/js-apis-enterprise-deviceControl.md) - [@ohos.enterprise.deviceControl (设备控制管理)](reference/apis/js-apis-enterprise-deviceControl.md)
- [@ohos.enterprise.deviceInfo (设备信息管理)](reference/apis/js-apis-enterprise-deviceInfo.md) - [@ohos.enterprise.deviceInfo (设备信息管理)](reference/apis/js-apis-enterprise-deviceInfo.md)
- [@ohos.enterprise.deviceSettings (设备设置管理)](reference/apis/js-apis-enterprise-deviceSetings.md) - [@ohos.enterprise.deviceSettings (设备设置管理)](reference/apis/js-apis-enterprise-deviceSettings.md)
- [@ohos.enterprise.EnterpriseAdminExtensionAbility (企业设备管理扩展能力)](reference/apis/js-apis-EnterpriseAdminExtensionAbility.md) - [@ohos.enterprise.EnterpriseAdminExtensionAbility (企业设备管理扩展能力)](reference/apis/js-apis-EnterpriseAdminExtensionAbility.md)
- [@ohos.enterprise.networkManager (网络管理)](reference/apis/js-apis-enterprise-networkManager.md) - [@ohos.enterprise.networkManager (网络管理)](reference/apis/js-apis-enterprise-networkManager.md)
- [@ohos.enterprise.wifiManager (WiFi管理)](reference/apis/js-apis-enterprise-wifiManager.md) - [@ohos.enterprise.wifiManager (WiFi管理)](reference/apis/js-apis-enterprise-wifiManager.md)
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
- [标准系统内核](kernel/kernel-standard-overview.md) - [标准系统内核](kernel/kernel-standard-overview.md)
- [驱动](driver/Readme-CN.md) - [驱动](driver/Readme-CN.md)
- [编译构建](subsystems/subsys-build-all.md) - [编译构建](subsystems/subsys-build-all.md)
- [分布式远程启动](subsystems/subsys-remote-start.md)
- [图形图像](subsystems/subsys-graphics-overview.md) - [图形图像](subsystems/subsys-graphics-overview.md)
- [媒体](subsystems/subsys-multimedia-camera-overview.md) - [媒体](subsystems/subsys-multimedia-camera-overview.md)
- [公共基础](subsystems/subsys-utils-guide.md) - [公共基础](subsystems/subsys-utils-guide.md)
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
## Audio驱动框架介绍 ## Audio驱动框架介绍
Audio驱动框架基于[HDF驱动框架](driver-hdf-overview.md)实现。Audio驱动架构组成: Audio驱动框架基于[HDF驱动框架](driver-overview-foundation.md)实现。Audio驱动架构组成:
![](figures/Audio框架图.png) ![](figures/Audio框架图.png)
...@@ -300,7 +300,7 @@ int32_t CodecDaiHwParams(const struct AudioCard *card, const struct AudioPcmHwPa ...@@ -300,7 +300,7 @@ int32_t CodecDaiHwParams(const struct AudioCard *card, const struct AudioPcmHwPa
#### Codec注册绑定到HDF #### Codec注册绑定到HDF
此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-hdf-overview.md)指导。 此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-overview-foundation.md)指导。
填充g_codecDriverEntry结构体,moduleName与device_info.hcs中的moduleName匹配,实现Bind、Init、Release函数指针。 填充g_codecDriverEntry结构体,moduleName与device_info.hcs中的moduleName匹配,实现Bind、Init、Release函数指针。
...@@ -799,7 +799,7 @@ int32_t Tfa9879DaiHwParams(const struct AudioCard *card, const struct AudioPcmHw ...@@ -799,7 +799,7 @@ int32_t Tfa9879DaiHwParams(const struct AudioCard *card, const struct AudioPcmHw
#### Codec注册绑定到HDF #### Codec注册绑定到HDF
此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-hdf-overview.md) 此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-overview-foundation.md)
填充g_tfa9879DriverEntry结构体,moduleName与device_info.hcs中的moduleName匹配,实现Bind、Init、Release函数指针。 填充g_tfa9879DriverEntry结构体,moduleName与device_info.hcs中的moduleName匹配,实现Bind、Init、Release函数指针。
...@@ -927,7 +927,7 @@ int32_t Hi3516DmaPointer(struct PlatformData *data, const enum AudioStreamType s ...@@ -927,7 +927,7 @@ int32_t Hi3516DmaPointer(struct PlatformData *data, const enum AudioStreamType s
#### Platform注册绑定到HDF #### Platform注册绑定到HDF
此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-hdf-overview.md) 此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-overview-foundation.md)
- 填充g_platformDriverEntry结构体 - 填充g_platformDriverEntry结构体
- moduleName与device_info.hcs中的moduleName匹配 - moduleName与device_info.hcs中的moduleName匹配
...@@ -1091,7 +1091,7 @@ int32_t DaiStartup(const struct AudioCard *card, const struct DaiDevice *device) ...@@ -1091,7 +1091,7 @@ int32_t DaiStartup(const struct AudioCard *card, const struct DaiDevice *device)
#### Dai注册绑定到HDF #### Dai注册绑定到HDF
此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-hdf-overview.md) 此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-overview-foundation.md)
- 填充g_daiDriverEntry结构体 - 填充g_daiDriverEntry结构体
- moduleName与device_info.hcs中的moduleName匹配 - moduleName与device_info.hcs中的moduleName匹配
......
# kernel # 内核
- 内核 - [内核概述](kernel-overview.md)
- [内核概述](kernel-overview.md) - 轻量系统内核(LiteOS-M)
- 轻量系统内核(LiteOS-M)
- [轻量系统内核概述](kernel-mini-overview.md) - [轻量系统内核概述](kernel-mini-overview.md)
- 基础内核 - 基础内核
- [中断管理](kernel-mini-basic-interrupt.md) - [中断管理](kernel-mini-basic-interrupt.md)
...@@ -30,7 +29,7 @@ ...@@ -30,7 +29,7 @@
- 附录 - 附录
- [内核编码规范](kernel-mini-appx-code.md) - [内核编码规范](kernel-mini-appx-code.md)
- [标准库支持](kernel-mini-appx-lib.md) - [标准库支持](kernel-mini-appx-lib.md)
- 小型系统内核(LiteOS-A) - 小型系统内核(LiteOS-A)
- [小型系统内核概述](kernel-small-overview.md) - [小型系统内核概述](kernel-small-overview.md)
- 内核启动 - 内核启动
- [内核态启动](kernel-small-start-kernel.md) - [内核态启动](kernel-small-start-kernel.md)
...@@ -154,7 +153,7 @@ ...@@ -154,7 +153,7 @@
- [位操作](kernel-small-apx-bitwise.md) - [位操作](kernel-small-apx-bitwise.md)
- [标准库](kernel-small-apx-library.md) - [标准库](kernel-small-apx-library.md)
- [内核编码规范](kernel-mini-appx-code.md) - [内核编码规范](kernel-mini-appx-code.md)
- 标准系统内核(Linux) - 标准系统内核(Linux)
- [标准系统内核概述](kernel-standard-overview.md) - [标准系统内核概述](kernel-standard-overview.md)
- [OpenHarmony开发板Patch使用指导](kernel-standard-patch.md) - [OpenHarmony开发板Patch使用指导](kernel-standard-patch.md)
- [标准系统内核编译与构建指导](kernel-standard-build.md) - [标准系统内核编译与构建指导](kernel-standard-build.md)
......
# security # 隐私与安全
- 隐私与安全
- [隐私保护](security-privacy-protection.md)
- [安全指南](security-guidelines-overall.md) - [隐私保护](security-privacy-protection.md)
- [安全指南](security-guidelines-overall.md)
# subsystems # 子系统开发
- 编译构建 - 编译构建
- [编译构建指导](subsys-build-all.md) - [编译构建指导](subsys-build-all.md)
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
- [Cargo2gn工具操作指导](subsys-build-cargo2gn-guide.md) - [Cargo2gn工具操作指导](subsys-build-cargo2gn-guide.md)
- [ 常见问题](subsys-build-FAQ.md) - [ 常见问题](subsys-build-FAQ.md)
- [ArkCompiler](subsys-arkcompiler-guide.md) - [ArkCompiler](subsys-arkcompiler-guide.md)
- [分布式远程启动](subsys-remote-start.md)
- 小型系统图形图像 - 小型系统图形图像
- [小型系统图形图像概述](subsys-graphics-overview.md) - [小型系统图形图像概述](subsys-graphics-overview.md)
- [普通组件开发指导](subsys-graphics-common-guide.md) - [普通组件开发指导](subsys-graphics-common-guide.md)
......
...@@ -393,7 +393,6 @@ ...@@ -393,7 +393,6 @@
- [HAP编译构建指导](subsystems/subsys-build-gn-hap-compilation-guide.md) - [HAP编译构建指导](subsystems/subsys-build-gn-hap-compilation-guide.md)
- [常见问题](subsystems/subsys-build-FAQ.md) - [常见问题](subsystems/subsys-build-FAQ.md)
- [ArkCompiler](subsystems/subsys-arkcompiler-guide.md) - [ArkCompiler](subsystems/subsys-arkcompiler-guide.md)
- [分布式远程启动](subsystems/subsys-remote-start.md)
- 图形图像 - 图形图像
- [图形图像概述](subsystems/subsys-graphics-overview.md) - [图形图像概述](subsystems/subsys-graphics-overview.md)
- [容器类组件开发指导](subsystems/subsys-graphics-container-guide.md) - [容器类组件开发指导](subsystems/subsys-graphics-container-guide.md)
......
...@@ -40,7 +40,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'; ...@@ -40,7 +40,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary';
async function example() { async function example() {
try { try {
let context = getContext(this); let context = getContext(this);
let media = mediaLibrary.getmediaLibrary(context); let media = mediaLibrary.getMediaLibrary(context);
let fileKeyObj = mediaLibrary.FileKey; let fileKeyObj = mediaLibrary.FileKey;
let albumId = 1; let albumId = 1;
let getImageOp = { let getImageOp = {
...@@ -66,7 +66,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'; ...@@ -66,7 +66,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary';
async function example() { async function example() {
try { try {
let context = getContext(this); let context = getContext(this);
let media = mediaLibrary.getmediaLibrary(context); let media = mediaLibrary.getMediaLibrary(context);
let fileKeyObj = mediaLibrary.FileKey; let fileKeyObj = mediaLibrary.FileKey;
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = { let getImageOp = {
...@@ -102,14 +102,15 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'; ...@@ -102,14 +102,15 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary';
async function example() { async function example() {
try { try {
let context = getContext(this); let context = getContext(this);
let media = mediaLibrary.getmediaLibrary(context); let media = mediaLibrary.getMediaLibrary(context);
let AlbumNoArgsfetchOp = { let AlbumNoArgsfetchOp = {
selections: mediaLibrary.FileKey.ALBUM_NAME + ' = ?', selections: mediaLibrary.FileKey.ALBUM_NAME + ' = ?',
selectionArgs: ['新建相册1'], // 获取albumName为新建相册1的相册。 selectionArgs: ['新建相册1'], // 获取albumName为新建相册1的相册。
}; };
const fetchFileResult = await media.getAlbums(AlbumNoArgsfetchOp); // 查询失败,获取的fetchFileResult为空。 const albumList = await media.getAlbums(AlbumNoArgsfetchOp); // 查询失败,获取的fetchFileResult为空。
const album = await fetchFileResult.getFirstObject(); for (let i = 0; i < albumList.length; i++) {
console.info('mediaLibrary album albumName: ' + album.albumName); console.info('mediaLibrary album albumName: ' + albumList[i].albumName);
}
} catch (err) { } catch (err) {
console.error('mediaLibrary fail, err: ' + err); console.error('mediaLibrary fail, err: ' + err);
} }
...@@ -126,14 +127,15 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'; ...@@ -126,14 +127,15 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary';
async function example() { async function example() {
try { try {
let context = getContext(this); let context = getContext(this);
let media = mediaLibrary.getmediaLibrary(context); let media = mediaLibrary.getMediaLibrary(context);
let AlbumNoArgsfetchOp = { let AlbumNoArgsfetchOp = {
selections: mediaLibrary.FileKey.ALBUM_NAME + ' = ? OR ' + mediaLibrary.FileKey.ALBUM_NAME + ' = ?', selections: mediaLibrary.FileKey.ALBUM_NAME + ' = ? OR ' + mediaLibrary.FileKey.ALBUM_NAME + ' = ?',
selectionArgs: ['Camera', 'Screenshots'], // 获取相机相册和截屏录屏相册。 selectionArgs: ['Camera', 'Screenshots'], // 获取相机相册和截屏录屏相册。
}; };
const fetchFileResult = await media.getAlbums(AlbumNoArgsfetchOp); const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = await fetchFileResult.getFirstObject(); for (let i = 0; i < albumList.length; i++) {
console.info('mediaLibrary album albumName: ' + album.albumName); console.info('mediaLibrary album albumName: ' + albumList[i].albumName);
}
} catch (err) { } catch (err) {
console.error('mediaLibrary fail, err: ' + err); console.error('mediaLibrary fail, err: ' + err);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册