• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Starting a UIAbility from the FA Model
2
3
4This topic describes how the three application components of the FA model start the UIAbility component of the stage model.
5
6
7## PageAbility Starting a UIAbility
8
9A PageAbility starts a UIAbility in the same way as it starts another PageAbility.
10
11```ts
12import featureAbility from '@ohos.ability.featureAbility';
13
14let parameter = {
15    "want": {
16        bundleName: "com.ohos.stage",
17        abilityName: "com.ohos.stage.EntryAbility"
18    }
19};
20featureAbility.startAbility(parameter).then((code) => {
21    console.info('Ability verify code: ' + JSON.stringify(code));
22}).catch((error) => {
23    console.error("Ability failed: " + JSON.stringify(error));
24});
25```
26
27
28## PageAbility Accessing a UIAbility (startAbilityForResult)
29
30Different from **startAbility()**, **startAbilityForResult()** obtains the execution result when the UIAbility is destroyed.
31
32A PageAbility starts a UIAbility through **startAbilityForResult()** in the same way as it starts another PageAbility through **startAbilityForResult()**.
33
34
35```ts
36import featureAbility from '@ohos.ability.featureAbility';
37
38let parameter = {
39    "want": {
40        bundleName: "com.ohos.stage",
41        abilityName: "com.ohos.stage.EntryAbility"
42    }
43};
44featureAbility.startAbilityForResult(parameter).then((result) => {
45    console.info('Ability verify result: ' + JSON.stringify(result));
46}).catch((error) => {
47    console.error("Ability failed: " + JSON.stringify(error));
48});
49```
50
51
52## ServiceAbility or DataAbility Starting a UIAbility
53
54A ServiceAbility or DataAbility starts a UIAbility in the same way as it starts a PageAbility.
55
56
57```ts
58import particleAbility from '@ohos.ability.particleAbility';
59
60let parameter = {
61    "want": {
62        bundleName: "com.ohos.stage",
63        abilityName: "com.ohos.stage.EntryAbility"
64    }
65};
66particleAbility.startAbility(parameter).then(() => {
67    console.info('Start Ability successfully.');
68}).catch((error) => {
69    console.error("Ability failed: " + JSON.stringify(error));
70});
71```
72