1e41f4b71Sopenharmony_ci# @ohos.app.ability.AtomicServiceOptions (AtomicServiceOptions)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciAtomicServiceOptions可以作为[openAtomicService()](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextopenatomicservice12)的入参,用于携带参数。继承于[StartOptions](js-apis-app-ability-startOptions.md)。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **说明:**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> 本模块首批接口从API version 12 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> 本模块接口仅可在Stage模型下使用。
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## 导入模块
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci```ts
14e41f4b71Sopenharmony_ciimport { AtomicServiceOptions } from '@kit.AbilityKit';
15e41f4b71Sopenharmony_ci```
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## 属性
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci| 名称 | 类型 | 只读 | 可选 | 说明 |
24e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
25e41f4b71Sopenharmony_ci| [flags](js-apis-app-ability-wantConstant.md#flags) | number | 否 |  是 | 系统处理该次启动的方式。<br />例如通过wantConstant.Flags.FLAG_INSTALL_ON_DEMAND表示使用免安装能力。 |
26e41f4b71Sopenharmony_ci| parameters | Record\<string, Object> | 否 |  是 | 表示额外参数描述。具体描述参考[Want](js-apis-app-ability-want.md)中parameters字段描述。 |
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci**示例:**
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci```ts
31e41f4b71Sopenharmony_ciimport { UIAbility, AtomicServiceOptions, common, wantConstant } from '@kit.AbilityKit';
32e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
35e41f4b71Sopenharmony_ci  onForeground() {
36e41f4b71Sopenharmony_ci    let appId: string = '6918661953712445909';
37e41f4b71Sopenharmony_ci    let options: AtomicServiceOptions = {
38e41f4b71Sopenharmony_ci      flags: wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
39e41f4b71Sopenharmony_ci      parameters: {
40e41f4b71Sopenharmony_ci        "demo.result": 123456
41e41f4b71Sopenharmony_ci      }
42e41f4b71Sopenharmony_ci    };
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci    try {
45e41f4b71Sopenharmony_ci      this.context.openAtomicService(appId, options)
46e41f4b71Sopenharmony_ci        .then((result: common.AbilityResult) => {
47e41f4b71Sopenharmony_ci          // 执行正常业务
48e41f4b71Sopenharmony_ci          console.info('openAtomicService succeed');
49e41f4b71Sopenharmony_ci        })
50e41f4b71Sopenharmony_ci        .catch((err: BusinessError) => {
51e41f4b71Sopenharmony_ci          // 处理业务逻辑错误
52e41f4b71Sopenharmony_ci          console.error(`openAtomicService failed, code is ${err.code}, message is ${err.message}`);
53e41f4b71Sopenharmony_ci        });
54e41f4b71Sopenharmony_ci    } catch (err) {
55e41f4b71Sopenharmony_ci      // 处理入参错误异常
56e41f4b71Sopenharmony_ci      let code = (err as BusinessError).code;
57e41f4b71Sopenharmony_ci      let message = (err as BusinessError).message;
58e41f4b71Sopenharmony_ci      console.error(`openAtomicService failed, code is ${code}, message is ${message}`);
59e41f4b71Sopenharmony_ci    }
60e41f4b71Sopenharmony_ci  }
61e41f4b71Sopenharmony_ci}
62e41f4b71Sopenharmony_ci```
63