• 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';
13import { BusinessError } from '@ohos.base';
14
15featureAbility.startAbility(
16    {
17        want: {
18            bundleName: "com.ohos.stage",
19            abilityName: "EntryAbility"
20        }
21    }
22).then((code) => {
23    console.info('Ability verify code: ' + JSON.stringify(code));
24}).catch((error: BusinessError) => {
25    console.error("Ability failed: " + JSON.stringify(error));
26});
27```
28
29
30## PageAbility Accessing a UIAbility (startAbilityForResult)
31
32Different from **startAbility()**, **startAbilityForResult()** obtains the execution result when the UIAbility is destroyed.
33
34A PageAbility starts a UIAbility through **startAbilityForResult()** in the same way as it starts another PageAbility through **startAbilityForResult()**.
35
36
37```ts
38import featureAbility from '@ohos.ability.featureAbility';
39import { BusinessError } from '@ohos.base';
40
41featureAbility.startAbilityForResult(
42    {
43        want: {
44            bundleName: "com.ohos.stage",
45            abilityName: "com.ohos.stage.EntryAbility"
46        }
47    }).then((result) => {
48    console.info('Ability verify result: ' + JSON.stringify(result));
49}).catch((error: BusinessError) => {
50    console.error("Ability failed: " + JSON.stringify(error));
51});
52```
53
54
55## ServiceAbility or DataAbility Starting a UIAbility
56
57A ServiceAbility or DataAbility starts a UIAbility in the same way as it starts a PageAbility.
58
59
60```ts
61import particleAbility from '@ohos.ability.particleAbility';
62import { BusinessError } from '@ohos.base';
63
64particleAbility.startAbility(
65    {
66        want: {
67            bundleName: "com.ohos.stage",
68            abilityName: "com.ohos.stage.EntryAbility"
69        }
70    }
71).then(() => {
72    console.info('Start Ability successfully.');
73}).catch((error: BusinessError) => {
74    console.error("Ability failed: " + JSON.stringify(error));
75});
76```
77