• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AbilityStateData
2
3The 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 [on](js-apis-app-ability-appManager.md#appmanageronapplicationstate14).
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 14. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10
11```ts
12import { appManager } from '@kit.AbilityKit';
13```
14
15## Properties
16
17**System capability**: SystemCapability.Ability.AbilityRuntime.Core
18
19| Name                    | Type    | Read-Only| Optional| Description                      |
20| ----------------------- | ---------| ---- | ---- | ------------------------- |
21| pid                     | number   | No  | No  | Process ID.                   |
22| bundleName              | string   | No  | No | Bundle name.         |
23| abilityName            | string   | No  | No  | Ability name.              |
24| uid                    | number   | No  | No  | User ID.                 |
25| state                   | number   | No  | No  | Ability state.<br>- In the stage model, the states of a UIAbility are described in [Ability States](#ability-states), and the states of an ExtensionAbility are described in [ExtensionAbility States](#extensionability-states).<br>- In the FA model, the states of an ability are described in [Ability States](#ability-states).               |
26| moduleName | string   | No  | No  | Name of the HAP file to which the ability belongs.   |
27| abilityType | number | No  | No  | [Ability type](#ability-types), which can be **page** or **service**.|
28| isAtomicService | boolean   | No | No | Whether the ability belongs to an atomic service.<br>- **true**: The ability belongs to an atomic service.<br>- **false**: The ability does not belong to an atomic service.    |
29| appCloneIndex          | number   | No  | Yes  | Index of an application clone.                 |
30
31### Ability States
32
33| State                       | Value | Description                   |
34| --------------------------  | --- | ---------------------- |
35| ABILITY_STATE_CREATE        | 0   |  The ability is being created.   |
36| ABILITY_STATE_READY         | 1   |  The ability has been created.   |
37| ABILITY_STATE_FOREGROUND    | 2   |  The ability is running in the foreground.     |
38| ABILITY_STATE_FOCUS         | 3   |   The ability has focus.    |
39| ABILITY_STATE_BACKGROUND    | 4   |  The ability is running in the background.     |
40| ABILITY_STATE_TERMINATED    | 5   |  The ability is terminated.     |
41| ABILITY_STATE_CONNECTED     | 7   |  The background service is connected to the client.|
42| ABILITY_STATE_DISCONNECTED  | 8   |  The background service is disconnected from the client.|
43
44### ExtensionAbility States
45| State                  | Value| Description                  |
46| ---------------------- | ---- | ---------------------- |
47| EXTENSION_STATE_CREATE | 0   | The ExtensionAbility is being created. |
48| EXTENSION_STATE_READY  | 1   | The ExtensionAbility has been created. |
49| EXTENSION_STATE_CONNECTED | 2  | The ExtensionAbility is connected to the client. |
50| EXTENSION_STATE_DISCONNECTED | 3 | The ExtensionAbility is disconnected from the client.|
51| EXTENSION_STATE_TERMINATED | 4  | The ExtensionAbility is terminated. |
52
53### Ability Types
54
55| State   | Value     | Description                 |
56| ------  | ------- | --------------------- |
57| UNKNOWN | 0 | Unknown type.             |
58| PAGE    | 1 | Ability that has the UI.  |
59| SERVICE | 2 | Ability that provides the background service.|
60| DATA    | 3 | Ability that provides the data service.             |
61| FORM    | 4 | Ability that provides the widget service.  |
62| EXTENSION | 5 | Ability that provides extension capabilities.|
63