• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AbilityStateData
2
3The **AbilityStateData** module defines the ability state information, which can be obtained through the **onAbilityStateChanged** lifecycle callback of [ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md). The callback can be invoked after a lifecycle change listener is registered through [registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8).
4
5**System capability**: SystemCapability.Ability.AbilityRuntime.Core
6
7| Name                    | Type    | Readable| Writable| Description                      |
8| ----------------------- | ---------| ---- | ---- | ------------------------- |
9| pid<sup>8+</sup>                     | number   | Yes  | No  | Process ID.                   |
10| bundleName<sup>8+</sup>              | string   | Yes  | No | Bundle name.         |
11| abilityName<sup>8+</sup>             | string   | Yes  | No  | Ability name.              |
12| uid<sup>8+</sup>                     | number   | Yes  | No  | User ID.                 |
13| state<sup>8+</sup>                   | number   | Yes  | No  | [Ability state](#ability-states).               |
14| moduleName<sup>9+</sup> | string   | Yes  | No  | Name of the HAP file to which the ability belongs.   |
15| abilityType<sup>8+</sup> | number | Yes  | No  | [Ability type](#ability-types), which can be **page** or **service**.|
16
17#### Ability States
18
19| Value  | State                      | Description                  |
20| ---- | -------------------------- | ---------------------- |
21| 0    | ABILITY_STATE_CREATE       | The ability is being created.     |
22| 1    | ABILITY_STATE_READY        | The ability has been created.     |
23| 2    | ABILITY_STATE_FOREGROUND   | The ability is running in the foreground.       |
24| 3    | ABILITY_STATE_FOCUS        | The ability has focus.       |
25| 4    | ABILITY_STATE_BACKGROUND   | The ability is running in the background.       |
26| 5    | ABILITY_STATE_TERMINATED   | The ability is terminated.       |
27| 8    | ABILITY_STATE_CONNECTED    | The background service is connected to the client.|
28| 9    | ABILITY_STATE_DISCONNECTED | The background service is disconnected from the client.|
29
30#### Ability Types
31
32| Value  | Status   | Description                 |
33| ---- | ------- | --------------------- |
34| 0    | UNKNOWN | Unknown type.             |
35| 1    | PAGE    | Ability that has the UI.  |
36| 2    | SERVICE | Ability that provides the background service.|
37