1# ServiceAbility Switching 2 3 4The ServiceAbility component in the FA model corresponds to the ServiceExtensionAbility component in the stage model. The ServiceExtensionAbility class provides system APIs. Only system applications can create ServiceExtensionAbility instances. Therefore, ServiceAbility switching adopts different policies for system applications and third-party applications. 5 6 7## Switching a ServiceAbility of a System Application 8 9The procedure for switching a ServiceAbility of a system application is similar to the procedure of PageAbility switching. 10 111. [Create a ServiceExtensionAbility](serviceextensionability.md) in the stage model. 12 132. Migrate the ServiceAbility code to the ServiceExtensionAbility. 14 15The table below describes the lifecycle comparison of the ServiceAbility and ServiceExtensionAbility. 16 17 | ServiceAbility| ServiceExtensionAbility| Comparison Description| 18 | -------- | -------- | -------- | 19 | onStart(): void | onCreate(want: Want): void | The two methods have the same invoking time. In the stage model, the **want** parameter is added so that you can obtain parameters during creation.| 20 | onCommand(want: Want, startId: number): void | onRequest(want: Want, startId: number): void | The two methods have the same meaning, invoking time, and parameters.| 21 | onConnect(want: Want): rpc.RemoteObject | onConnect(want: Want): rpc.RemoteObject | The two methods have the same meaning, invoking time, and parameters.| 22 | onDisconnect(want: Want): void | onDisconnect(want: Want): void | The two methods have the same meaning, invoking time, and parameters.| 23 | onReconnect(want: Want): void| onReconnect(want: Want): void| The two methods have the same meaning, invoking time, and parameters.| 24 | onStop(): void | onDestroy(): void | The two methods have the same meaning, invoking time, and parameters.| 25 26 27## Switching a ServiceAbility of a Third-Party Application 28 29In the stage model, third-party applications cannot provide services for other third-party applications. You can select a switching solution based on your service requirements. 30 31| Service Type| Switching Solution| 32| -------- | -------- | 33| Providing services for other third-party applications| Match a scenario-specific [ExtensionAbility](extensionability-overview.md).| 34| In-application: providing public use when it is running in the foreground| Extract the component code as a common module for other components to use.| 35| In-application: continuing running when it switches to the background| Switch the service to [a background service](serviceextensionability.md).| 36