提交 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
zh-cn/application-dev/background-task-management/ @ningningW @wangwenli_wolf @tangtiantian2021 @nan-xiansen
zh-cn/application-dev/work-scheduler/ @ningningW
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-guidelines.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 @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-info.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
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-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-usb.md @jasonyujia @ge-yafang @andeszhang @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-usbManager.md @ge-yafang @Kevin-Lau @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 @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-util.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 @@
- 支持应用兼容性检测。
- 支持应用根据实际使用场景动态设置迁移状态(默认迁移状态为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 @@
}
```
- 如果是单实例应用,则采用同样的代码实现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 @@
- **跨端迁移**
在用户使用设备的过程中,当使用情境发生变化时(例如从室内走到户外或者周围有更合适的设备等),之前使用的设备可能已经不适合继续当前的任务,此时,用户可以选择新的设备来继续当前的任务,原设备退出任务,这就是跨端迁移场景。常见的跨端迁移场景实例:在平板上播放的视频,迁移到智慧屏继续播放,从而获得更佳的观看体验;平板上的视频应用退出。在应用开发层面,跨端迁移指在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 @@
2. 以下场景以加速度传感器ACCELEROMETER为例。展示持续监听传感器接口的调用结果。
```js
```ts
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 @@
3. 注销传感器数据监听。
```js
```ts
import sensor from "@ohos.sensor";
sensor.off(sensor.SensorId.ACCELEROMETER);
```
......@@ -53,10 +54,11 @@
4. 获取一次传感器数据变化。
```js
```ts
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 @@
若接口调用不成功,建议使用try/catch语句捕获代码中可能出现的错误信息。例如:
```js
```ts
import sensor from "@ohos.sensor";
try {
sensor.once(sensor.SensorId.ACCELEROMETER, function(data) {
console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z); // 获取数据成功
});
} catch (error) {
console.error("Get sensor data error. data:" + error.data, " msg:", error.message);
}
```
\ No newline at end of file
try {
sensor.once(sensor.SensorId.ACCELEROMETER, function (data) {
console.info("Succeeded in obtaining data. x: " + data.x + "y: " + data.y + "z: " + data.z); // 获取数据成功
});
} catch (error) {
console.error(`Failed to get sensor data. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -110,171 +110,162 @@ Json文件共包含2个属性。
2. 根据指定振动效果和振动属性触发马达振动。
```js
```ts
import vibrator from '@ohos.vibrator';
try {
vibrator.startVibration({ // 使用startVibration需要添加ohos.permission.VIBRATE权限
type: 'time',
duration: 1000,
}, {
id: 0,
usage: 'alarm'
}, (error) => {
if (error) {
console.error('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message);
return;
}
console.log('Callback returned to indicate a successful vibration.');
});
vibrator.startVibration({ // 使用startVibration需要添加ohos.permission.VIBRATE权限
type: 'time',
duration: 1000,
}, {
id: 0,
usage: 'alarm'
}, (error) => {
if (error) {
console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
return;
}
console.info('Succeed in starting vibration.');
});
} catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
console.error(`An unexpected error occurred. Code: ${err.code}, message: ${err.message}`);
}
```
3. 按照指定模式停止马达的振动。
```js
```ts
import vibrator from '@ohos.vibrator';
try {
// 按照VIBRATOR_STOP_MODE_TIME模式停止振动, 使用stopVibration需要添加ohos.permission.VIBRATE权限
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
return;
}
console.log('Callback returned to indicate successful.');
})
// 按照VIBRATOR_STOP_MODE_TIME模式停止振动, 使用stopVibration需要添加ohos.permission.VIBRATE权限
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) {
if (error) {
console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
return;
}
console.info('Succeeded in stopping vibration.');
})
} catch (err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message);
console.error(`An unexpected error occurred. Code: ${err.code}, message: ${err.message}`);
}
```
4. 停止所有模式的马达振动。
```js
```ts
import vibrator from '@ohos.vibrator';
// 使用startVibration、stopVibration需要添加ohos.permission.VIBRATE权限
try {
vibrator.startVibration({
type: 'time',
duration: 1000,
}, {
id: 0,
usage: 'alarm'
}, (error) => {
if (error) {
console.error('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message);
return;
}
console.log('Callback returned to indicate a successful vibration.');
});
// 停止所有类型的马达振动
vibrator.stopVibration(function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
return;
}
console.log('Callback returned to indicate successful.');
})
vibrator.startVibration({
type: 'time',
duration: 1000,
}, {
id: 0,
usage: 'alarm'
}, (error) => {
if (error) {
console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
return;
}
console.info('Succeed in starting vibration');
});
// 停止所有类型的马达振动
vibrator.stopVibration(function (error) {
if (error) {
console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
return;
}
console.info('Succeed in stopping vibration');
})
} catch (error) {
console.info('errCode: ' + error.code + ' ,msg: ' + error.message);
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
5. 查询是否支持传入的参数effectId。
```js
```ts
import vibrator from '@ohos.vibrator';
try {
// 查询是否支持'haptic.clock.timer'
vibrator.isSupportEffect('haptic.clock.timer', function (err, state) {
if (err) {
console.error('isSupportEffect failed, error:' + JSON.stringify(err));
return;
}
console.log('The effectId is ' + (state ? 'supported' : 'unsupported'));
if (state) {
try {
vibrator.startVibration({ // 使用startVibration需要添加ohos.permission.VIBRATE权限
type: 'preset',
effectId: 'haptic.clock.timer',
count: 1,
}, {
usage: 'unknown'
}, (error) => {
if(error) {
console.error('haptic.clock.timer vibrator error:' + JSON.stringify(error));
} else {
console.log('haptic.clock.timer vibrator success');
}
});
} catch (error) {
console.error('Exception in, error:' + JSON.stringify(error));
}
}
})
// 查询是否支持'haptic.clock.timer'
vibrator.isSupportEffect('haptic.clock.timer', function (err, state) {
if (err) {
console.error(`Failed to query effect. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info('Succeed in querying effect');
if (state) {
try {
vibrator.startVibration({ // 使用startVibration需要添加ohos.permission.VIBRATE权限
type: 'preset',
effectId: 'haptic.clock.timer',
count: 1,
}, {
usage: 'unknown'
}, (error) => {
if (error) {
console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
} else {
console.info('Succeed in starting vibration');
}
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
}
})
} catch (error) {
console.error('Exception in, error:' + JSON.stringify(error));
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
6. 启动和停止自定义振动
```js
```ts
import vibrator from '@ohos.vibrator';
import resourceManager from '@ohos.resourceManager';
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权限
try {
// 启动自定义振动
vibrator.startVibration({
type: "file",
hapticFd: { fd: rawFd.fd, offset: rawFd.offset, length: rawFd.length }
}, {
usage: "alarm"
}).then(() => {
console.info('startVibration success');
}, (error) => {
console.info('startVibration error');
});
// 停止所有类型的马达振动
vibrator.stopVibration(function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
return;
}
console.log('Callback returned to indicate successful.');
})
// 启动自定义振动
vibrator.startVibration({
type: "file",
hapticFd: { fd: fileDescriptor.fd, offset: fileDescriptor.offset, length: fileDescriptor.length }
}, {
usage: "alarm"
}).then(() => {
console.info('Succeed in starting vibration');
}, (error) => {
console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
});
// 停止所有类型的马达振动
vibrator.stopVibration(function (error) {
if (error) {
console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
return;
}
console.info('Succeed in stopping vibration');
})
} 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 @@
- [Native API在应用工程中的使用指导](napi-guidelines.md)
- [Drawing开发指导](drawing-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)
- [使用MindSpore Lite引擎进行模型推理](mindspore-lite-guidelines.md)
- [使用MindSpore Lite进行离线模型的转换及推理](mindspore-lite-offline-model-guidelines.md)
- [Neural Network Runtime对接AI推理框架开发指导](neural-network-runtime-guidelines.md)
- [Purgeable memory开发指导](purgeable-memory-guidelines.md)
- [XComponent开发指导](xcomponent-guidelines.md)
\ No newline at end of file
- [XComponent开发指导](xcomponent-guidelines.md)
- [USB DDK开发指导](usb-ddk-guidelines.md)
\ No newline at end of file
......@@ -418,7 +418,7 @@
- [@ohos.enterprise.dateTimeManager (系统时间管理)](js-apis-enterprise-dateTimeManager.md)
- [@ohos.enterprise.deviceControl (设备控制管理)](js-apis-enterprise-deviceControl.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.networkManager (网络管理)](js-apis-enterprise-networkManager.md)
- [@ohos.enterprise.wifiManager (WiFi管理)](js-apis-enterprise-wifiManager.md)
......
......@@ -223,4 +223,25 @@ class MyAbility extends UIAbility {
return AbilityConstant.OnSaveResult.ALL_AGREE;
}
}
```
## 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操作的常量。
| CONTENT_TITLE_KEY<sup>10+</sup> | ohos.extra.param.key.contentTitle | 指示原子化服务支持分享标题的参数的操作。 |
| SHARE_ABSTRACT_KEY<sup>10+</sup> | ohos.extra.param.key.shareAbstract | 指示原子化服务支持分享内容的参数的操作。 |
| 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
......
......@@ -8,8 +8,6 @@
> - 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> - 从API Version 9开始,该接口不再维护,推荐使用新接口[`@ohos.data.preferences`](js-apis-data-preferences.md)。
>
> - 本模块接口仅可在FA模型下使用。
## 导入模块
......
......@@ -2213,6 +2213,82 @@ setMissionIcon(icon: image.PixelMap): Promise\<void>;
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
restoreWindowStage(localStorage: LocalStorage) : void;
......
......@@ -1300,7 +1300,7 @@ setData(data: PasteData, callback: AsyncCallback&lt;void&gt;): void
**示例:**
```js
let pasteData = pasteboard.createPlainTextData('content');
let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'content');
let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setData(pasteData, (err, data) => {
if (err) {
......@@ -1343,7 +1343,7 @@ setData(data: PasteData): Promise&lt;void&gt;
**示例:**
```js
let pasteData = pasteboard.createPlainTextData('content');
let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'content');
let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setData(pasteData).then((data) => {
console.info('Succeeded in setting PasteData.');
......
......@@ -9,7 +9,7 @@ sensor模块提供了获取传感器数据的能力,包括获取传感器属
## 导入模块
```js
```ts
import sensor from '@ohos.sensor';
```
## sensor.on
......@@ -42,14 +42,14 @@ on(type: SensorId.COLOR, callback: Callback\<ColorResponse>,options?: Options):
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.COLOR, function (data) {
console.info('The intensity of light: ' + data.lightIntensity);
console.info('The color temperature: ' + data.colorTemperature);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.COLOR, function (data) {
console.info('Succeeded in getting the intensity of light: ' + data.lightIntensity);
console.info('Succeeded in getting the color temporature: ' + data.colorTemperature);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.SAR, function (data) {
console.info('Specific absorption rate : ' + data.absorptionRatio);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.SAR, function (data) {
console.info('Succeeded in getting specific absorption rate : ' + data.absorptionRatio);
}, { interval: 100000000 });
} catch (error) {
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;
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.ACCELEROMETER, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.ACCELEROMETER, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking on. X-coordinate bias: ' + data.biasX);
console.info('Succeeded in invoking on. Y-coordinate bias: ' + data.biasY);
console.info('Succeeded in invoking on. Z-coordinate bias: ' + data.biasZ);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.AMBIENT_LIGHT, function (data) {
console.info('The ambient light intensity: ' + data.intensity);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.AMBIENT_LIGHT, function (data) {
console.info('Succeeded in getting the ambient light intensity: ' + data.intensity);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, function (data) {
console.info('Temperature: ' + data.temperature);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, function (data) {
console.info('Succeeded in invoking on. Temperature: ' + data.temperature);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.BAROMETER, function (data) {
console.info('Atmospheric pressure: ' + data.pressure);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.BAROMETER, function (data) {
console.info('Succeeded in invoking on. Atmospheric pressure: ' + data.pressure);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.GRAVITY, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.GRAVITY, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.GYROSCOPE, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.GYROSCOPE, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking on. X-coordinate bias: ' + data.biasX);
console.info('Succeeded in invoking on. Y-coordinate bias: ' + data.biasY);
console.info('Succeeded in invoking on. Z-coordinate bias: ' + data.biasZ);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.HALL, function (data) {
console.info('Hall status: ' + data.status);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.HALL, function (data) {
console.info('Succeeded in invoking on. Hall status: ' + data.status);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.HEART_RATE, function (data) {
console.info('Heart rate: ' + data.heartRate);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.HEART_RATE, function (data) {
console.info('Succeeded in invoking on. Heart rate: ' + data.heartRate);
}, { interval: 100000000 });
} catch (error) {
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?:
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.HUMIDITY, function (data) {
console.info('Humidity: ' + data.humidity);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.HUMIDITY, function (data) {
console.info('Succeeded in invoking on. Humidity: ' + data.humidity);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.MAGNETIC_FIELD, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.MAGNETIC_FIELD, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking on. X-coordinate bias: ' + data.biasX);
console.info('Succeeded in invoking on. Y-coordinate bias: ' + data.biasY);
console.info('Succeeded in invoking on. Z-coordinate bias: ' + data.biasZ);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.ORIENTATION, function (data) {
console.info('The device rotates 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('The device rotates at an angle around the Y axis: ' + data.gamma);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.ORIENTATION, function (data) {
console.info('Succeeded in the device rotating at an angle around the Z axis: ' + data.alpha);
console.info('Succeeded in the device rotating at an angle around the X axis: ' + data.beta);
console.info('Succeeded in the device rotating at an angle around the Y axis: ' + data.gamma);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.PEDOMETER, function (data) {
console.info('Step count: ' + data.steps);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.PEDOMETER, function (data) {
console.info('Succeeded in invoking on. Step count: ' + data.steps);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.PEDOMETER_DETECTION, function (data) {
console.info('Pedometer scalar: ' + data.scalar);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.PEDOMETER_DETECTION, function (data) {
console.info('Succeeded in invoking on. Pedometer scalar: ' + data.scalar);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.PROXIMITY, function (data) {
console.info('Distance: ' + data.distance);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.PROXIMITY, function (data) {
console.info('Succeeded in invoking on. Distance: ' + data.distance);
}, { interval: 100000000 });
} catch (error) {
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&
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.ROTATION_VECTOR, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('Scalar quantity: ' + data.w);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.ROTATION_VECTOR, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking on. Scalar quantity: ' + data.w);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, function (data) {
console.info('Scalar data: ' + data.scalar);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, function (data) {
console.info('Succeeded in invoking on. Scalar data: ' + data.scalar);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.on(sensor.SensorId.WEAR_DETECTION, function (data) {
console.info('Wear status: ' + data.value);
}, { interval: 100000000 });
} catch (err) {
console.error('On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.WEAR_DETECTION, function (data) {
console.info('Succeeded in invoking on. Wear status: ' + data.value);
}, { interval: 100000000 });
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.ACCELEROMETER, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.ACCELEROMETER, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking once. X-coordinate bias: ' + data.biasX);
console.info('Succeeded in invoking once. Y-coordinate bias: ' + data.biasY);
console.info('Succeeded in invoking once. Z-coordinate bias: ' + data.biasZ);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.AMBIENT_LIGHT, function (data) {
console.info('The ambient light intensity: ' + data.intensity);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.AMBIENT_LIGHT, function (data) {
console.info('Succeeded in invoking once. the ambient light intensity: ' + data.intensity);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.AMBIENT_TEMPERATURE, function (data) {
console.info('Temperature: ' + data.temperature);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.AMBIENT_TEMPERATURE, function (data) {
console.info('Succeeded in invoking once. Temperature: ' + data.temperature);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function (data) {
console.info('Atmospheric pressure: ' + data.pressure);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.BAROMETER, function (data) {
console.info('Succeeded in invoking once. Atmospheric pressure: ' + data.pressure);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.GRAVITY, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.GRAVITY, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
});
} catch (error) {
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
**示例:**
```js
```ts
import sensor from '@ohos.sensor';
try {
sensor.once(sensor.SensorId.GYROSCOPE, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.GYROSCOPE, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.GYROSCOPE_UNCALIBRATED, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.GYROSCOPE_UNCALIBRATED, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking once. X-coordinate bias: ' + data.biasX);
console.info('Succeeded in invoking once. Y-coordinate bias: ' + data.biasY);
console.info('Succeeded in invoking once. Z-coordinate bias: ' + data.biasZ);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.HALL, function (data) {
console.info('Status: ' + data.status);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.HALL, function (data) {
console.info('Succeeded in invoking once. Status: ' + data.status);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.HEART_RATE, function (data) {
console.info('Heart rate: ' + data.heartRate);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.HEART_RATE, function (data) {
console.info('Succeeded in invoking once. Heart rate: ' + data.heartRate);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.HUMIDITY, function (data) {
console.info('Humidity: ' + data.humidity);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.HUMIDITY, function (data) {
console.info('Succeeded in invoking once. Humidity: ' + data.humidity);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.LINEAR_ACCELEROMETER, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.LINEAR_ACCELEROMETER, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
});
} catch (error) {
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&
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.MAGNETIC_FIELD, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.MAGNETIC_FIELD, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking once. X-coordinate bias: ' + data.biasX);
console.info('Succeeded in invoking once. Y-coordinate bias: ' + data.biasY);
console.info('Succeeded in invoking once. Z-coordinate bias: ' + data.biasZ);
});
} catch (error) {
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;):
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.ORIENTATION, function (data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.ORIENTATION, function (data) {
console.info('Succeeded in the device rotating at an angle around the X axis: ' + data.beta);
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);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.PEDOMETER, function (data) {
console.info('Step count: ' + data.steps);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.PEDOMETER, function (data) {
console.info('Succeeded in invoking once. Step count: ' + data.steps);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.PEDOMETER_DETECTION, function (data) {
console.info('Scalar data: ' + data.scalar);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.PEDOMETER_DETECTION, function (data) {
console.info('Succeeded in invoking once. Scalar data: ' + data.scalar);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.PROXIMITY, function (data) {
console.info('Distance: ' + data.distance);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.PROXIMITY, function (data) {
console.info('Succeeded in invoking once. Distance: ' + data.distance);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.ROTATION_VECTOR, function (data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('Scalar quantity: ' + data.w);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.ROTATION_VECTOR, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking once. Scalar quantity: ' + data.w);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.SIGNIFICANT_MOTION, function (data) {
console.info('Scalar data: ' + data.scalar);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.SIGNIFICANT_MOTION, function (data) {
console.info('Succeeded in invoking once. Scalar data: ' + data.scalar);
});
} catch (error) {
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&
**示例:**
```js
```ts
try {
sensor.once(sensor.SensorId.WEAR_DETECTION, function (data) {
console.info("Wear status: " + data.value);
});
} catch (err) {
console.error('Once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.once(sensor.SensorId.WEAR_DETECTION, function (data) {
console.info('Succeeded in invoking once. Wear status: ' + data.value);
});
} catch (error) {
console.error(`Failed to invoke once. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1703,22 +1705,24 @@ off(type: SensorId.COLOR, callback?: Callback\<ColorResponse>): void
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.COLOR, callback1);
sensor.on(sensor.SensorId.COLOR, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.COLOR, callback1);
// 取消注册SensorId.COLOR的所有回调
sensor.off(sensor.SensorId.COLOR);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.COLOR, callback1);
sensor.on(sensor.SensorId.COLOR, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.COLOR, callback1);
// 取消注册SensorId.COLOR的所有回调
sensor.off(sensor.SensorId.COLOR);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1741,22 +1745,24 @@ off(type: SensorId.SAR, callback?: Callback\<SarResponse>): void
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.SAR, callback1);
sensor.on(sensor.SensorId.SAR, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.SAR, callback1);
// 取消注册SensorId.SAR的所有回调
sensor.off(sensor.SensorId.SAR);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.SAR, callback1);
sensor.on(sensor.SensorId.SAR, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.SAR, callback1);
// 取消注册SensorId.SAR的所有回调
sensor.off(sensor.SensorId.SAR);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1779,22 +1785,24 @@ off(type: SensorId.ACCELEROMETER, callback?: Callback&lt;AccelerometerResponse&g
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.ACCELEROMETER, callback1);
sensor.on(sensor.SensorId.ACCELEROMETER, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.ACCELEROMETER, callback1);
// 取消SensorId.ACCELEROMETER类型的所有回调
sensor.off(sensor.SensorId.ACCELEROMETER);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.ACCELEROMETER, callback1);
sensor.on(sensor.SensorId.ACCELEROMETER, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.ACCELEROMETER, callback1);
// 取消SensorId.ACCELEROMETER类型的所有回调
sensor.off(sensor.SensorId.ACCELEROMETER);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1817,22 +1825,24 @@ off(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback?: Callback&lt;Accelerome
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback1);
sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback1);
// 取消注册SensorId.ACCELEROMETER_UNCALIBRATED类型的所有回调
sensor.off(sensor.SensorId.ACCELEROMETER_UNCALIBRATED);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback1);
sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback1);
// 取消注册SensorId.ACCELEROMETER_UNCALIBRATED类型的所有回调
sensor.off(sensor.SensorId.ACCELEROMETER_UNCALIBRATED);
} catch (error) {
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
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback1);
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.AMBIENT_LIGHT, callback1);
// 取消注册SensorId.AMBIENT_LIGHT的所有回调
sensor.off(sensor.SensorId.AMBIENT_LIGHT);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback1);
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.AMBIENT_LIGHT, callback1);
// 取消注册SensorId.AMBIENT_LIGHT
sensor.off(sensor.SensorId.AMBIENT_LIGHT);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1889,22 +1901,24 @@ off(type: SensorId.AMBIENT_TEMPERATURE, callback?: Callback&lt;AmbientTemperatur
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, callback1);
sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.AMBIENT_TEMPERATURE, callback1);
// 取消注册SensorId.AMBIENT_TEMPERATURE的所有回调
sensor.off(sensor.SensorId.AMBIENT_TEMPERATURE);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, callback1);
sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.AMBIENT_TEMPERATURE, callback1);
// 取消注册SensorId.AMBIENT_TEMPERATURE的所有回调
sensor.off(sensor.SensorId.AMBIENT_TEMPERATURE);
} catch (error) {
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
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.BAROMETER, callback1);
sensor.on(sensor.SensorId.BAROMETER, callback2);
......@@ -1939,8 +1955,8 @@ try {
sensor.off(sensor.SensorId.BAROMETER, callback1);
// 取消注册SensorId.BAROMETER的所有回调
sensor.off(sensor.SensorId.BAROMETER);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1961,22 +1977,24 @@ off(type: SensorId.GRAVITY, callback?: Callback&lt;GravityResponse&gt;): void
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.GRAVITY, callback1);
sensor.on(sensor.SensorId.GRAVITY, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.GRAVITY, callback1);
// 取消注册SensorId.GRAVITY的所有回调
sensor.off(sensor.SensorId.GRAVITY);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.GRAVITY, callback1);
sensor.on(sensor.SensorId.GRAVITY, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.GRAVITY, callback1);
// 取消注册SensorId.GRAVITY的所有回调
sensor.off(sensor.SensorId.GRAVITY);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1999,22 +2017,24 @@ off(type: SensorId.GYROSCOPE, callback?: Callback&lt;GyroscopeResponse&gt;): voi
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.GYROSCOPE, callback1);
sensor.on(sensor.SensorId.GYROSCOPE, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.GYROSCOPE, callback1);
// 取消注册SensorId.GYROSCOPE的所有回调
sensor.off(sensor.SensorId.GYROSCOPE);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.GYROSCOPE, callback1);
sensor.on(sensor.SensorId.GYROSCOPE, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.GYROSCOPE, callback1);
// 取消注册SensorId.GYROSCOPE的所有回调
sensor.off(sensor.SensorId.GYROSCOPE);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2037,22 +2057,24 @@ off(type: SensorId.GYROSCOPE_UNCALIBRATED, callback?: Callback&lt;GyroscopeUncal
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback1);
sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback1);
// 取消注册SensorId.GYROSCOPE_UNCALIBRATED的所有回调
sensor.off(sensor.SensorId.GYROSCOPE_UNCALIBRATED);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback1);
sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback1);
// 取消注册SensorId.GYROSCOPE_UNCALIBRATED的所有回调
sensor.off(sensor.SensorId.GYROSCOPE_UNCALIBRATED);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2073,22 +2095,24 @@ off(type: SensorId.HALL, callback?: Callback&lt;HallResponse&gt;): void
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.HALL, callback1);
sensor.on(sensor.SensorId.HALL, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.HALL, callback1);
// 取消注册SensorId.HALL的所有回调
sensor.off(sensor.SensorId.HALL);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.HALL, callback1);
sensor.on(sensor.SensorId.HALL, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.HALL, callback1);
// 取消注册SensorId.HALL的所有回调
sensor.off(sensor.SensorId.HALL);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2111,22 +2135,24 @@ off(type: SensorId.HEART_RATE, callback?: Callback&lt;HeartRateResponse&gt;): vo
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.HEART_RATE, callback1);
sensor.on(sensor.SensorId.HEART_RATE, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.HEART_RATE, callback1);
// 取消注册SensorId.HEART_RATE的所有回调
sensor.off(sensor.SensorId.HEART_RATE);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.HEART_RATE, callback1);
sensor.on(sensor.SensorId.HEART_RATE, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.HEART_RATE, callback1);
// 取消注册SensorId.HEART_RATE的所有回调
sensor.off(sensor.SensorId.HEART_RATE);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2147,22 +2173,24 @@ off(type: SensorId.HUMIDITY, callback?: Callback&lt;HumidityResponse&gt;): void
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.HUMIDITY, callback1);
sensor.on(sensor.SensorId.HUMIDITY, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.HUMIDITY, callback1);
// 取消注册SensorId.HUMIDITY的所有回调
sensor.off(sensor.SensorId.HUMIDITY);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.HUMIDITY, callback1);
sensor.on(sensor.SensorId.HUMIDITY, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.HUMIDITY, callback1);
// 取消注册SensorId.HUMIDITY的所有回调
sensor.off(sensor.SensorId.HUMIDITY);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2185,22 +2213,24 @@ off(type: SensorId.LINEAR_ACCELEROMETER, callback?: Callback&lt;LinearAccelerome
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, callback1);
sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.LINEAR_ACCELEROMETER, callback1);
// 取消注册SensorId.LINEAR_ACCELEROMETER的所有回调
sensor.off(sensor.SensorId.LINEAR_ACCELEROMETER);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, callback1);
sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.LINEAR_ACCELEROMETER, callback1);
// 取消注册SensorId.LINEAR_ACCELEROMETER的所有回调
sensor.off(sensor.SensorId.LINEAR_ACCELEROMETER);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2221,22 +2251,24 @@ off(type: SensorId.MAGNETIC_FIELD, callback?: Callback&lt;MagneticFieldResponse&
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback1);
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.MAGNETIC_FIELD, callback1);
// 取消注册SensorId.MAGNETIC_FIELD的所有回调
sensor.off(sensor.SensorId.MAGNETIC_FIELD);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback1);
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.MAGNETIC_FIELD, callback1);
// 取消注册SensorId.MAGNETIC_FIELD的所有回调
sensor.off(sensor.SensorId.MAGNETIC_FIELD);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2257,22 +2289,24 @@ off(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback&lt;MagneticF
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback1);
sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback1);
// 取消注册SensorId.MAGNETIC_FIELD_UNCALIBRATED的所有回调
sensor.off(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback1);
sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback1);
// 取消注册SensorId.MAGNETIC_FIELD_UNCALIBRATED的所有回调
sensor.off(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2293,22 +2327,24 @@ off(type: SensorId.ORIENTATION, callback?: Callback&lt;OrientationResponse&gt;):
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.ORIENTATION, callback1);
sensor.on(sensor.SensorId.ORIENTATION, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.ORIENTATION, callback1);
// 取消注册SensorId.ORIENTATION的所有回调
sensor.off(sensor.SensorId.ORIENTATION);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.ORIENTATION, callback1);
sensor.on(sensor.SensorId.ORIENTATION, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.ORIENTATION, callback1);
// 取消注册SensorId.ORIENTATION的所有回调
sensor.off(sensor.SensorId.ORIENTATION);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2331,22 +2367,24 @@ off(type: SensorId.PEDOMETER, callback?: Callback&lt;PedometerResponse&gt;): voi
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.PEDOMETER, callback1);
sensor.on(sensor.SensorId.PEDOMETER, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.PEDOMETER, callback1);
// 取消注册SensorId.PEDOMETER的所有回调
sensor.off(sensor.SensorId.PEDOMETER);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.PEDOMETER, callback1);
sensor.on(sensor.SensorId.PEDOMETER, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.PEDOMETER, callback1);
// 取消注册SensorId.PEDOMETER的所有回调
sensor.off(sensor.SensorId.PEDOMETER);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2369,22 +2407,24 @@ off(type: SensorId.PEDOMETER_DETECTION, callback?: Callback&lt;PedometerDetectio
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback1);
sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.PEDOMETER_DETECTION, callback1);
// 取消注册SensorId.PEDOMETER_DETECTION的所有回调
sensor.off(sensor.SensorId.PEDOMETER_DETECTION);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback1);
sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.PEDOMETER_DETECTION, callback1);
// 取消注册SensorId.PEDOMETER_DETECTION的所有回调
sensor.off(sensor.SensorId.PEDOMETER_DETECTION);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2405,22 +2445,24 @@ off(type: SensorId.PROXIMITY, callback?: Callback&lt;ProximityResponse&gt;): voi
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.PROXIMITY, callback1);
sensor.on(sensor.SensorId.PROXIMITY, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.PROXIMITY, callback1);
// 取消注册SensorId.PROXIMITY的所有回调
sensor.off(sensor.SensorId.PROXIMITY);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.PROXIMITY, callback1);
sensor.on(sensor.SensorId.PROXIMITY, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.PROXIMITY, callback1);
// 取消注册SensorId.PROXIMITY的所有回调
sensor.off(sensor.SensorId.PROXIMITY);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2441,22 +2483,24 @@ off(type: SensorId.ROTATION_VECTOR, callback?: Callback&lt;RotationVectorRespons
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.ROTATION_VECTOR, callback1);
sensor.on(sensor.SensorId.ROTATION_VECTOR, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.ROTATION_VECTOR, callback1);
// 取消注册SensorId.ROTATION_VECTOR的所有回调
sensor.off(sensor.SensorId.ROTATION_VECTOR);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.ROTATION_VECTOR, callback1);
sensor.on(sensor.SensorId.ROTATION_VECTOR, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.ROTATION_VECTOR, callback1);
// 取消注册SensorId.ROTATION_VECTOR的所有回调
sensor.off(sensor.SensorId.ROTATION_VECTOR);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2477,22 +2521,24 @@ off(type: SensorId.SIGNIFICANT_MOTION, callback?: Callback&lt;SignificantMotionR
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, callback1);
sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.SIGNIFICANT_MOTION, callback1);
// 取消注册SensorId.SIGNIFICANT_MOTION的所有回调
sensor.off(sensor.SensorId.SIGNIFICANT_MOTION);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, callback1);
sensor.on(sensor.SensorId.SIGNIFICANT_MOTION, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.SIGNIFICANT_MOTION, callback1);
// 取消注册SensorId.SIGNIFICANT_MOTION的所有回调
sensor.off(sensor.SensorId.SIGNIFICANT_MOTION);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2513,22 +2559,24 @@ off(type: SensorId.WEAR_DETECTION, callback?: Callback&lt;WearDetectionResponse&
**示例:**
```js
```ts
function callback1(data) {
console.info('Callback1 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback1 data: ' + JSON.stringify(data));
}
function callback2(data) {
console.info('Callback2 data: ' + JSON.stringify(data));
console.info('Succeeded in getting callback2 data: ' + JSON.stringify(data));
}
try {
sensor.on(sensor.SensorId.WEAR_DETECTION, callback1);
sensor.on(sensor.SensorId.WEAR_DETECTION, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.WEAR_DETECTION, callback1);
// 取消注册SensorId.WEAR_DETECTION的所有回调
sensor.off(sensor.SensorId.WEAR_DETECTION);
} catch (err) {
console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
sensor.on(sensor.SensorId.WEAR_DETECTION, callback1);
sensor.on(sensor.SensorId.WEAR_DETECTION, callback2);
// 仅取消callback1的注册
sensor.off(sensor.SensorId.WEAR_DETECTION, callback1);
// 取消注册SensorId.WEAR_DETECTION的所有回调
sensor.off(sensor.SensorId.WEAR_DETECTION);
} catch (error) {
console.error(`Failed to invoke off. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2558,23 +2606,23 @@ getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number, callbac
**示例:**
```js
```ts
try {
sensor.getGeomagneticInfo({ latitude: 80, longitude: 0, altitude: 0 }, 1580486400000, function (err, data) {
if (err) {
console.error('Get geomagneticInfo failed. Error code: ' + err.code + '; message: ' + err.message);
return;
}
console.info("GeomagneticInfo x" + data.x);
console.info("GeomagneticInfo y" + data.y);
console.info("GeomagneticInfo z" + data.z);
console.info("GeomagneticInfo geomagneticDip" + data.geomagneticDip);
console.info("GeomagneticInfo deflectionAngle" + data.deflectionAngle);
console.info("GeomagneticInfo levelIntensity" + data.levelIntensity);
console.info("GeomagneticInfo totalIntensity" + data.totalIntensity);
});
} catch (err) {
console.error('Get geomagneticInfo failed. Error code: ' + err.code + '; message: ' + err.message);
sensor.getGeomagneticInfo({ latitude: 80, longitude: 0, altitude: 0 }, 1580486400000, function (err, data) {
if (err) {
console.error(`Failed to get geomagneticInfo. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info("Succeeded in getting geomagneticInfo x" + data.x);
console.info("Succeeded in getting geomagneticInfo y" + data.y);
console.info("Succeeded in getting geomagneticInfo z" + data.z);
console.info("Succeeded in getting geomagneticInfo geomagneticDip" + data.geomagneticDip);
console.info("Succeeded in getting geomagneticInfo deflectionAngle" + data.deflectionAngle);
console.info("Succeeded in getting geomagneticInfo levelIntensity" + data.levelIntensity);
console.info("Succeeded in getting geomagneticInfo totalIntensity" + data.totalIntensity);
});
} catch (error) {
console.error(`Failed to get geomagneticInfo. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2609,22 +2657,22 @@ getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number): Promis
**示例:**
```js
```ts
try {
const promise = sensor.getGeomagneticInfo({ latitude: 80, longitude: 0, altitude: 0 }, 1580486400000);
promise.then((data) => {
console.info("GeomagneticInfo x" + data.x);
console.info("GeomagneticInfo y" + data.y);
console.info("GeomagneticInfo z" + data.z);
console.info("GeomagneticInfo geomagneticDip" + data.geomagneticDip);
console.info("GeomagneticInfo deflectionAngle" + data.deflectionAngle);
console.info("GeomagneticInfo levelIntensity" + data.levelIntensity);
console.info("GeomagneticInfo totalIntensity" + data.totalIntensity);
}, (err)=>{
console.error('Get geomagneticInfo failed. Error code: ' + err.code + '; message: ' + err.message);
});
} catch (err) {
console.error('Get geomagneticInfo. Error code: ' + err.code + '; message: ' + err.message);
const promise = sensor.getGeomagneticInfo({ latitude: 80, longitude: 0, altitude: 0 }, 1580486400000);
promise.then((data) => {
console.info("Succeeded in getting geomagneticInfo x" + data.x);
console.info("Succeeded in getting geomagneticInfo y" + data.y);
console.info("Succeeded in getting geomagneticInfo z" + data.z);
console.info("Succeeded in getting geomagneticInfo geomagneticDip" + data.geomagneticDip);
console.info("Succeeded in getting geomagneticInfo deflectionAngle" + data.deflectionAngle);
console.info("Succeeded in getting geomagneticInfo levelIntensity" + data.levelIntensity);
console.info("Succeeded in getting geomagneticInfo totalIntensity" + data.totalIntensity);
}, (err) => {
console.error(`Failed to get geomagneticInfo. Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
console.error(`Failed to get geomagneticInfo. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2654,19 +2702,19 @@ getDeviceAltitude(seaPressure: number, currentPressure: number, callback: AsyncC
**示例:**
```js
```ts
try {
let seaPressure = 1013.2;
let currentPressure = 1500.0;
sensor.getDeviceAltitude(seaPressure, currentPressure, function (err, data) {
if (err) {
console.error('Get altitude failed. Error code: ' + err.code + '; message: ' + err.message);
return;
}
console.info('altitude: ' + data);
});
} catch (err) {
console.error('Get altitude failed. Error code: ' + err.code + '; message: ' + err.message);
let seaPressure = 1013.2;
let currentPressure = 1500.0;
sensor.getDeviceAltitude(seaPressure, currentPressure, function (err, data) {
if (err) {
console.error(`Failed to get altitude. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info('Succeeded in getting altitude: ' + data);
});
} catch (error) {
console.error(`Failed to get altitude. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2701,18 +2749,18 @@ getDeviceAltitude(seaPressure: number, currentPressure: number): Promise&lt;numb
**示例:**
```js
```ts
try {
let seaPressure = 1013.2;
let currentPressure = 1500.0;
const promise = sensor.getDeviceAltitude(seaPressure, currentPressure);
promise.then((data) => {
console.info('sensor_getDeviceAltitude_Promise success', data);
}, (err) => {
console.error('Get altitude failed. Error code: ' + err.code + '; message: ' + err.message);
});
} catch (err) {
console.error('Get altitude failed. Error code: ' + err.code + '; message: ' + err.message);
let seaPressure = 1013.2;
let currentPressure = 1500.0;
const promise = sensor.getDeviceAltitude(seaPressure, currentPressure);
promise.then((data) => {
console.info('Succeeded in getting sensor_getDeviceAltitude_Promise', data);
}, (err) => {
console.error(`Failed to get altitude. Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
console.error(`Failed to get altitude. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2741,23 +2789,23 @@ getInclination(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallback&l
**示例:**
```js
```ts
try {
// inclinationMatrix可以为3*3,或者4*4
let inclinationMatrix = [
1, 0, 0,
0, 1, 0,
0, 0, 1
]
sensor.getInclination(inclinationMatrix, function (err, data) {
if (err) {
console.error('Get inclination failed. Error code: ' + err.code + '; message: ' + err.message);
return;
}
console.info('Inclination: ' + data);
})
} catch (err) {
console.error('Get inclination failed. Error code: ' + err.code + '; message: ' + err.message);
// inclinationMatrix可以为3*3,或者4*4
let inclinationMatrix = [
1, 0, 0,
0, 1, 0,
0, 0, 1
]
sensor.getInclination(inclinationMatrix, function (err, data) {
if (err) {
console.error(`Failed to get inclination. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info('Succeeded in getting inclination: ' + data);
})
} catch (error) {
console.error(`Failed to get inclination. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2791,22 +2839,22 @@ try {
**示例:**
```js
```ts
try {
// inclinationMatrix可以为3*3,或者4*4
let inclinationMatrix = [
1, 0, 0,
0, 1, 0,
0, 0, 1
]
const promise = sensor.getInclination(inclinationMatrix);
promise.then((data) => {
console.info('Inclination: ' + data);
}, (err) => {
console.error('Get inclination failed. Error code: ' + err.code + '; message: ' + err.message);
});
} catch (err) {
console.error('Get inclination failed. Error code: ' + err.code + '; message: ' + err.message);
// inclinationMatrix可以为3*3,或者4*4
let inclinationMatrix = [
1, 0, 0,
0, 1, 0,
0, 0, 1
]
const promise = sensor.getInclination(inclinationMatrix);
promise.then((data) => {
console.info('Succeeded in getting inclination: ' + data);
}, (err) => {
console.error(`Failed to get inclination. Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
console.error(`Failed to get inclination. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2837,33 +2885,33 @@ try {
**示例:**
```js
```ts
try {
// 旋转矩阵可以为3*3,或者4*4
let currentRotationMatrix = [
1, 0, 0,
0, 1, 0,
0, 0, 1
];
let preRotationMatrix = [
1, 0, 0,
0, 0.87, -0.50,
0, 0.50, 0.87
];
sensor.getAngleVariation(currentRotationMatrix, preRotationMatrix, function (err, data) {
if (err) {
console.error('Get angle variation failed. Error code: ' + err.code + '; message: ' + err.message);
return;
}
if (data.length < 3) {
console.error("Get angle variation failed, length" + data.length);
}
console.info("Z: " + data[0]);
console.info("X: " + data[1]);
console.info("Y : " + data[2]);
})
} catch (err) {
console.error('Get angle variation failed. Error code: ' + err.code + '; message: ' + err.message);
// 旋转矩阵可以为3*3,或者4*4
let currentRotationMatrix = [
1, 0, 0,
0, 1, 0,
0, 0, 1
];
let preRotationMatrix = [
1, 0, 0,
0, 0.87, -0.50,
0, 0.50, 0.87
];
sensor.getAngleVariation(currentRotationMatrix, preRotationMatrix, function (err, data) {
if (err) {
console.error(`Failed to get angle variation. Code: ${err.code}, message: ${err.message}`);
return;
}
if (data.length < 3) {
console.error("Failed to get angle variation, length" + data.length);
}
console.info("Z: " + data[0]);
console.info("X: " + data[1]);
console.info("Y : " + data[2]);
})
} catch (error) {
console.error(`Failed to get angle variation. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -2898,32 +2946,32 @@ getAngleVariation(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix:
**示例:**
```js
```ts
try {
// 旋转矩阵可以为3*3,或者4*4
let currentRotationMatrix = [
1, 0, 0,
0, 1, 0,
0, 0, 1
];
let preRotationMatrix = [
1, 0, 0,
0, 0.87, -0.50,
0, 0.50, 0.87
];
const promise = sensor.getAngleVariation(currentRotationMatrix, preRotationMatrix);
promise.then((data) => {
if (data.length < 3) {
console.error("Get angle variation failed, length" + data.length);
}
console.info("Z: " + data[0]);
console.info("X: " + data[1]);
console.info("Y : " + data[2]);
}, (err) => {
console.error('Get angle variation failed. Error code: ' + err.code + '; message: ' + err.message);
});
} catch (err) {
console.error('Get angle variation failed. Error code: ' + err.code + '; message: ' + err.message);
// 旋转矩阵可以为3*3,或者4*4
let currentRotationMatrix = [
1, 0, 0,
0, 1, 0,
0, 0, 1
];
let preRotationMatrix = [
1, 0, 0,
0, 0.87, -0.50,
0, 0.50, 0.87
];
const promise = sensor.getAngleVariation(currentRotationMatrix, preRotationMatrix);
promise.then((data) => {
if (data.length < 3) {
console.error("Failed to get angle variation, length" + data.length);
}
console.info("Z: " + data[0]);
console.info("X: " + data[1]);
console.info("Y : " + data[2]);
}, (err) => {
console.error(`Failed to get angle variation. Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
sensor.getRotationMatrix(rotationVector, function (err, data) {
if (err) {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
return;
}
for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + data[i]);
}
})
} catch (err) {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
sensor.getRotationMatrix(rotationVector, function (err, data) {
if (err) {
console.error(`Failed to get rotationMatrix. Code: ${err.code}, message: ${err.message}`);
return;
}
for (var i = 0; i < data.length; i++) {
console.info('Succeeded in getting data[' + i + ']: ' + data[i]);
}
})
} catch (error) {
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
**示例:**
```js
```ts
try {
let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
const promise = sensor.getRotationMatrix(rotationVector);
promise.then((data) => {
for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + data[i]);
}
}, (err) => {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
});
} catch (err) {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
const promise = sensor.getRotationMatrix(rotationVector);
promise.then((data) => {
for (var i = 0; i < data.length; i++) {
console.info('Succeeded in getting data[' + i + ']: ' + data[i]);
}
}, (err) => {
console.error(`Failed to get rotationMatrix. Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
console.error(`Failed to get rotationMatrix. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -3042,24 +3090,24 @@ transformRotationMatrix(inRotationVector: Array&lt;number&gt;, coordinates: Coor
**示例:**
```js
```ts
try {
let rotationMatrix = [
1, 0, 0,
0, 0.87, -0.50,
0, 0.50, 0.87
];
sensor.transformRotationMatrix(rotationMatrix, { x: 1, y: 3 }, function (err, data) {
if (err) {
console.error('Transform rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
return;
}
for (var i = 0; i < data.length; i++) {
console.info('data[' + i + '] = ' + data[i]);
}
})
} catch (err) {
console.error('Transform rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
let rotationMatrix = [
1, 0, 0,
0, 0.87, -0.50,
0, 0.50, 0.87
];
sensor.transformRotationMatrix(rotationMatrix, { x: 1, y: 3 }, function (err, data) {
if (err) {
console.error(`Failed to transform rotationMatrix. Code: ${err.code}, message: ${err.message}`);
return;
}
for (var i = 0; i < data.length; i++) {
console.info('Succeeded in getting data[' + i + '] = ' + data[i]);
}
})
} catch (error) {
console.error(`Failed to transform rotationMatrix. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -3094,23 +3142,23 @@ transformRotationMatrix(inRotationVector: Array&lt;number&gt;, coordinates: Coor
**示例:**
```js
```ts
try {
let rotationMatrix = [
1, 0, 0,
0, 0.87, -0.50,
0, 0.50, 0.87
];
const promise = sensor.transformRotationMatrix(rotationMatrix, { x: 1, y: 3 });
promise.then((data) => {
for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + data[i]);
}
}, (err) => {
console.error('Transform rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
});
} catch (err) {
console.error('Transform rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
let rotationMatrix = [
1, 0, 0,
0, 0.87, -0.50,
0, 0.50, 0.87
];
const promise = sensor.transformRotationMatrix(rotationMatrix, { x: 1, y: 3 });
promise.then((data) => {
for (var i = 0; i < data.length; i++) {
console.info('Succeeded in getting data[' + i + ']: ' + data[i]);
}
}, (err) => {
console.error(`Failed to transform rotationMatrix. Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
sensor.getQuaternion(rotationVector, function (err, data) {
if (err) {
console.error('Get quaternion failed. Error code: ' + err.code + '; message: ' + err.message);
return;
}
for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + data[i]);
}
})
} catch (err) {
console.error('Get quaternion failed. Error code: ' + err.code + '; message: ' + err.message);
let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
sensor.getQuaternion(rotationVector, function (err, data) {
if (err) {
console.error(`Failed to get quaternion. Code: ${err.code}, message: ${err.message}`);
return;
}
for (var i = 0; i < data.length; i++) {
console.info('Succeeded in getting data[' + i + ']: ' + data[i]);
}
})
} catch (error) {
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
**示例:**
```js
```ts
try {
let rotationVector = [0.20046076, 0.21907, 0.73978853, 0.60376877];
const promise = sensor.getQuaternion(rotationVector);
promise.then((data) => {
for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + data[i]);
console.info('Succeeded in getting data[' + i + ']: ' + data[i]);
}
}, (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) {
console.error('Get quaternion failed. Error code: ' + err.code + '; message: ' + err.message);
} catch (error) {
console.error(`Failed to get quaternion. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -3227,27 +3275,27 @@ getOrientation(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;A
**示例:**
```js
```ts
try {
let preRotationMatrix = [
1, 0, 0,
0, 0.87, -0.50,
0, 0.50, 0.87
];
sensor.getOrientation(preRotationMatrix, function (err, data) {
if (err) {
console.error('Get orientation failed. Error code: ' + err.code + '; message: ' + err.message);
return;
}
if (data.length < 3) {
console.error("Get orientation failed, length" + data.length);
}
console.info("Z: " + data[0]);
console.info("X: " + data[1]);
console.info("Y : " + data[2]);
})
} catch (err) {
console.error('Get orientation failed. Error code: ' + err.code + '; message: ' + err.message);
let preRotationMatrix = [
1, 0, 0,
0, 0.87, -0.50,
0, 0.50, 0.87
];
sensor.getOrientation(preRotationMatrix, function (err, data) {
if (err) {
console.error(`Failed to get orientation. Code: ${err.code}, message: ${err.message}`);
return;
}
if (data.length < 3) {
console.error("Failed to get orientation, length" + data.length);
}
console.info("Succeeded in getting data. Z: " + data[0]);
console.info("Succeeded in getting data. X: " + data[1]);
console.info("Succeeded in getting data. Y: " + data[2]);
})
} catch (error) {
console.error(`Failed to get orientation. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -3281,23 +3329,23 @@ getOrientation(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&
**示例:**
```js
```ts
try {
let preRotationMatrix = [
1, 0, 0,
0, 0.87, -0.50,
0, 0.50, 0.87
];
const promise = sensor.getOrientation(preRotationMatrix);
promise.then((data) => {
for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + data[i]);
}
}, (err) => {
console.error('getOrientation failed. Error code: ' + err.code + '; message: ' + err.message);
});
} catch (err) {
console.error('getOrientation failed. Error code: ' + err.code + '; message: ' + err.message);
let preRotationMatrix = [
1, 0, 0,
0, 0.87, -0.50,
0, 0.50, 0.87
];
const promise = sensor.getOrientation(preRotationMatrix);
promise.then((data) => {
for (var i = 0; i < data.length; i++) {
console.info('Succeeded in getting data[' + i + ']: ' + data[i]);
}
}, (err) => {
console.error(`Failed to getOrientatin. Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
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;
**示例:**
```js
```ts
try {
let gravity = [-0.27775216, 0.5351276, 9.788099];
let geomagnetic = [210.87253, -78.6096, -111.44444];
sensor.getRotationMatrix(gravity, geomagnetic, function (err, data) {
if (err) {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
return;
}
console.info('RotationMatrix' + JSON.stringify(data));
})
} catch (err) {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
let gravity = [-0.27775216, 0.5351276, 9.788099];
let geomagnetic = [210.87253, -78.6096, -111.44444];
sensor.getRotationMatrix(gravity, geomagnetic, function (err, data) {
if (err) {
console.error(`Failed to get rotationMatrix. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info('Succeeded in getting rotationMatrix' + JSON.stringify(data));
})
} catch (error) {
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;
**示例:**
```js
```ts
try {
let gravity = [-0.27775216, 0.5351276, 9.788099];
let geomagnetic = [210.87253, -78.6096, -111.44444];
const promise = sensor.getRotationMatrix(gravity, geomagnetic);
promise.then((data) => {
console.info('RotationMatrix' + JSON.stringify(data));
}, (err) => {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
});
} catch (err) {
console.error('Get rotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
let gravity = [-0.27775216, 0.5351276, 9.788099];
let geomagnetic = [210.87253, -78.6096, -111.44444];
const promise = sensor.getRotationMatrix(gravity, geomagnetic);
promise.then((data) => {
console.info('Succeeded in getting rotationMatrix' + JSON.stringify(data));
}, (err) => {
console.error(`Failed to get rotationMatrix. Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.getSensorList((err, data) => {
if (err) {
console.error('Get sensorList failed. Error code: ' + err.code + '; message: ' + err.message);
return;
}
for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + JSON.stringify(data[i]));
}
});
} catch (err) {
console.error('Get sensorList failed. Error code: ' + err.code + '; message: ' + err.message);
sensor.getSensorList((err, data) => {
if (err) {
console.error(`Failed to get sensorList. Code: ${err.code}, message: ${err.message}`);
return;
}
for (var i = 0; i < data.length; i++) {
console.info('Succeeded in getting data[' + i + ']: ' + JSON.stringify(data[i]));
}
});
} catch (error) {
console.error(`Failed to get sensorList. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -3453,17 +3501,17 @@ try {
**示例:**
```js
```ts
try {
sensor.getSensorList().then((data) => {
for (var i = 0; i < data.length; i++) {
console.info('data[' + i + ']: ' + JSON.stringify(data[i]));
}
}, (err) => {
console.error('Get sensorList failed. Error code: ' + err.code + '; message: ' + err.message);
});
} catch (err) {
console.error('Get sensorList failed. Error code: ' + err.code + '; message: ' + err.message);
sensor.getSensorList().then((data) => {
for (var i = 0; i < data.length; i++) {
console.info('Succeeded in getting data[' + i + ']: ' + JSON.stringify(data[i]));
}
}, (err) => {
console.error(`Failed to get sensorList. Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
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
**示例:**
```js
```ts
try {
sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER, (err, data) => {
if (err) {
console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message);
return;
}
console.info('Sensor: ' + JSON.stringify(data));
});
} catch (err) {
console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message);
sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER, (err, data) => {
if (err) {
console.error(`Failed to get singleSensor. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info('Succeeded in getting sensor: ' + JSON.stringify(data));
});
} catch (error) {
console.error(`Failed to get singleSensor. Code: ${error.code}, message: ${error.message}`);
}
```
......@@ -3536,15 +3584,15 @@ try {
**示例:**
```js
```ts
try {
sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER).then((data) => {
console.info('Sensor: ' + JSON.stringify(data));
}, (err) => {
console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message);
});
} catch (err) {
console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message);
sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER).then((data) => {
console.info('Succeeded in getting sensor: ' + JSON.stringify(data));
}, (err) => {
console.error(`Failed to get singleSensor . Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
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
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
},
{ interval: 100000000 }
);
```
### LINEAR_ACCELERATION<sup>(deprecated)</sup>
......@@ -4084,18 +4132,19 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking on. X-coordinate bias: ' + data.biasX);
console.info('Succeeded in invoking on. Y-coordinate bias: ' + data.biasY);
console.info('Succeeded in invoking on. Z-coordinate bias: ' + data.biasZ);
},
{ interval: 100000000 }
);
```
### GRAVITY<sup>(deprecated)</sup>
......@@ -4117,15 +4166,15 @@ on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespons
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
},
{ interval: 100000000 }
);
```
### GYROSCOPE<sup>(deprecated)</sup>
......@@ -4148,15 +4197,16 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeRes
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
},
{ interval: 100000000 }
);
```
### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup>
......@@ -4179,18 +4229,19 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback&lt;G
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking on. X-coordinate bias: ' + data.biasX);
console.info('Succeeded in invoking on. Y-coordinate bias: ' + data.biasY);
console.info('Succeeded in invoking on. Z-coordinate bias: ' + data.biasZ);
},
{ interval: 100000000 }
);
```
### SIGNIFICANT_MOTION<sup>(deprecated)</sup>
......@@ -4211,13 +4262,14 @@ on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback&lt;Sig
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){
console.info('Scalar data: ' + data.scalar);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function (data) {
console.info('Succeeded in invoking on. Scalar data: ' + data.scalar);
},
{ interval: 100000000 }
);
```
### PEDOMETER_DETECTION<sup>(deprecated)</sup>
......@@ -4240,13 +4292,14 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback&lt;Pe
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){
console.info('Scalar data: ' + data.scalar);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function (data) {
console.info('Succeeded in invoking on. Scalar data: ' + data.scalar);
},
{ interval: 100000000 }
);
```
### PEDOMETER<sup>(deprecated)</sup>
......@@ -4269,13 +4322,14 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerRes
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){
console.info('Steps: ' + data.steps);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function (data) {
console.info('Succeeded in invoking on. Steps: ' + data.steps);
},
{ interval: 100000000 }
);
```
### AMBIENT_TEMPERATURE<sup>(deprecated)</sup>
......@@ -4297,13 +4351,13 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback&lt;Ambi
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){
console.info('Temperature: ' + data.temperature);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function (data) {
console.info('Succeeded in invoking on. Temperature: ' + data.temperature);
},
{ interval: 100000000 }
);
```
### MAGNETIC_FIELD<sup>(deprecated)</sup>
......@@ -4325,15 +4379,15 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magneti
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
},
{ interval: 100000000 }
);
```
### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup>
......@@ -4354,18 +4408,19 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callbac
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking on. X-coordinate bias: ' + data.biasX);
console.info('Succeeded in invoking on. Y-coordinate bias: ' + data.biasY);
console.info('Succeeded in invoking on. Z-coordinate bias: ' + data.biasZ);
},
{ interval: 100000000 }
);
```
### PROXIMITY<sup>(deprecated)</sup>
......@@ -4386,13 +4441,14 @@ on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityRes
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){
console.info('Distance: ' + data.distance);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function (data) {
console.info('Succeeded in invoking on. Distance: ' + data.distance);
},
{ interval: 100000000 }
);
```
### HUMIDITY<sup>(deprecated)</sup>
......@@ -4414,13 +4470,13 @@ on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRespo
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){
console.info('Humidity: ' + data.humidity);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function (data) {
console.info('Succeeded in invoking on. Humidity: ' + data.humidity);
},
{ interval: 100000000 }
);
```
### BAROMETER<sup>(deprecated)</sup>
......@@ -4442,13 +4498,13 @@ on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerRes
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){
console.info('Atmospheric pressure: ' + data.pressure);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function (data) {
console.info('Succeeded in invoking on. Atmospheric pressure: ' + data.pressure);
},
{ interval: 100000000 }
);
```
### HALL<sup>(deprecated)</sup>
......@@ -4469,13 +4525,14 @@ on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;,
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){
console.info('Status: ' + data.status);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, function (data) {
console.info('Succeeded in invoking on. Status: ' + data.status);
},
{ interval: 100000000 }
);
```
### AMBIENT_LIGHT<sup>(deprecated)</sup>
......@@ -4497,13 +4554,13 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightRes
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){
console.info(' Illumination: ' + data.intensity);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function (data) {
console.info('Succeeded in invoking on. Illumination: ' + data.intensity);
},
{ interval: 100000000 }
);
```
### ORIENTATION<sup>(deprecated)</sup>
......@@ -4524,15 +4581,16 @@ on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientatio
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){
console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function (data) {
console.info('Succeeded in the device rotating at an angle around the X axis: ' + data.beta);
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 }
);
```
### HEART_RATE<sup>(deprecated)</sup>
......@@ -4573,16 +4631,17 @@ on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback&lt;Rotatio
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('Scalar quantity: ' + data.w);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function (data) {
console.info('Succeeded in invoking on. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking on. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking on. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking on. Scalar quantity: ' + data.w);
},
{ interval: 100000000 }
);
```
### WEAR_DETECTION<sup>(deprecated)</sup>
......@@ -4603,13 +4662,14 @@ on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDet
| options | [Options](#options) | 否 | 可选参数列表,用于设置传感器上报频率,默认值为200000000ns。 |
**示例:**
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){
console.info('Wear status: ' + data.value);
},
{interval: 100000000}
);
```
```ts
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function (data) {
console.info('Succeeded in invoking on. Wear status: ' + data.value);
},
{ interval: 100000000 }
);
```
## sensor.once<sup>(deprecated)</sup>
......@@ -4633,14 +4693,14 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Accele
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
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>
......@@ -4681,17 +4741,17 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callba
| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | 是 | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 |
**示例:**
```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking once. X-coordinate bias: ' + data.biasX);
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>
......@@ -4711,14 +4771,14 @@ once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespo
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
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>
......@@ -4740,14 +4800,14 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeR
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
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>
......@@ -4769,17 +4829,16 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&l
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking once. X-coordinate bias: ' + data.biasX);
console.info('Succeeded in invoking once. Y-coordinate bias: ' + data.biasY);
console.info('Succeeded in invoking once. Z-coordinate bias: ' + data.biasZ);
});
```
### SIGNIFICANT_MOTION<sup>(deprecated)</sup>
......@@ -4799,12 +4858,12 @@ once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback&lt;Si
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) {
console.info('Scalar data: ' + data.scalar);
}
);
```
```ts
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>
......@@ -4826,12 +4885,12 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback&lt;P
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) {
console.info('Scalar data: ' + data.scalar);
}
);
```
```ts
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>
......@@ -4853,12 +4912,12 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerR
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) {
console.info('Steps: ' + data.steps);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function (data) {
console.info('Succeeded in invoking once. Steps: ' + data.steps);
});
```
### AMBIENT_TEMPERATURE<sup>(deprecated)</sup>
......@@ -4878,12 +4937,12 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback&lt;A
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) {
console.info('Temperature: ' + data.temperature);
}
);
```
```ts
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>
......@@ -4903,14 +4962,14 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magne
| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
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>
......@@ -4930,17 +4989,17 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callb
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking once. X-coordinate bias: ' + data.biasX);
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>
......@@ -4960,12 +5019,13 @@ once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityR
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(data) {
console.info('Distance: ' + data.distance);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function (data) {
console.info('Succeeded in invoking once. Distance: ' + data.distance);
}
);
```
### HUMIDITY<sup>(deprecated)</sup>
......@@ -4985,12 +5045,12 @@ once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRes
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) {
console.info('Humidity: ' + data.humidity);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function (data) {
console.info('Succeeded in invoking once. Humidity: ' + data.humidity);
});
```
### BAROMETER<sup>(deprecated)</sup>
......@@ -5010,12 +5070,12 @@ once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerR
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) {
console.info('Atmospheric pressure: ' + data.pressure);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function (data) {
console.info('Succeeded in invoking once. Atmospheric pressure: ' + data.pressure);
});
```
### HALL<sup>(deprecated)</sup>
......@@ -5035,12 +5095,12 @@ once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) {
console.info('Status: ' + data.status);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function (data) {
console.info('Succeeded in invoking once. Status: ' + data.status);
});
```
### AMBIENT_LIGHT<sup>(deprecated)</sup>
......@@ -5061,12 +5121,11 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightR
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) {
console.info(' Illumination: ' + data.intensity);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function (data) {
console.info('Succeeded in invoking once. invoking once. Illumination: ' + data.intensity);
});
```
### ORIENTATION<sup>(deprecated)</sup>
......@@ -5086,14 +5145,14 @@ once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientat
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function (data) {
console.info('Succeeded in invoking the device rotateing at an angle around the X axis: ' + data.beta);
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>
......@@ -5113,15 +5172,15 @@ once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback&lt;Rota
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('Scalar quantity: ' + data.w);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function (data) {
console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
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>
......@@ -5160,12 +5219,11 @@ once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearD
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |
**示例:**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) {
console.info("Wear status: "+ data.value);
}
);
```
```ts
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function (data) {
console.info("Succeeded in invoking once. Wear status: " + data.value);
});
```
## sensor.off<sup>(deprecated)</sup>
......@@ -5190,12 +5248,13 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback&lt;Accele
**示例:**
```js
```ts
function callback(data) {
console.info('x-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback);
```
......@@ -5220,15 +5279,16 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callb
**示例:**
```js
```ts
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking off. X-coordinate bias: ' + data.biasX);
console.info('Succeeded in invoking off. Y-coordinate bias: ' + data.biasY);
console.info('Succeeded in invoking off. Z-coordinate bias: ' + data.biasZ);
}
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
**示例:**
```js
```ts
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);
```
......@@ -5277,10 +5338,11 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback&lt;
**示例:**
```js
```ts
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);
```
......@@ -5303,10 +5365,11 @@ off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback&lt;BarometerR
**示例:**
```js
```ts
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);
```
......@@ -5329,13 +5392,14 @@ off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback&lt;GravityRespo
**示例:**
```js
```ts
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
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>
......@@ -5359,12 +5423,13 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback&lt;GyroscopeR
**示例:**
```js
```ts
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback);
```
......@@ -5389,12 +5454,13 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback&
**示例:**
```js
```ts
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
}
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
**示例:**
```js
```ts
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);
```
......@@ -5462,10 +5529,11 @@ off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityRes
**示例:**
```js
```ts
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);
```
......@@ -5507,12 +5575,13 @@ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback&lt;
**示例:**
```js
```ts
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
}
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) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking off. X-coordinate bias: ' + data.biasX);
console.info('Succeeded in invoking off. Y-coordinate bias: ' + data.biasY);
console.info('Succeeded in invoking off. Z-coordinate bias: ' + data.biasZ);
}
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
**示例:**
```js
```ts
function callback(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the 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 X axis: ' + data.beta);
console.info('Succeeded in invoking off. 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 Z axis: ' + data.alpha);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback);
```
......@@ -5596,10 +5667,11 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerR
**示例:**
```js
```ts
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);
```
......@@ -5624,10 +5696,11 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback&lt;
**示例:**
```js
```ts
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);
```
......@@ -5650,10 +5723,11 @@ off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback&lt;ProximityR
**示例:**
```js
```ts
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);
```
......@@ -5676,13 +5750,14 @@ off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback&lt;Rota
**示例:**
```js
```ts
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
console.info('Scalar quantity: ' + data.w);
console.info('Succeeded in invoking off. X-coordinate component: ' + data.x);
console.info('Succeeded in invoking off. Y-coordinate component: ' + data.y);
console.info('Succeeded in invoking off. Z-coordinate component: ' + data.z);
console.info('Succeeded in invoking off. Scalar quantity: ' + data.w);
}
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
**示例:**
```js
```ts
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);
```
......@@ -5731,10 +5807,11 @@ off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback&lt;WearD
**示例:**
```js
```ts
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);
```
......@@ -5758,17 +5835,17 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co
**示例:**
```js
sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}, function(err, data) {
if (err) {
console.error("Operation failed. Error code: " + err.code + ", message: " + err.message);
return;
}
console.info("Operation succeeded. Data obtained: " + data);
for (var i=0; i < data.length; i++) {
console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
}
})
```ts
sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], { x: 2, y: 3 }, function (err, data) {
if (err) {
console.error(`Failed to operate. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info("Succeeded in starting Operation. Data obtained: " + data);
for (var i = 0; i < data.length; i++) {
console.info("Succeeded in getting transformCoordinateSystem data[ " + i + "] = " + data[i]);
}
})
```
## sensor.transformCoordinateSystem<sup>(deprecated)</sup>
......@@ -5795,15 +5872,15 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co
**示例:**
```js
const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3});
promise.then((data) => {
console.info("Operation succeeded.");
for (var i=0; i < data.length; i++) {
console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
}
}).catch((err) => {
console.info("Operation failed");
```ts
const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], { x: 2, y: 3 });
promise.then((data) => {
console.info("Succeeded in starting Operation");
for (var i = 0; i < data.length; i++) {
console.info("Succeeded in getting transformCoordinateSystem data[ " + i + "] = " + data[i]);
}
}).catch((err) => {
console.error(`Failed to operate.`);
})
```
......@@ -5826,15 +5903,16 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callba
| callback | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 是 | 返回磁场信息。 |
**示例:**
```js
sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000, function(err, data) {
if (err) {
console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message);
return;
}
console.info('sensor_getGeomagneticField_callback x: ' + data.x + ',y: ' + data.y + ',z: ' +
data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
```ts
sensor.getGeomagneticField({ latitude: 80, longitude: 0, altitude: 0 }, 1580486400000, function (err, data) {
if (err) {
console.error(`Failed to operate. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info('Succeeded in getting sensor_getGeomagneticField_callback x: ' + data.x + ',y: ' + data.y + ',z: ' +
data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
});
```
## sensor.getGeomagneticField<sup>(deprecated)</sup>
......@@ -5860,16 +5938,17 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promi
| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 返回磁场信息。 |
**示例:**
```js
const promise = sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000);
promise.then((data) => {
console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' +
data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
}).catch((reason) => {
console.info('Operation failed.');
})
```
```ts
const promise = sensor.getGeomagneticField({ latitude: 80, longitude: 0, altitude: 0 }, 1580486400000);
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 +
',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
}).catch((reason) => {
console.error(`Failed to operate.`);
})
```
## sensor.getAltitude<sup>(deprecated)</sup>
......@@ -5891,16 +5970,15 @@ getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallbac
**示例:**
```js
sensor.getAltitude(0, 200, function(err, data) {
if (err) {
console.error(
"Operation failed. Error code: " + err.code + ", message: " + err.message);
return;
}
console.info("Succeeded to get getAltitude interface get data: " + data);
});
```
```ts
sensor.getAltitude(0, 200, function (err, data) {
if (err) {
console.error(`Failed to operate. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info("Succeeded in getting getAltitude interface get data: " + data);
});
```
## sensor.getAltitude<sup>(deprecated)</sup>
......@@ -5927,14 +6005,14 @@ getAltitude(seaPressure: number, currentPressure: number): Promise&lt;number&gt;
**示例:**
```js
const promise = sensor.getAltitude(0, 200);
promise.then((data) => {
console.info(' sensor_getAltitude_Promise success', data);
}).catch((err) => {
console.error("Operation failed");
})
```
```ts
const promise = sensor.getAltitude(0, 200);
promise.then((data) => {
console.info('Succeeded in getting sensor_getAltitude_Promise success', data);
}).catch((err) => {
console.error(`Failed to operate.`);
})
```
## sensor.getGeomagneticDip<sup>(deprecated)</sup>
......@@ -5956,16 +6034,15 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallbac
**示例:**
```js
sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
if (err) {
console.error('SensorJsAPI--->Failed to register data, error code is:' + err.code + ', message: ' +
err.message);
return;
}
console.info("Succeeded to get getGeomagneticDip interface get data: " + data);
})
```
```ts
sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function (err, data) {
if (err) {
console.error(`Failed to register data. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info("Succeeded in getting getGeomagneticDip interface get data: " + data);
})
```
## sensor.getGeomagneticDip<sup>(deprecated)</sup>
......@@ -5991,14 +6068,14 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;): Promise&lt;number&gt;
**示例:**
```js
const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => {
console.info('getGeomagneticDip_promise succeeded', data);
}).catch((err) => {
console.error("Operation failed");
})
```
```ts
const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => {
console.info('Succeeded in get GeomagneticDip_promise', data);
}).catch((err) => {
console.error(`Failed to operate.`);
})
```
## sensor. getAngleModify<sup>(deprecated)</sup>
......@@ -6020,19 +6097,17 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar
**示例:**
```js
sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) {
if (err) {
console.error('Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
for (var i=0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]);
}
})
```
```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) {
if (err) {
console.error(`Failed to register data. Code: ${err.code}, message: ${err.message}`);
return;
}
for (var i = 0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]);
}
})
```
## sensor. getAngleModify<sup>(deprecated)</sup>
......@@ -6059,18 +6134,17 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar
**示例:**
```js
const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]);
promise.then((data) => {
console.info('getAngleModify_promise success');
for (var i=0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]);
}
}).catch((reason) => {
console.info("promise::catch", reason);
})
```
```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]);
promise.then((data) => {
console.info('Succeeded in getting AngleModify_promise.');
for (var i = 0; i < data.length; i++) {
console.info("Succeeded in getting data[" + i + "]: " + data[i]);
}
}).catch((reason) => {
console.info("Succeeded in getting promise::catch", reason);
})
```
## sensor.createRotationMatrix<sup>(deprecated)</sup>
......@@ -6091,19 +6165,17 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallbac
**示例:**
```js
sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
if (err) {
console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
for (var i=0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]);
}
})
```
```ts
sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function (err, data) {
if (err) {
console.error(`Failed to register data. Code: ${err.code}, message: ${err.message}`);
return;
}
for (var i = 0; i < data.length; i++) {
console.info("Succeeded in getting data[" + i + "]: " + data[i]);
}
})
```
## sensor.createRotationMatrix<sup>(deprecated)</sup>
......@@ -6129,18 +6201,17 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;n
**示例:**
```js
const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => {
console.info('createRotationMatrix_promise success');
for (var i=0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]);
}
}).catch((reason) => {
console.info("promise::catch", reason);
})
```
```ts
const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => {
console.info('Succeeded in getting createRotationMatrix_promise');
for (var i = 0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]);
}
}).catch((reason) => {
console.info("Succeeded in getting promise::catch", reason);
})
```
## sensor.createQuaternion<sup>(deprecated)</sup>
......@@ -6161,19 +6232,17 @@ createQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt
**示例:**
```js
sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
if (err) {
console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
for (var i=0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]);
}
})
```
```ts
sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function (err, data) {
if (err) {
console.error(`Failed to register data. Code: ${err.code}, message: ${err.message}`);
return;
}
for (var i = 0; i < data.length; i++) {
console.info("Succeeded in getting data[" + i + "]: " + data[i]);
}
})
```
## sensor.createQuaternion<sup>(deprecated)</sup>
......@@ -6199,18 +6268,17 @@ createQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;numbe
**示例:**
```js
const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => {
console.info('createQuaternion_promise succeeded');
for (var i=0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]);
}
}).catch((err) => {
console.info('promise failed');
})
```
```ts
const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => {
console.info('Succeeded in getting createQuaternion_promise');
for (var i = 0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]);
}
}).catch((err) => {
console.info(`Failed to get promise.`);
})
```
## sensor.getDirection<sup>(deprecated)</sup>
......@@ -6231,20 +6299,18 @@ getDirection(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Arr
**示例:**
```js
sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
if (err) {
console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
console.info("SensorJsAPI--->Succeeded to get getDirection interface get data: " + data);
for (var i = 1; i < data.length; i++) {
console.info("sensor_getDirection_callback" + data[i]);
}
})
```
```ts
sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function (err, data) {
if (err) {
console.error(`Failed to register data. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info("Succeeded in getting getDirection interface get data: " + data);
for (var i = 1; i < data.length; i++) {
console.info("Succeeded in getting sensor_getDirection_callback" + data[i]);
}
})
```
## sensor.getDirection<sup>(deprecated)</sup>
......@@ -6270,18 +6336,17 @@ getDirection(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt
**示例:**
```js
const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => {
console.info('sensor_getAltitude_Promise success', data);
for (var i = 1; i < data.length; i++) {
console.info("sensor_getDirection_promise" + data[i]);
}
}).catch((err) => {
console.info('promise failed');
})
```
```ts
const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => {
console.info('Succeeded in getting sensor_getAltitude_Promise', data);
for (var i = 1; i < data.length; i++) {
console.info("Succeeded in getting sensor_getDirection_promise" + data[i]);
}
}).catch((err) => {
console.info(`Failed to get promise.`);
})
```
## sensor.createRotationMatrix<sup>(deprecated)</sup>
......@@ -6303,16 +6368,15 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&
**示例:**
```js
sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) {
if (err) {
console.error('error code is: ' + err.code + ', message: ' + err.message);
return;
}
console.info(JSON.stringify(data));
})
```
```ts
sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function (err, data) {
if (err) {
console.error(`Failed to get create rotationMatrix. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info(JSON.stringify(data));
})
```
## sensor.createRotationMatrix<sup>(deprecated)</sup>
......@@ -6339,11 +6403,11 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&
**示例:**
```js
const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]);
promise.then((data) => {
console.info(JSON.stringify(data));
}).catch((err) => {
console.info('promise failed');
})
```
```ts
const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]);
promise.then((data) => {
console.info(JSON.stringify(data));
}).catch((err) => {
console.info(`Failed to get promise.`);
})
```
......@@ -615,7 +615,7 @@ hasSimCard\(slotId: number, callback: AsyncCallback\<boolean\>\): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | -------------------------------------- |
| 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';
**示例:**
```js
```ts
sensor.subscribeAccelerometer({
interval: 'normal',
success: function(ret) {
console.log('X-axis data: ' + ret.x);
console.log('Y-axis data: ' + ret.y);
console.log('Z-axis data: ' + ret.z);
success: function (ret) {
console.info('Succeeded in subscribing. X-axis data: ' + ret.x);
console.info('Succeeded in subscribing. Y-axis data: ' + ret.y);
console.info('Succeeded in subscribing. Z-axis data: ' + ret.z);
},
fail: function(data, code) {
console.error('Subscription failed. Code: ' + code + '; Data: ' + data);
fail: function (data, code) {
console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
},
});
```
......@@ -66,7 +66,7 @@ unsubscribeAccelerometer(): void
**示例:**
```js
```ts
sensor.unsubscribeAccelerometer();
```
......@@ -86,13 +86,13 @@ sensor.unsubscribeAccelerometer();
**示例:**
```js
```ts
sensor.subscribeCompass({
success: function(ret) {
console.log('Get data direction:' + ret.direction);
success: function (ret) {
console.info('Succeeded in subscribing. Get data direction:' + ret.direction);
},
fail: function(data, code) {
console.error('Subscription failed. Code: ' + code + '; Data: ' + data);
fail: function (data, code) {
console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
},
});
```
......@@ -110,7 +110,7 @@ unsubscribeCompass(): void
**示例:**
```js
```ts
sensor.unsubscribeCompass();
```
......@@ -130,13 +130,14 @@ sensor.unsubscribeCompass();
**示例:**
```js
```ts
sensor.subscribeProximity({
success: function(ret) {
console.log('Get data distance:' + ret.distance);
success: function (ret) {
console.info('Succeeded in subscribing. Get data distance:' + ret.distance);
},
fail: function(data, code) {
console.error('Subscription failed. Code: ' + code + '; Data: ' + data);
fail: function (data, code) {
console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
},
});
```
......@@ -154,7 +155,7 @@ unsubscribeProximity(): void
**示例:**
```js
```ts
sensor.unsubscribeProximity();
```
......@@ -174,13 +175,13 @@ sensor.unsubscribeProximity();
**示例:**
```js
```ts
sensor.subscribeLight({
success: function(ret) {
console.log('Get data intensity:' + ret.intensity);
success: function (ret) {
console.info('Succeeded in subscribing. Get data intensity:' + ret.intensity);
},
fail: function(data, code) {
console.error('Subscription failed. Code: ' + code + '; Data: ' + data);
fail: function (data, code) {
console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
},
});
```
......@@ -198,7 +199,7 @@ unsubscribeLight(): void
**示例:**
```js
```ts
sensor.unsubscribeLight();
```
......@@ -220,13 +221,13 @@ sensor.unsubscribeLight();
**示例:**
```js
```ts
sensor.subscribeStepCounter({
success: function(ret) {
console.log('Get step value:' + ret.steps);
success: function (ret) {
console.info('Succeeded in subscribing. Get step value:' + ret.steps);
},
fail: function(data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data);
fail: function (data, code) {
console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
},
});
```
......@@ -246,7 +247,7 @@ unsubscribeStepCounter(): void
**示例:**
```js
```ts
sensor.unsubscribeStepCounter();
```
......@@ -267,13 +268,13 @@ subscribeBarometer(options: SubscribeBarometerOptions): void
**示例:**
```js
```ts
sensor.subscribeBarometer({
success: function(ret) {
console.log('Get data value:' + ret.pressure);
success: function (ret) {
console.info('Succeeded in subscribing. Get data value:' + ret.pressure);
},
fail: function(data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data);
fail: function (data, code) {
console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
},
});
```
......@@ -292,7 +293,7 @@ unsubscribeBarometer(): void
**示例:**
```js
```ts
sensor.unsubscribeBarometer();
```
......@@ -315,13 +316,13 @@ sensor.unsubscribeBarometer();
**示例:**
```js
```ts
sensor.subscribeHeartRate({
success: function(ret) {
console.log('Get heartrate value:' + ret.heartRate);
success: function (ret) {
console.info('Succeeded in subscribing. Get heartrate value:' + ret.heartRate);
},
fail: function(data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data);
fail: function (data, code) {
console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
},
});
```
......@@ -342,7 +343,7 @@ unsubscribeHeartRate(): void
**示例:**
```js
```ts
sensor.unsubscribeHeartRate();
```
......@@ -362,13 +363,13 @@ sensor.unsubscribeHeartRate();
**示例:**
```js
```ts
sensor.subscribeOnBodyState({
success: function(ret) {
console.log('Get on-body state value:' + ret.value);
success: function (ret) {
console.info('Succeeded in subscribing. Get on-body state value:' + ret.value);
},
fail: function(data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data);
fail: function (data, code) {
console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
},
});
```
......@@ -386,7 +387,7 @@ unsubscribeOnBodyState(): void
**示例:**
```js
```ts
sensor.unsubscribeOnBodyState();
```
......@@ -406,13 +407,13 @@ sensor.unsubscribeOnBodyState();
**示例:**
```js
```ts
sensor.getOnBodyState({
success: function(ret) {
console.log('On body state: ' + ret.value);
success: function (ret) {
console.info('Succeeded in subscribing. On body state: ' + ret.value);
},
fail: function(data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data);
fail: function (data, code) {
console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
},
});
```
......@@ -435,17 +436,17 @@ sensor.getOnBodyState({
**示例:**
```js
```ts
sensor.subscribeDeviceOrientation({
interval: 'normal',
success: function(ret) {
console.log('Alpha data: ' + ret.alpha);
console.log('Beta data: ' + ret.beta);
console.log('Gamma data: ' + ret.gamma);
success: function (ret) {
console.info('Succeeded in subscribing. Alpha data: ' + ret.alpha);
console.info('Succeeded in subscribing. Beta data: ' + ret.beta);
console.info('Succeeded in subscribing. Gamma data: ' + ret.gamma);
},
fail: function(data, code) {
console.error('Subscription failed. Code: ' + code + '; Data: ' + data);
}
fail: function (data, code) {
console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
}
});
```
......@@ -462,7 +463,7 @@ unsubscribeDeviceOrientation(): void
**示例:**
```js
```ts
sensor.unsubscribeDeviceOrientation();
```
......@@ -486,16 +487,16 @@ sensor.unsubscribeDeviceOrientation();
**示例:**
```js
```ts
sensor.subscribeGyroscope({
interval: 'normal',
success: function(ret) {
console.log('X-axis data: ' + ret.x);
console.log('Y-axis data: ' + ret.y);
console.log('Z-axis data: ' + ret.z);
success: function (ret) {
console.info('Succeeded in subscribing. X-axis data: ' + ret.x);
console.info('Succeeded in subscribing. Y-axis data: ' + ret.y);
console.info('Succeeded in subscribing. Z-axis data: ' + ret.z);
},
fail: function(data, code) {
console.error('Subscription failed. Code: ' + code + '; data: ' + data);
fail: function (data, code) {
console.error(`Failed to subscription. Code: ${code}, data: ${data}`);
}
});
```
......@@ -515,7 +516,7 @@ unsubscribeGyroscope(): void
**示例:**
```js
```ts
sensor.unsubscribeGyroscope();
```
......
......@@ -36,17 +36,17 @@ import vibrator from '@system.vibrator';
**示例:**
```js
```ts
vibrator.vibrate({
mode: 'short',
success: function() {
console.log('vibrate is successful');
console.info('Succeed in vibrating');
},
fail: function(data, code) {
console.log("vibrate is failed, data: " + data + ", code: " + code);
console.info(`Failed to vibrate. Data: ${data}, code: ${code}`);
},
complete: function() {
console.log('vibrate is completed');
console.info('completed in vibrating');
}
});
```
......
......@@ -2080,7 +2080,7 @@ let result = that.encodeSync(array);
### encodeToStringSync<sup>9+</sup>
encodeToStringSync(src: Uint8Array): string
encodeToStringSync(src: Uint8Array, options?: Type): string
通过输入参数编码后输出对应文本。
......@@ -2091,6 +2091,7 @@ encodeToStringSync(src: Uint8Array): string
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------- | ---- | ------------------- |
| 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
```js
let that = new util.Base64Helper();
let array = new Uint8Array([115,49,51]);
let result = that.encodeToStringSync(array);
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, util.Type.MIME);
```
### 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
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------------ | ---- | ----------------------------- |
| 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
```js
let that = new util.Base64Helper();
let buff = 'czEz';
let result = that.decodeSync(buff);
let buff = 'TWFuaXNkaXN0aW5ndWlzaGVkbm90b25seWJ5aGlzcmVhc29uYnV0Ynl0aGlzc2luZ3VsYXJwYXNz\r\naW9uZnJvbW90aGVyYW5pbWFsc3doaWNoaXNhbHVzdG9mdGhlbWluZGV4Y2VlZHN0aGVzaG9ydHZl\r\naGVtZW5jZW9mYW55Y2FybmFscGxlYXN1cmU=\r\n';
let result = that.decodeSync(buff, util.Type.MIME);
```
......@@ -2172,7 +2174,7 @@ that.encode(array).then(val=>{
### 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;
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------- | ---- | ----------------------- |
| 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;
```js
let that = new util.Base64Helper();
let array = new Uint8Array([115,49,51]);
that.encodeToString(array).then(val=>{
console.log(val)
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, util.Type.MIME).then(val=>{
// 根据开发者需求进行添加。
})
```
### 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;
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------------ | ---- | --------------------------------- |
| 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;
```js
let that = new util.Base64Helper();
let array = new Uint8Array([99,122,69,122]);
let rarray = new Uint8Array([115,49,51]);
that.decode(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
console.log(val[i].toString())
}
let array = 'TWFuaXNkaXN0aW5ndWlzaGVkbm90b25seWJ5aGlzcmVhc29uYnV0Ynl0aGlzc2luZ3VsYXJwYXNz\r\naW9uZnJvbW90aGVyYW5pbWFsc3doaWNoaXNhbHVzdG9mdGhlbWluZGV4Y2VlZHN0aGVzaG9ydHZl\r\naGVtZW5jZW9mYW55Y2FybmFscGxlYXN1cmU=\r\n';
that.decode(array, util.Type.MIME).then(val=>{
// 根据开发者需求进行添加。
})
```
## Type<sup>10+</sup>
Base64编码格式枚举。
**系统能力:** SystemCapability.Utils.Lang
| 名称 | 值 | 说明 |
| -------- | ------------------------ | ---------------- |
| BASIC | 0 | 表示BASIC编码格式 |
| MIME | 1 | 表示MIME编码格式。 |
## types<sup>8+</sup>
types为不同类型的内置对象提供类型检查,可以避免由于类型错误导致的异常或崩溃。该模块包含了多个工具函数,用于判断JS对象是否属于各种类型例如:ArrayBuffer、Map、Set等。
......
......@@ -9,7 +9,7 @@ vibrator模块提供控制马达振动启、停的能力。
## 导入模块
```js
```ts
import vibrator from '@ohos.vibrator';
```
......@@ -41,24 +41,25 @@ startVibration(effect: VibrateEffect, attribute: VibrateAttribute, callback: Asy
示例:
```js
```ts
import vibrator from '@ohos.vibrator';
try {
vibrator.startVibration({
type: 'time',
duration: 1000,
}, {
id: 0,
usage: 'alarm'
}, (error) => {
if (error) {
console.error('Vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message);
return;
}
console.log('Callback returned to indicate a successful vibration.');
});
vibrator.startVibration({
type: 'time',
duration: 1000,
}, {
id: 0,
usage: 'alarm'
}, (error) => {
if (error) {
console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
return;
}
console.info('Succeed in starting vibration');
});
} catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
console.error(`An unexpected error occurred. Code: ${err.code}, message: ${err.message}`);
}
```
......@@ -95,24 +96,25 @@ startVibration(effect: VibrateEffect, attribute: VibrateAttribute): Promise&lt;v
**示例:**
```js
```ts
import vibrator from '@ohos.vibrator';
try {
vibrator.startVibration({
type: 'time',
duration: 1000
}, {
id: 0,
usage: 'alarm'
}).then(() => {
console.log('Promise returned to indicate a successful vibration');
}, (error) => {
console.error('error.code' + error.code + 'error.message' + error.message);
});
vibrator.startVibration({
type: 'time',
duration: 1000
}, {
id: 0,
usage: 'alarm'
}).then(() => {
console.info('Succeed in starting vibration');
}, (error) => {
console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
});
} 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>
......@@ -133,40 +135,41 @@ stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback&lt;void&gt;):
**示例:**
```js
```ts
import vibrator from '@ohos.vibrator';
try {
// 按照固定时长振动
vibrator.startVibration({
type: 'time',
duration: 1000,
}, {
id: 0,
usage: 'alarm'
}, (error) => {
if (error) {
console.error('Vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message);
return;
}
console.log('Callback returned to indicate a successful vibration.');
});
// 按照固定时长振动
vibrator.startVibration({
type: 'time',
duration: 1000,
}, {
id: 0,
usage: 'alarm'
}, (error) => {
if (error) {
console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
return;
}
console.info('Succeed in starting vibration');
});
} catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
console.error(`An unexpected error occurred. Code: ${err.code}, message: ${err.message}`);
}
try {
// 按照VIBRATOR_STOP_MODE_TIME模式停止振动
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
return;
}
console.log('Callback returned to indicate successful.');
})
// 按照VIBRATOR_STOP_MODE_TIME模式停止振动
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) {
if (error) {
console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
return;
}
console.info('Succeed in stopping vibration');
})
} 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>
......@@ -192,36 +195,37 @@ stopVibration(stopMode: VibratorStopMode): Promise&lt;void&gt;
**示例:**
```js
```ts
import vibrator from '@ohos.vibrator';
try {
// 按照固定时长振动
vibrator.startVibration({
type: 'time',
duration: 1000
}, {
id: 0,
usage: 'alarm'
}).then(() => {
console.log('Promise returned to indicate a successful vibration');
}, (error) => {
console.error('error.code' + error.code + 'error.message' + error.message);
});
// 按照固定时长振动
vibrator.startVibration({
type: 'time',
duration: 1000
}, {
id: 0,
usage: 'alarm'
}).then(() => {
console.info('Succeed in starting vibration');
}, (error) => {
console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
});
} catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
console.error(`An unexpected error occurred. Code: ${err.code}, message: ${err.message}`);
}
try {
// 按照VIBRATOR_STOP_MODE_TIME模式停止振动
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(() => {
console.log('Promise returned to indicate a successful vibration.');
}, (error) => {
console.log('error.code' + error.code + 'error.message' + error.message);
});
// 按照VIBRATOR_STOP_MODE_TIME模式停止振动
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(() => {
console.info('Succeed in stopping vibration');
}, (error) => {
console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
});
} 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>
......@@ -241,40 +245,41 @@ stopVibration(callback: AsyncCallback&lt;void&gt;): void
**示例:**
```js
```ts
import vibrator from '@ohos.vibrator';
try {
// 按照固定时长振动
vibrator.startVibration({
type: 'time',
duration: 1000,
}, {
id: 0,
usage: 'alarm'
}, (error) => {
if (error) {
console.error('Vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message);
return;
}
console.log('Callback returned to indicate a successful vibration.');
});
// 按照固定时长振动
vibrator.startVibration({
type: 'time',
duration: 1000,
}, {
id: 0,
usage: 'alarm'
}, (error) => {
if (error) {
console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
return;
}
console.info('Succeed in starting vibration');
});
} catch (error) {
console.error('errCode: ' + error.code + ' ,msg: ' + error.message);
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
try {
// 停止所有模式的马达振动
vibrator.stopVibration(function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
return;
}
console.log('Callback returned to indicate successful.');
})
// 停止所有模式的马达振动
vibrator.stopVibration(function (error) {
if (error) {
console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
return;
}
console.info('Succeed in stopping vibration');
})
} 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>
......@@ -294,36 +299,37 @@ stopVibration(): Promise&lt;void&gt;
**示例:**
```js
```ts
import vibrator from '@ohos.vibrator';
try {
// 按照固定时长振动
vibrator.startVibration({
type: 'time',
duration: 1000
}, {
id: 0,
usage: 'alarm'
}).then(() => {
console.log('Promise returned to indicate a successful vibration');
}, (error) => {
console.error('error.code' + error.code + 'error.message' + error.message);
});
// 按照固定时长振动
vibrator.startVibration({
type: 'time',
duration: 1000
}, {
id: 0,
usage: 'alarm'
}).then(() => {
console.info('Succeed in starting vibration');
}, (error) => {
console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
});
} catch (error) {
console.error('errCode: ' + error.code + ' ,msg: ' + error.message);
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
try {
// 停止所有模式的马达振动
vibrator.stopVibration().then(() => {
console.log('Promise returned to indicate a successful vibration.');
}, (error) => {
console.log('error.code' + error.code + 'error.message' + error.message);
});
// 停止所有模式的马达振动
vibrator.stopVibration().then(() => {
console.info('Succeed in stopping vibration');
}, (error) => {
console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);
});
} 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>
......@@ -342,40 +348,41 @@ isSupportEffect(effectId: string, callback: AsyncCallback&lt;boolean&gt;): void
**示例:**
```js
```ts
import vibrator from '@ohos.vibrator';
try {
// 查询是否支持'haptic.clock.timer'
vibrator.isSupportEffect('haptic.clock.timer', function (err, state) {
if (err) {
console.error('isSupportEffect failed, error:' + JSON.stringify(err));
return;
}
console.log('The effectId is ' + (state ? 'supported' : 'unsupported'));
if (state) {
try {
vibrator.startVibration({ // 使用startVibration需要添加ohos.permission.VIBRATE权限
type: 'preset',
effectId: 'haptic.clock.timer',
count: 1,
}, {
usage: 'unknown'
}, (error) => {
if(error) {
console.error('haptic.clock.timer vibrator error:' + JSON.stringify(error));
} else {
console.log('haptic.clock.timer vibrator success');
}
});
} catch (error) {
console.error('Exception in, error:' + JSON.stringify(error));
}
}
})
// 查询是否支持'haptic.clock.timer'
vibrator.isSupportEffect('haptic.clock.timer', function (err, state) {
if (err) {
console.error(`Failed to query effect. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info('Succeed in querying effect');
if (state) {
try {
vibrator.startVibration({ // 使用startVibration需要添加ohos.permission.VIBRATE权限
type: 'preset',
effectId: 'haptic.clock.timer',
count: 1,
}, {
usage: 'unknown'
}, (error) => {
if (error) {
console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
} else {
console.info('Succeed in starting vibration');
}
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
}
})
} 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>
......@@ -399,36 +406,37 @@ isSupportEffect(effectId: string): Promise&lt;boolean&gt;
**示例:**
```js
```ts
import vibrator from '@ohos.vibrator';
try {
// 查询是否支持'haptic.clock.timer'
vibrator.isSupportEffect('haptic.clock.timer').then((state) => {
console.log('The effectId is ' + (state ? 'supported' : 'unsupported'));
if (state) {
try {
vibrator.startVibration({
type: 'preset',
effectId: 'haptic.clock.timer',
count: 1,
}, {
usage: 'unknown'
}).then(()=>{
console.log('Promise returned to indicate a successful vibration');
}).catch((error)=>{
console.error('Promise returned to indicate a failed vibration:' + JSON.stringify(error));
});
} catch (error) {
console.error('Exception in, error:' + JSON.stringify(error));
}
}
}, (error) => {
console.error('isSupportEffect failed, error:' + JSON.stringify(error));
})
// 查询是否支持'haptic.clock.timer'
vibrator.isSupportEffect('haptic.clock.timer').then((state) => {
console.info(`The query result is ${state}`);
if (state) {
try {
vibrator.startVibration({
type: 'preset',
effectId: 'haptic.clock.timer',
count: 1,
}, {
usage: 'unknown'
}).then(() => {
console.info('Succeed in starting vibration');
}).catch((error) => {
console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
}
}, (error) => {
console.error(`Failed to query effect. Code: ${error.code}, message: ${error.message}`);
})
} catch (error) {
console.error('Exception in, error:' + JSON.stringify(error));
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
```
## EffectId
......@@ -489,7 +497,7 @@ try {
## VibrateFromFile<sup>10+</sup>
自定义振动类型,仅部分设备支持。
自定义振动类型,仅部分设备支持,当设备不支持此振动类型时,返回[设备不支持错误码](../errorcodes/errorcode-universal.md)
**系统能力**:SystemCapability.Sensors.MiscDevice
......@@ -565,13 +573,13 @@ vibrate(duration: number): Promise&lt;void&gt;
**示例:**
```js
```ts
vibrator.vibrate(1000).then(() => {
console.log('Promise returned to indicate a successful vibration.');
console.info('Succeed in vibrating');
}, (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>
......@@ -594,15 +602,15 @@ vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void
**示例:**
```js
```ts
vibrator.vibrate(1000, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
} else {
console.log('Callback returned to indicate a successful vibration.');
}
if (error) {
console.error(`Failed to vibrate. Code: ${error.code}, message: ${error.message}`);
} else {
console.info('Succeed in vibrating');
}
})
```
```
## vibrator.vibrate<sup>(deprecated)</sup>
......@@ -631,13 +639,13 @@ vibrate(effectId: EffectId): Promise&lt;void&gt;
**示例:**
```js
```ts
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(() => {
console.log('Promise returned to indicate a successful vibration.');
console.info('Succeed in vibrating');
}, (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>
......@@ -661,15 +669,15 @@ vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void
**示例:**
```js
```ts
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
} else {
console.log('Callback returned to indicate a successful vibration.');
}
if (error) {
console.error(`Failed to vibrate. Code: ${error.code}, message: ${error.message}`);
} else {
console.info('Succeed in vibrating');
}
})
```
```
## vibrator.stop<sup>(deprecated)</sup>
......@@ -697,22 +705,22 @@ stop(stopMode: VibratorStopMode): Promise&lt;void&gt;
**示例:**
```js
```ts
// 按照effectId类型启动振动
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
} else {
console.log('Callback returned to indicate a successful vibration.');
}
if (error) {
console.error(`Failed to vibrate. Code: ${error.code}, message: ${error.message}`);
} else {
console.info('Succeed in vibrating');
}
})
// 使用VIBRATOR_STOP_MODE_PRESET模式停止振动
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(() => {
console.log('Promise returned to indicate a successful vibration.');
console.info('Succeed in stopping');
}, (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>
......@@ -736,21 +744,21 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void
**示例:**
```js
```ts
// 按照effectId类型启动振动
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
} else {
console.log('Callback returned to indicate a successful vibration.');
}
if (error) {
console.error(`Failed to vibrate. Code: ${error.code}, message: ${error.message}`);
} else {
console.info('Succeed in vibrating');
}
})
// 使用VIBRATOR_STOP_MODE_PRESET模式停止振动
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
} else {
console.log('Callback returned to indicate successful.');
}
if (error) {
console.error(`Failed to stop. Code: ${error.code}, message: ${error.message}`);
} else {
onsole.info('Succeed in stopping');
}
})
```
```
......@@ -2977,7 +2977,7 @@ onWindowNew(callback: (event: {isAlert: boolean, isUserTrigger: boolean, targetU
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
//在同一page页有两个web组件。在WebComponent新开窗口时,会跳转到NewWebViewComp。
@CustomDialog
struct NewWebViewComp {
......@@ -3333,8 +3333,8 @@ onFirstContentfulPaint(callback: (event?: { navigationStartTick: number, firstCo
Column() {
Web({ src:'www.example.com', controller: this.controller })
.onFirstContentfulPaint(event => {
console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" +
event.navigationStartTick + ", [firstContentfulPaintMs]:" +
console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" +
event.navigationStartTick + ", [firstContentfulPaintMs]:" +
event.firstContentfulPaintMs)
})
}
......@@ -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
Web组件获取控制台信息对象。示例代码参考[onConsole事件](#onconsole)
......
......@@ -82,7 +82,7 @@ SubTabBarStyle的静态构造函数。
| -------- | -------- | -------- | -------------------------------- |
| color | [ResourceColor](ts-types.md#resourcecolor) | 否 | 下划线的颜色和背板颜色。<br/>默认值:#FF007DFF |
| 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 |
| marginTop | [Length](ts-types.md#length) | 否 | 下划线与文字的间距(不支持百分比设置)。<br/>默认值:8.0<br/>单位:vp |
......
......@@ -31,6 +31,7 @@
- [Memory](memory.md)
- [UsbDdk](_usb_ddk.md)
- [Hitrace](_hitrace.md)
- [Vulkan](_vulkan.md)
- 头文件
- [drawing_bitmap.h](drawing__bitmap_8h.md)
- [drawing_brush.h](drawing__brush_8h.md)
......@@ -92,6 +93,7 @@
- [usb_ddk_api.h](usb__ddk__api_8h.md)
- [usb_ddk_types.h](usb__ddk__types_8h.md)
- [trace.h](trace_8h.md)
- [vulkan_ohos.h](vulkan__ohos_8h.md)
- 结构体
- [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md)
- [OH_NativeBuffer_Config](_o_h___native_buffer___config.md)
......@@ -148,3 +150,10 @@
- [UsbEndpointDescriptor](_usb_endpoint_descriptor.md)
- [UsbInterfaceDescriptor](_usb_interface_descriptor.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 @@
- [@ohos.enterprise.dateTimeManager (系统时间管理)](reference/apis/js-apis-enterprise-dateTimeManager.md)
- [@ohos.enterprise.deviceControl (设备控制管理)](reference/apis/js-apis-enterprise-deviceControl.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.networkManager (网络管理)](reference/apis/js-apis-enterprise-networkManager.md)
- [@ohos.enterprise.wifiManager (WiFi管理)](reference/apis/js-apis-enterprise-wifiManager.md)
......
......@@ -34,7 +34,6 @@
- [标准系统内核](kernel/kernel-standard-overview.md)
- [驱动](driver/Readme-CN.md)
- [编译构建](subsystems/subsys-build-all.md)
- [分布式远程启动](subsystems/subsys-remote-start.md)
- [图形图像](subsystems/subsys-graphics-overview.md)
- [媒体](subsystems/subsys-multimedia-camera-overview.md)
- [公共基础](subsystems/subsys-utils-guide.md)
......
......@@ -11,7 +11,7 @@
## Audio驱动框架介绍
Audio驱动框架基于[HDF驱动框架](driver-hdf-overview.md)实现。Audio驱动架构组成:
Audio驱动框架基于[HDF驱动框架](driver-overview-foundation.md)实现。Audio驱动架构组成:
![](figures/Audio框架图.png)
......@@ -300,7 +300,7 @@ int32_t CodecDaiHwParams(const struct AudioCard *card, const struct AudioPcmHwPa
#### Codec注册绑定到HDF
此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-hdf-overview.md)指导。
此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-overview-foundation.md)指导。
填充g_codecDriverEntry结构体,moduleName与device_info.hcs中的moduleName匹配,实现Bind、Init、Release函数指针。
......@@ -799,7 +799,7 @@ int32_t Tfa9879DaiHwParams(const struct AudioCard *card, const struct AudioPcmHw
#### Codec注册绑定到HDF
此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-hdf-overview.md)
此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-overview-foundation.md)
填充g_tfa9879DriverEntry结构体,moduleName与device_info.hcs中的moduleName匹配,实现Bind、Init、Release函数指针。
......@@ -927,7 +927,7 @@ int32_t Hi3516DmaPointer(struct PlatformData *data, const enum AudioStreamType s
#### Platform注册绑定到HDF
此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-hdf-overview.md)
此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-overview-foundation.md)
- 填充g_platformDriverEntry结构体
- moduleName与device_info.hcs中的moduleName匹配
......@@ -1091,7 +1091,7 @@ int32_t DaiStartup(const struct AudioCard *card, const struct DaiDevice *device)
#### Dai注册绑定到HDF
此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-hdf-overview.md)
此处依赖HDF框架的驱动实现方式,具体流程可参考[HDF驱动框架](driver-overview-foundation.md)
- 填充g_daiDriverEntry结构体
- moduleName与device_info.hcs中的moduleName匹配
......
# kernel
# 内核
- 内核
- [内核概述](kernel-overview.md)
- 轻量系统内核(LiteOS-M)
- [轻量系统内核概述](kernel-mini-overview.md)
- 基础内核
- [中断管理](kernel-mini-basic-interrupt.md)
- [任务管理](kernel-mini-basic-task.md)
- [内存管理](kernel-mini-basic-memory.md)
- 内核通信机制
- [事件](kernel-mini-basic-ipc-event.md)
- [互斥锁](kernel-mini-basic-ipc-mutex.md)
- [消息队列](kernel-mini-basic-ipc-queue.md)
- [信号量](kernel-mini-basic-ipc-sem.md)
- [时间管理](kernel-mini-basic-time.md)
- [软件定时器](kernel-mini-basic-soft.md)
- [双向链表](kernel-mini-basic-list.md)
- 扩展组件
- [C++支持](kernel-mini-extend-support.md)
- [CPU占用率](kernel-mini-extend-cpup.md)
- [动态加载](kernel-mini-extend-dynamic-loading.md)
- [文件系统](kernel-mini-extend-file.md)
- 内核调测
- [内存调测](kernel-mini-memory-debug.md)
- [异常调测](kernel-mini-memory-exception.md)
- [Trace调测](kernel-mini-memory-trace.md)
- [LMS调测](kernel-mini-memory-lms.md)
- [SHELL](kernel-mini-debug-shell.md)
- 附录
- [内核编码规范](kernel-mini-appx-code.md)
- [标准库支持](kernel-mini-appx-lib.md)
- 小型系统内核(LiteOS-A)
- [小型系统内核概述](kernel-small-overview.md)
- 内核启动
- [内核态启动](kernel-small-start-kernel.md)
- [用户态启动](kernel-small-start-user.md)
- 基础内核
- [中断及异常处理](kernel-small-basic-interrupt.md)
- 进程管理
- [进程](kernel-small-basic-process-process.md)
- [任务](kernel-small-basic-process-thread.md)
- [调度器](kernel-small-basic-process-scheduler.md)
- 内存管理
- [堆内存管理](kernel-small-basic-memory-heap.md)
- [物理内存管理](kernel-small-basic-memory-physical.md)
- [虚拟内存管理](kernel-small-basic-memory-virtual.md)
- [虚实映射](kernel-small-basic-inner-reflect.md)
- 内核通信机制
- [事件](kernel-small-basic-trans-event.md)
- [信号量](kernel-small-basic-trans-semaphore.md)
- [互斥锁](kernel-small-basic-trans-mutex.md)
- [消息队列](kernel-small-basic-trans-queue.md)
- [读写锁](kernel-small-basic-trans-rwlock.md)
- [用户态快速互斥锁](kernel-small-basic-trans-user-mutex.md)
- [信号](kernel-small-basic-trans-user-signal.md)
- [时间管理](kernel-small-basic-time.md)
- [软件定时器](kernel-small-basic-softtimer.md)
- [原子操作](kernel-small-basic-atomic.md)
- 扩展组件
- [系统调用](kernel-small-bundles-system.md)
- [动态加载与链接](kernel-small-bundles-linking.md)
- [虚拟动态共享库](kernel-small-bundles-share.md)
- [轻量级进程间通信](kernel-small-bundles-ipc.md)
- [容器隔离](kernel-small-bundles-container.md)
- 文件系统
- [虚拟文件系统](kernel-small-bundles-fs-virtual.md)
- [支持的文件系统](kernel-small-bundles-fs-support.md)
- [适配新的文件系统](kernel-small-bundles-fs-new.md)
- [Plimitsfs文件系统](kernel-small-plimits.md)
- 调测与工具
- Shell
- [Shell介绍](kernel-small-debug-shell-overview.md)
- [Shell命令开发指导](kernel-small-debug-shell-guide.md)
- [Shell命令编程实例](kernel-small-debug-shell-build.md)
- Shell命令使用详解
- 系统命令
- [cpup](kernel-small-debug-shell-cmd-cpup.md)
- [date](kernel-small-debug-shell-cmd-date.md)
- [dmesg](kernel-small-debug-shell-cmd-dmesg.md)
- [exec](kernel-small-debug-shell-cmd-exec.md)
- [free](kernel-small-debug-shell-cmd-free.md)
- [help](kernel-small-debug-shell-cmd-help.md)
- [hwi](kernel-small-debug-shell-cmd-hwi.md)
- [kill](kernel-small-debug-shell-cmd-kill.md)
- [log](kernel-small-debug-shell-cmd-log.md)
- [memcheck](kernel-small-debug-shell-cmd-memcheck.md)
- [oom](kernel-small-debug-shell-cmd-oom.md)
- [pmm](kernel-small-debug-shell-cmd-pmm.md)
- [reset](kernel-small-debug-shell-cmd-reset.md)
- [sem](kernel-small-debug-shell-cmd-sem.md)
- [stack](kernel-small-debug-shell-cmd-stack.md)
- [su](kernel-small-debug-shell-cmd-su.md)
- [swtmr](kernel-small-debug-shell-cmd-swtmr.md)
- [systeminfo](kernel-small-debug-shell-cmd-sysinfo.md)
- [task](kernel-small-debug-shell-cmd-task.md)
- [uname](kernel-small-debug-shell-cmd-uname.md)
- [vmm](kernel-small-debug-shell-cmd-vmm.md)
- [watch](kernel-small-debug-shell-cmd-watch.md)
- [reboot](kernel-small-debug-shell-cmd-reboot.md)
- [top](kernel-small-debug-shell-cmd-top.md)
- 文件命令
- [cat](kernel-small-debug-shell-file-cat.md)
- [cd](kernel-small-debug-shell-file-cd.md)
- [chgrp](kernel-small-debug-shell-file-chgrp.md)
- [chmod](kernel-small-debug-shell-file-chmod.md)
- [chown](kernel-small-debug-shell-file-chown.md)
- [cp](kernel-small-debug-shell-file-cp.md)
- [format](kernel-small-debug-shell-file-format.md)
- [ls](kernel-small-debug-shell-file-ls.md)
- [lsfd](kernel-small-debug-shell-file-lsfd.md)
- [mkdir](kernel-small-debug-shell-file-mkdir.md)
- [mount](kernel-small-debug-shell-file-mount.md)
- [partinfo](kernel-small-debug-shell-file-partinfo.md)
- [partition](kernel-small-debug-shell-file-partition.md)
- [pwd](kernel-small-debug-shell-file-pwd.md)
- [rm](kernel-small-debug-shell-file-rm.md)
- [rmdir](kernel-small-debug-shell-file-rmdir.md)
- [statfs](kernel-small-debug-shell-file-statfs.md)
- [sync](kernel-small-debug-shell-file-sync.md)
- [touch](kernel-small-debug-shell-file-touch.md)
- [writeproc](kernel-small-debug-shell-file-write.md)
- [umount](kernel-small-debug-shell-file-umount.md)
- [du](kernel-small-debug-shell-file-du.md)
- [mv](kernel-small-debug-shell-file-mv.md)
- 网络命令
- [arp](kernel-small-debug-shell-net-arp.md)
- [dhclient](kernel-small-debug-shell-net-dhclient.md)
- [ifconfig](kernel-small-debug-shell-net-ifconfig.md)
- [ipdebug](kernel-small-debug-shell-net-ipdebug.md)
- [netstat](kernel-small-debug-shell-net-netstat.md)
- [ntpdate](kernel-small-debug-shell-net-ntpdate.md)
- [ping](kernel-small-debug-shell-net-ping.md)
- [ping6](kernel-small-debug-shell-net-ping6.md)
- [telnet](kernel-small-debug-shell-net-telnet.md)
- [tftp](kernel-small-debug-shell-net-tftp.md)
- [魔法键使用方法](kernel-small-debug-shell-magickey.md)
- [用户态异常信息说明](kernel-small-debug-shell-error.md)
- [Trace调测](kernel-small-debug-trace.md)
- [Perf调测](kernel-small-debug-perf.md)
- [LMS调测](kernel-small-memory-lms.md)
- [进程调测](kernel-small-debug-process-cpu.md)
- 内核态内存调测
- [内存信息统计](kernel-small-debug-memory-info.md)
- [内存泄漏检测](kernel-small-debug-memory-leak.md)
- [踩内存检测](kernel-small-debug-memory-corrupt.md)
- [用户态内存调测](kernel-small-debug-user.md)
- 其他内核调测手段
- [临终遗言](kernel-small-debug-trace-other-lastwords.md)
- [常见问题](kernel-small-debug-trace-other-faqs.md)
- 附录
- 基本数据结构
- [双向链表](kernel-small-apx-dll.md)
- [位操作](kernel-small-apx-bitwise.md)
- [标准库](kernel-small-apx-library.md)
- [内核编码规范](kernel-mini-appx-code.md)
- 标准系统内核(Linux)
- [标准系统内核概述](kernel-standard-overview.md)
- [OpenHarmony开发板Patch使用指导](kernel-standard-patch.md)
- [标准系统内核编译与构建指导](kernel-standard-build.md)
- [HCK内核解耦框架指导](kernel-standard-hck.md)
- 内核增强特性
- [Enhanced SWAP特性介绍](kernel-standard-mm-eswap.md)
- [NewIP内核协议栈介绍](kernel-standard-newip.md)
- 任务调度
- [关联线程组调度](kernel-standard-sched-rtg.md)
- [CPU轻量级隔离](kernel-standard-sched-cpuisolation.md)
- [内核概述](kernel-overview.md)
- 轻量系统内核(LiteOS-M)
- [轻量系统内核概述](kernel-mini-overview.md)
- 基础内核
- [中断管理](kernel-mini-basic-interrupt.md)
- [任务管理](kernel-mini-basic-task.md)
- [内存管理](kernel-mini-basic-memory.md)
- 内核通信机制
- [事件](kernel-mini-basic-ipc-event.md)
- [互斥锁](kernel-mini-basic-ipc-mutex.md)
- [消息队列](kernel-mini-basic-ipc-queue.md)
- [信号量](kernel-mini-basic-ipc-sem.md)
- [时间管理](kernel-mini-basic-time.md)
- [软件定时器](kernel-mini-basic-soft.md)
- [双向链表](kernel-mini-basic-list.md)
- 扩展组件
- [C++支持](kernel-mini-extend-support.md)
- [CPU占用率](kernel-mini-extend-cpup.md)
- [动态加载](kernel-mini-extend-dynamic-loading.md)
- [文件系统](kernel-mini-extend-file.md)
- 内核调测
- [内存调测](kernel-mini-memory-debug.md)
- [异常调测](kernel-mini-memory-exception.md)
- [Trace调测](kernel-mini-memory-trace.md)
- [LMS调测](kernel-mini-memory-lms.md)
- [SHELL](kernel-mini-debug-shell.md)
- 附录
- [内核编码规范](kernel-mini-appx-code.md)
- [标准库支持](kernel-mini-appx-lib.md)
- 小型系统内核(LiteOS-A)
- [小型系统内核概述](kernel-small-overview.md)
- 内核启动
- [内核态启动](kernel-small-start-kernel.md)
- [用户态启动](kernel-small-start-user.md)
- 基础内核
- [中断及异常处理](kernel-small-basic-interrupt.md)
- 进程管理
- [进程](kernel-small-basic-process-process.md)
- [任务](kernel-small-basic-process-thread.md)
- [调度器](kernel-small-basic-process-scheduler.md)
- 内存管理
- [堆内存管理](kernel-small-basic-memory-heap.md)
- [物理内存管理](kernel-small-basic-memory-physical.md)
- [虚拟内存管理](kernel-small-basic-memory-virtual.md)
- [虚实映射](kernel-small-basic-inner-reflect.md)
- 内核通信机制
- [事件](kernel-small-basic-trans-event.md)
- [信号量](kernel-small-basic-trans-semaphore.md)
- [互斥锁](kernel-small-basic-trans-mutex.md)
- [消息队列](kernel-small-basic-trans-queue.md)
- [读写锁](kernel-small-basic-trans-rwlock.md)
- [用户态快速互斥锁](kernel-small-basic-trans-user-mutex.md)
- [信号](kernel-small-basic-trans-user-signal.md)
- [时间管理](kernel-small-basic-time.md)
- [软件定时器](kernel-small-basic-softtimer.md)
- [原子操作](kernel-small-basic-atomic.md)
- 扩展组件
- [系统调用](kernel-small-bundles-system.md)
- [动态加载与链接](kernel-small-bundles-linking.md)
- [虚拟动态共享库](kernel-small-bundles-share.md)
- [轻量级进程间通信](kernel-small-bundles-ipc.md)
- [容器隔离](kernel-small-bundles-container.md)
- 文件系统
- [虚拟文件系统](kernel-small-bundles-fs-virtual.md)
- [支持的文件系统](kernel-small-bundles-fs-support.md)
- [适配新的文件系统](kernel-small-bundles-fs-new.md)
- [Plimitsfs文件系统](kernel-small-plimits.md)
- 调测与工具
- Shell
- [Shell介绍](kernel-small-debug-shell-overview.md)
- [Shell命令开发指导](kernel-small-debug-shell-guide.md)
- [Shell命令编程实例](kernel-small-debug-shell-build.md)
- Shell命令使用详解
- 系统命令
- [cpup](kernel-small-debug-shell-cmd-cpup.md)
- [date](kernel-small-debug-shell-cmd-date.md)
- [dmesg](kernel-small-debug-shell-cmd-dmesg.md)
- [exec](kernel-small-debug-shell-cmd-exec.md)
- [free](kernel-small-debug-shell-cmd-free.md)
- [help](kernel-small-debug-shell-cmd-help.md)
- [hwi](kernel-small-debug-shell-cmd-hwi.md)
- [kill](kernel-small-debug-shell-cmd-kill.md)
- [log](kernel-small-debug-shell-cmd-log.md)
- [memcheck](kernel-small-debug-shell-cmd-memcheck.md)
- [oom](kernel-small-debug-shell-cmd-oom.md)
- [pmm](kernel-small-debug-shell-cmd-pmm.md)
- [reset](kernel-small-debug-shell-cmd-reset.md)
- [sem](kernel-small-debug-shell-cmd-sem.md)
- [stack](kernel-small-debug-shell-cmd-stack.md)
- [su](kernel-small-debug-shell-cmd-su.md)
- [swtmr](kernel-small-debug-shell-cmd-swtmr.md)
- [systeminfo](kernel-small-debug-shell-cmd-sysinfo.md)
- [task](kernel-small-debug-shell-cmd-task.md)
- [uname](kernel-small-debug-shell-cmd-uname.md)
- [vmm](kernel-small-debug-shell-cmd-vmm.md)
- [watch](kernel-small-debug-shell-cmd-watch.md)
- [reboot](kernel-small-debug-shell-cmd-reboot.md)
- [top](kernel-small-debug-shell-cmd-top.md)
- 文件命令
- [cat](kernel-small-debug-shell-file-cat.md)
- [cd](kernel-small-debug-shell-file-cd.md)
- [chgrp](kernel-small-debug-shell-file-chgrp.md)
- [chmod](kernel-small-debug-shell-file-chmod.md)
- [chown](kernel-small-debug-shell-file-chown.md)
- [cp](kernel-small-debug-shell-file-cp.md)
- [format](kernel-small-debug-shell-file-format.md)
- [ls](kernel-small-debug-shell-file-ls.md)
- [lsfd](kernel-small-debug-shell-file-lsfd.md)
- [mkdir](kernel-small-debug-shell-file-mkdir.md)
- [mount](kernel-small-debug-shell-file-mount.md)
- [partinfo](kernel-small-debug-shell-file-partinfo.md)
- [partition](kernel-small-debug-shell-file-partition.md)
- [pwd](kernel-small-debug-shell-file-pwd.md)
- [rm](kernel-small-debug-shell-file-rm.md)
- [rmdir](kernel-small-debug-shell-file-rmdir.md)
- [statfs](kernel-small-debug-shell-file-statfs.md)
- [sync](kernel-small-debug-shell-file-sync.md)
- [touch](kernel-small-debug-shell-file-touch.md)
- [writeproc](kernel-small-debug-shell-file-write.md)
- [umount](kernel-small-debug-shell-file-umount.md)
- [du](kernel-small-debug-shell-file-du.md)
- [mv](kernel-small-debug-shell-file-mv.md)
- 网络命令
- [arp](kernel-small-debug-shell-net-arp.md)
- [dhclient](kernel-small-debug-shell-net-dhclient.md)
- [ifconfig](kernel-small-debug-shell-net-ifconfig.md)
- [ipdebug](kernel-small-debug-shell-net-ipdebug.md)
- [netstat](kernel-small-debug-shell-net-netstat.md)
- [ntpdate](kernel-small-debug-shell-net-ntpdate.md)
- [ping](kernel-small-debug-shell-net-ping.md)
- [ping6](kernel-small-debug-shell-net-ping6.md)
- [telnet](kernel-small-debug-shell-net-telnet.md)
- [tftp](kernel-small-debug-shell-net-tftp.md)
- [魔法键使用方法](kernel-small-debug-shell-magickey.md)
- [用户态异常信息说明](kernel-small-debug-shell-error.md)
- [Trace调测](kernel-small-debug-trace.md)
- [Perf调测](kernel-small-debug-perf.md)
- [LMS调测](kernel-small-memory-lms.md)
- [进程调测](kernel-small-debug-process-cpu.md)
- 内核态内存调测
- [内存信息统计](kernel-small-debug-memory-info.md)
- [内存泄漏检测](kernel-small-debug-memory-leak.md)
- [踩内存检测](kernel-small-debug-memory-corrupt.md)
- [用户态内存调测](kernel-small-debug-user.md)
- 其他内核调测手段
- [临终遗言](kernel-small-debug-trace-other-lastwords.md)
- [常见问题](kernel-small-debug-trace-other-faqs.md)
- 附录
- 基本数据结构
- [双向链表](kernel-small-apx-dll.md)
- [位操作](kernel-small-apx-bitwise.md)
- [标准库](kernel-small-apx-library.md)
- [内核编码规范](kernel-mini-appx-code.md)
- 标准系统内核(Linux)
- [标准系统内核概述](kernel-standard-overview.md)
- [OpenHarmony开发板Patch使用指导](kernel-standard-patch.md)
- [标准系统内核编译与构建指导](kernel-standard-build.md)
- [HCK内核解耦框架指导](kernel-standard-hck.md)
- 内核增强特性
- [Enhanced SWAP特性介绍](kernel-standard-mm-eswap.md)
- [NewIP内核协议栈介绍](kernel-standard-newip.md)
- 任务调度
- [关联线程组调度](kernel-standard-sched-rtg.md)
- [CPU轻量级隔离](kernel-standard-sched-cpuisolation.md)
# security
# 隐私与安全
- 隐私与安全
- [隐私保护](security-privacy-protection.md)
- [安全指南](security-guidelines-overall.md)
- [隐私保护](security-privacy-protection.md)
- [安全指南](security-guidelines-overall.md)
# subsystems
# 子系统开发
- 编译构建
- [编译构建指导](subsys-build-all.md)
......@@ -24,7 +24,6 @@
- [Cargo2gn工具操作指导](subsys-build-cargo2gn-guide.md)
- [ 常见问题](subsys-build-FAQ.md)
- [ArkCompiler](subsys-arkcompiler-guide.md)
- [分布式远程启动](subsys-remote-start.md)
- 小型系统图形图像
- [小型系统图形图像概述](subsys-graphics-overview.md)
- [普通组件开发指导](subsys-graphics-common-guide.md)
......
......@@ -393,7 +393,6 @@
- [HAP编译构建指导](subsystems/subsys-build-gn-hap-compilation-guide.md)
- [常见问题](subsystems/subsys-build-FAQ.md)
- [ArkCompiler](subsystems/subsys-arkcompiler-guide.md)
- [分布式远程启动](subsystems/subsys-remote-start.md)
- 图形图像
- [图形图像概述](subsystems/subsys-graphics-overview.md)
- [容器类组件开发指导](subsystems/subsys-graphics-container-guide.md)
......
......@@ -40,7 +40,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary';
async function example() {
try {
let context = getContext(this);
let media = mediaLibrary.getmediaLibrary(context);
let media = mediaLibrary.getMediaLibrary(context);
let fileKeyObj = mediaLibrary.FileKey;
let albumId = 1;
let getImageOp = {
......@@ -66,7 +66,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary';
async function example() {
try {
let context = getContext(this);
let media = mediaLibrary.getmediaLibrary(context);
let media = mediaLibrary.getMediaLibrary(context);
let fileKeyObj = mediaLibrary.FileKey;
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
......@@ -102,14 +102,15 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary';
async function example() {
try {
let context = getContext(this);
let media = mediaLibrary.getmediaLibrary(context);
let media = mediaLibrary.getMediaLibrary(context);
let AlbumNoArgsfetchOp = {
selections: mediaLibrary.FileKey.ALBUM_NAME + ' = ?',
selectionArgs: ['新建相册1'], // 获取albumName为新建相册1的相册。
};
const fetchFileResult = await media.getAlbums(AlbumNoArgsfetchOp); // 查询失败,获取的fetchFileResult为空。
const album = await fetchFileResult.getFirstObject();
console.info('mediaLibrary album albumName: ' + album.albumName);
const albumList = await media.getAlbums(AlbumNoArgsfetchOp); // 查询失败,获取的fetchFileResult为空。
for (let i = 0; i < albumList.length; i++) {
console.info('mediaLibrary album albumName: ' + albumList[i].albumName);
}
} catch (err) {
console.error('mediaLibrary fail, err: ' + err);
}
......@@ -126,14 +127,15 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary';
async function example() {
try {
let context = getContext(this);
let media = mediaLibrary.getmediaLibrary(context);
let media = mediaLibrary.getMediaLibrary(context);
let AlbumNoArgsfetchOp = {
selections: mediaLibrary.FileKey.ALBUM_NAME + ' = ? OR ' + mediaLibrary.FileKey.ALBUM_NAME + ' = ?',
selectionArgs: ['Camera', 'Screenshots'], // 获取相机相册和截屏录屏相册。
};
const fetchFileResult = await media.getAlbums(AlbumNoArgsfetchOp);
const album = await fetchFileResult.getFirstObject();
console.info('mediaLibrary album albumName: ' + album.albumName);
const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
for (let i = 0; i < albumList.length; i++) {
console.info('mediaLibrary album albumName: ' + albumList[i].albumName);
}
} catch (err) {
console.error('mediaLibrary fail, err: ' + err);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册