# OHOS::Ability - [Overview](#section686627827165632) - [Summary](#section182016991165632) - [Public Member Functions](#pub-methods) ## **Overview** **Related Modules:** [AbilityKit](AbilityKit.md) **Description:** Declares ability-related functions, including ability lifecycle callbacks and functions for connecting to or disconnecting from Particle Abilities. As the fundamental unit of OpenHarmony applications, abilities are classified into [Feature](Feature.md) Abilities and Particle Abilities. [Feature](Feature.md) Abilities support the Page template, and Particle Abilities support the [Service](Service.md) template. An ability using the Page template is called Page ability for short and that using the [Service](Service.md) template is called [Service](Service.md) ability. **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Public Member Functions
Called when this ability is started. You must override this function if you want to perform some initialization operations during ability startup. |
|
OnInactive () |
|
OnBackground () |
|
OnStop () |
|
Called when this Service ability is connected for the first time. |
|
OnDisconnect (const Want &want) |
Called when all abilities connected to this Service ability are disconnected. |
SetMainRoute (const std::string &entry) |
|
SetUIContent (RootView *rootView) |
Sets the UI layout for this ability. You can call GetWindowRootView() to create a layout and add controls. |
MsgHandle (uint32_t funcId, IpcIo *request, IpcIo *reply) |
Handles a message sent by the client to this Service ability. |
Dump (const std::string &extra) |
|
StartAbility (const Want &want) |
|
StopAbility (const Want &want) |
|
Destroys this Ability. |
|
ConnectAbility (const Want &want, const IAbilityConnection &conn, void *data) |
Connects to a Service ability based on the specified Want information. |
DisconnectAbility (const IAbilityConnection &conn) |
Disconnects from a Service ability. |