harmony 鸿蒙@ohos.app.ability.AtomicServiceOptions (AtomicServiceOptions)
@ohos.app.ability.AtomicServiceOptions (AtomicServiceOptions)
AtomicServiceOptions is used as an input parameter of openAtomicService() to carry arguments. It inherits from StartOptions.
NOTE
The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The APIs of this module can be used only in the stage model.
Modules to Import
import { AtomicServiceOptions } from '@kit.AbilityKit';
Properties
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.Ability.AbilityRuntime.Core
Name | Type | Read Only | Optional | Description |
---|---|---|---|---|
flags | number | No | Yes | Mode in which the system processes the startup. For example, wantConstant.Flags.FLAG_INSTALL_ON_DEMAND indicates that the installation-free capability is used. |
parameters | Record<string, Object> | No | Yes | Additional parameters. For details, see the parameters field in Want. |
Example
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) => {
// Carry out normal service processing.
console.info('openAtomicService succeed');
})
.catch((err: BusinessError) => {
// Process service logic errors.
console.error(`openAtomicService failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// Process input parameter errors.
let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.error(`openAtomicService failed, code is ${code}, message is ${message}`);
}
}
}
你可能感兴趣的鸿蒙文章
harmony 鸿蒙AbilityAccessControl
harmony 鸿蒙OH_NativeBundle_ApplicationInfo
harmony 鸿蒙OH_NativeBundle_ElementName
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦