1e41f4b71Sopenharmony_ci# ServiceAbility Switching 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ciThe 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. 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci## Switching a ServiceAbility for a System Application 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ciThe procedure for switching a ServiceAbility for a system application is similar to the procedure of PageAbility switching. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci1. [Create a ServiceExtensionAbility](serviceextensionability.md) in the stage model. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci2. Migrate the ServiceAbility code to the ServiceExtensionAbility. 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ciThe table below describes the lifecycle comparison of the ServiceAbility and ServiceExtensionAbility. 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci| ServiceAbility| ServiceExtensionAbility| Comparison Description| 19e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 20e41f4b71Sopenharmony_ci| 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.| 21e41f4b71Sopenharmony_ci| onCommand(want: Want, startId: number): void | onRequest(want: Want, startId: number): void | The two methods have the same meaning, invoking time, and parameters.| 22e41f4b71Sopenharmony_ci| onConnect(want: Want): rpc.RemoteObject | onConnect(want: Want): rpc.RemoteObject | The two methods have the same meaning, invoking time, and parameters.| 23e41f4b71Sopenharmony_ci| onDisconnect(want: Want): void | onDisconnect(want: Want): void | The two methods have the same meaning, invoking time, and parameters.| 24e41f4b71Sopenharmony_ci| onReconnect(want: Want): void| onReconnect(want: Want): void| The two methods have the same meaning, invoking time, and parameters.| 25e41f4b71Sopenharmony_ci| onStop(): void | onDestroy(): void | The two methods have the same meaning, invoking time, and parameters.| 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci## Switching a ServiceAbility for a Third-Party Application 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ciIn 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. 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci| Service Type| Switching Solution| 33e41f4b71Sopenharmony_ci| -------- | -------- | 34e41f4b71Sopenharmony_ci| Providing services for other third-party applications| Match a scenario-specific [ExtensionAbility](extensionability-overview.md).| 35e41f4b71Sopenharmony_ci| 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.| 36e41f4b71Sopenharmony_ci| In-application: continuing running when it switches to the background| Switch the service to a [background service](serviceextensionability.md).| 37