代码拉取完成,页面将自动刷新
AtomicServiceOptions可以作为openAtomicService()的入参,用于携带参数。继承于StartOptions。
说明:
本模块首批接口从API version 12 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
本模块接口仅可在Stage模型下使用。
import { AtomicServiceOptions } from '@kit.AbilityKit';
原子化服务API: 从API version 12开始,该接口支持在原子化服务中使用。
系统能力:SystemCapability.Ability.AbilityRuntime.Core
名称 | 类型 | 只读 | 必填 | 说明 |
---|---|---|---|---|
flags | number | 否 | 否 | 系统处理该次启动的方式。 例如通过wantConstant.Flags.FLAG_INSTALL_ON_DEMAND表示使用免安装能力。 |
parameters | Record<string, Object> | 否 | 否 | 表示额外参数描述。具体描述参考Want中parameters字段描述。 |
示例:
import { UIAbility, AtomicServiceOptions, common, wantConstant } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
export default class EntryAbility extends UIAbility {
onForeground() {
let appId: string = '6918661953712445909';
let options: AtomicServiceOptions = {
flags: wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
parameters: {
"demo.result": 123456
}
};
try {
this.context.openAtomicService(appId, options)
.then((result: common.AbilityResult) => {
// 执行正常业务
console.info('openAtomicService succeed');
})
.catch((err: BusinessError) => {
// 处理业务逻辑错误
console.error(`openAtomicService failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// 处理入参错误异常
let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.error(`openAtomicService failed, code is ${code}, message is ${message}`);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。