• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# StartAbilityParameter
2
3The **StartAbilityParameter** module defines the parameters for starting an ability. The parameters can be used as input parameters in [startAbility](js-apis-ability-featureAbility.md#featureabilitystartability) to start the specified ability.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9> The APIs of this module can be used only in the FA model.
10
11## Modules to Import
12
13```ts
14import ability from '@ohos.ability.ability';
15```
16
17## Attributes
18
19**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
20
21| Name              |   Type  | Mandatory  | Description                                   |
22| ------------------- | -------- | ---- | -------------------------------------- |
23| want                | [Want](js-apis-app-ability-want.md)|   Yes  | Want information about the target ability.                    |
24| abilityStartSetting | { [key: string]: any } | No   | Special attribute of the target ability. This attribute can be passed in the call.|
25| abilityStartSettings<sup>11+<sup> | Record\<string, Object> | No   | Special attribute of the target ability. This attribute can be passed in the call. You are advised to use this attribute to replace **abilityStartSetting**. When this attribute is set, **abilityStartSetting** does not take effect.|
26
27**Example**
28
29<!--code_no_check_fa-->
30```ts
31import ability from '@ohos.ability.ability';
32import featureAbility from '@ohos.ability.featureAbility';
33import Want from '@ohos.app.ability.Want';
34
35let want: Want = {
36    bundleName: 'com.example.abilityStartSettingApp2',
37    abilityName: 'com.example.abilityStartSettingApp.EntryAbility',
38};
39
40let startAbilityParameter: ability.StartAbilityParameter = {
41    want : want,
42    abilityStartSettings : {
43        abilityBounds : [100,200,300,400],
44        windowMode :
45        featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED,
46        displayId : 1,
47    }
48};
49
50try {
51    featureAbility.startAbility(startAbilityParameter, (error, data) => {
52        if (error && error.code !== 0) {
53            console.error(`startAbility fail, error: ${JSON.stringify(error)}`);
54        } else {
55            console.log(`startAbility success, data: ${JSON.stringify(data)}`);
56        }
57    });
58} catch(error) {
59    console.error(`startAbility error: ${JSON.stringify(error)}`);
60}
61```
62