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