1# API Switching Overview
2
3
4Due to the differences in the thread model and process model, certain APIs can be used only in the FA model. They are marked with **FAModelOnly** in the SDK. When switching an application from the FA model to the stage model, replace the APIs marked with **FAModelOnly** in the application with the APIs supported in the stage model. This topic uses the switching of **startAbility()** as an example.
5
6![api-switch-overview](figures/api-switch-overview.png)
7
8
9
10- Sample code of **startAbility()** in the FA model:
11
12  ```ts
13  import featureAbility from '@ohos.ability.featureAbility';
14  import Want from '@ohos.app.ability.Want';
15  import hilog from '@ohos.hilog';
16
17  const TAG: string = 'PagePageAbilityFirst';
18  const domain: number = 0xFF00;
19
20  @Entry
21  @Component
22  struct PagePageAbilityFirst {
23
24    build() {
25      Column() {
26        List({ initialIndex: 0 }) {
27          ListItem() {
28            Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
29              //...
30            }
31            .onClick(() => {
32              (async (): Promise<void> => {
33                try {
34                  hilog.info(domain, TAG, 'Begin to start ability');
35                  let want: Want = {
36                    bundleName: 'com.samples.famodelabilitydevelop',
37                    moduleName: 'entry',
38                    abilityName: 'com.samples.famodelabilitydevelop.PageAbilitySingleton'
39                  };
40                  await featureAbility.startAbility({ want: want });
41                  hilog.info(domain, TAG, `Start ability succeed`);
42                }
43                catch (error) {
44                  hilog.error(domain, TAG, 'Start ability failed with ' + error);
45                }
46              })()
47            })
48          }
49          //...
50        }
51        //...
52      }
53      //...
54    }
55  }
56
57  ```
58
59- Sample code of **startAbility()** in the stage model:
60
61  ```ts
62  import hilog from '@ohos.hilog';
63  import Want from '@ohos.app.ability.Want';
64  import common from '@ohos.app.ability.common';
65  import { BusinessError } from '@ohos.base';
66  import { Caller } from '@ohos.app.ability.UIAbility';
67
68  const TAG: string = '[Page_UIAbilityComponentsInteractive]';
69  const DOMAIN_NUMBER: number = 0xFF00;
70
71  @Entry
72  @Component
73  struct Page_UIAbilityComponentsInteractive {
74    private context = getContext(this) as common.UIAbilityContext;
75    caller: Caller | undefined = undefined;
76    build() {
77      Column() {
78        //...
79        List({ initialIndex: 0 }) {
80          ListItem() {
81            Row() {
82              //...
83            }
84            .onClick(() => {
85              // Context is a member of the ability object and is required for invoking inside a non-ability object.
86              // Pass in the Context object.
87              let wantInfo: Want = {
88                deviceId: '', // An empty deviceId indicates the local device.
89                bundleName: 'com.samples.stagemodelabilitydevelop',
90                moduleName: 'entry', // moduleName is optional.
91                abilityName: 'FuncAbilityA',
92                parameters: { // Custom information.
93                  info: 'From the UIAbilityComponentsInteractive page of EntryAbility',
94                },
95              };
96              // context is the UIAbilityContext of the initiator UIAbility.
97              this.context.startAbility(wantInfo).then(() => {
98                hilog.info(DOMAIN_NUMBER, TAG, 'startAbility success.');
99              }).catch((error: BusinessError) => {
100                hilog.error(DOMAIN_NUMBER, TAG, 'startAbility failed.');
101              });
102            })
103          }
104          //...
105        }
106        //...
107      }
108      //...
109    }
110  }
111  ```
112