• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AbilityStateData (System API)
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-sys.md). The callback can be invoked after a lifecycle change listener is registered through [on](js-apis-app-ability-appManager-sys.md#appmanageronappforegroundstate11).
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8> The APIs provided by this module are system APIs.
9
10## Modules to Import
11
12```ts
13import { appManager } from '@kit.AbilityKit';
14```
15
16## Properties
17
18**System capability**: SystemCapability.Ability.AbilityRuntime.Core
19
20**System API**: This is a system API and cannot be called by third-party applications.
21
22| Name                    | Type    | Readable| Writable| Description                      |
23| ----------------------- | ---------| ---- | ---- | ------------------------- |
24| pid                     | number   | Yes  | No  | Process ID.                   |
25| bundleName              | string   | Yes  | No | Bundle name.         |
26| abilityName            | string   | Yes  | No  | Ability name.              |
27| uid                    | number   | Yes  | No  | User ID.                 |
28| state                   | number   | Yes  | No  | [Ability state](#ability-states).               |
29| moduleName<sup>9+</sup> | string   | Yes  | No  | Name of the HAP file to which the ability belongs.   |
30| abilityType | number | Yes  | No  | [Ability type](#ability-types), which can be **page** or **service**.|
31| isAtomicService<sup>12+</sup>| boolean   | Yes | 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.    |
32| appCloneIndex          | number   | Yes  | No  | Index of an application clone.                 |
33
34#### Ability States
35
36| Value  | State                      | Description                  |
37| ---- | -------------------------- | ---------------------- |
38| 0    | ABILITY_STATE_CREATE       | The ability is being created.     |
39| 1    | ABILITY_STATE_READY        | The ability has been created.     |
40| 2    | ABILITY_STATE_FOREGROUND   | The ability is running in the foreground.       |
41| 3    | ABILITY_STATE_FOCUS        | The ability has focus.       |
42| 4    | ABILITY_STATE_BACKGROUND   | The ability is running in the background.       |
43| 5    | ABILITY_STATE_TERMINATED   | The ability is terminated.       |
44| 8    | ABILITY_STATE_CONNECTED    | The background service is connected to the client.|
45| 9    | ABILITY_STATE_DISCONNECTED | The background service is disconnected from the client.|
46
47#### Ability Types
48
49| Value  | State   | Description                 |
50| ---- | ------- | --------------------- |
51| 0    | UNKNOWN | Unknown type.             |
52| 1    | PAGE    | Ability that has the UI.  |
53| 2    | SERVICE | Ability that provides the background service.|
54| 3    | DATA | Ability that provides the data service.             |
55| 4    | FORM    | Ability that provides the widget service.  |
56| 5    | EXTENSION | Ability that provides extension capabilities.|
57