js-apis-inner-ability-startAbilityParameter.md 1.8 KB
Newer Older
M
m00512953 已提交
1 2
# StartAbilityParameter

D
dy_study 已提交
3
定义启动Ability参数,可以作为入参,调用[startAbility](js-apis-ability-featureAbility.md#featureabilitystartability)启动指定的Ability。
M
m00512953 已提交
4 5 6 7 8 9 10 11

> **说明:**
> 
> 本接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本接口仅可在FA模型下使用

**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.FAModel

D
merge  
donglin 已提交
12 13
| 名称               |   类型   | 必填   | 说明                                    |
| ------------------- | -------- | ---- | -------------------------------------- |
D
dy_study 已提交
14 15
| want                | [Want](js-apis-application-want.md)|   是   | 启动Ability的want信息。                     |
| abilityStartSetting | {[key: string]: any} | 否    | 启动Ability的特殊属性,当开发者启动Ability时,该属性可以作为调用中的输入参数传递。 |
M
m00512953 已提交
16 17 18 19 20 21 22

**示例:**
```ts
import featureAbility from '@ohos.ability.featureAbility'

let Want = {
    bundleName: "com.example.abilityStartSettingApp2",
23
    abilityName: "com.example.abilityStartSettingApp.EntryAbility",
M
m00512953 已提交
24 25 26 27 28 29 30 31 32 33
}

let abilityStartSetting ={
    [featureAbility.AbilityStartSetting.BOUNDS_KEY] : [100,200,300,400],
    [featureAbility.AbilityStartSetting.WINDOW_MODE_KEY] :
    featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED,
    [featureAbility.AbilityStartSetting.DISPLAY_ID_KEY] : 1,
}

let startAbilityParameter = {
Z
zhongjianfei 已提交
34 35
    want : Want,
    abilityStartSetting : abilityStartSetting
M
m00512953 已提交
36 37
}

D
dy_study 已提交
38 39 40 41 42
try {
    featureAbility.startAbility(startAbilityParameter, (err, data) => {
        console.log('errCode : ' + JSON.stringify(err));
        console.log('data : ' + JSON.stringify(data));
    });
M
m00512953 已提交
43 44 45 46
} catch(error) {
    console.log("startAbility error: " + JSON.stringify(error));
}
```