AbilityStateData

The AbilityStateData module defines the ability state information, which can be obtained through the onAbilityStateChanged lifecycle callback of ApplicationStateObserver. The callback can be invoked after a lifecycle change listener is registered through registerApplicationStateObserver.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Name Type Readable Writable Description
pid8+ number Yes No Process ID.
bundleName8+ string Yes No Bundle name.
abilityName8+ string Yes No Ability name.
uid8+ number Yes No User ID.
state8+ number Yes No Ability state.
moduleName9+ string Yes No Name of the HAP file to which the ability belongs.
abilityType8+ number Yes No Ability type, which can be page or service.

Ability States

Value State Description
0 ABILITY_STATE_CREATE The ability is being created.
1 ABILITY_STATE_READY The ability has been created.
2 ABILITY_STATE_FOREGROUND The ability is running in the foreground.
3 ABILITY_STATE_FOCUS The ability has focus.
4 ABILITY_STATE_BACKGROUND The ability is running in the background.
5 ABILITY_STATE_TERMINATED The ability is terminated.
8 ABILITY_STATE_CONNECTED The background service is connected to the client.
9 ABILITY_STATE_DISCONNECTED The background service is disconnected from the client.

Ability Types

Value Status Description
0 UNKNOWN Unknown type.
1 PAGE Ability that has the UI.
2 SERVICE Ability that provides the background service.