harmony 鸿蒙AbilityStateData

  • 2025-06-12
  • 浏览 (4)

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 on.

NOTE

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.

Modules to Import

import { appManager } from '@kit.AbilityKit';

Properties

System capability: SystemCapability.Ability.AbilityRuntime.Core

Name Type Readable Writable Description
pid number Yes No Process ID.
bundleName string Yes No Bundle name.
abilityName string Yes No Ability name.
uid number Yes No User ID.
state number Yes No Ability state.
- In the stage model, the states of a UIAbility are described in Ability States, and the states of an ExtensionAbility are described in ExtensionAbility States.
- In the FA model, the states of an ability are described in Ability States.
moduleName string Yes No Name of the HAP file to which the ability belongs.
abilityType number Yes No Ability type, which can be page or service.
isAtomicService boolean Yes No Whether the ability belongs to an atomic service.
true: The ability belongs to an atomic service.
false: The ability does not belong to an atomic service.
appCloneIndex number Yes No Index of an application clone.

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.
7 ABILITY_STATE_CONNECTED The background service is connected to the client.
8 ABILITY_STATE_DISCONNECTED The background service is disconnected from the client.

ExtensionAbility States

Value State Description
0 EXTENSION_STATE_CREATE The ExtensionAbility is being created.
1 EXTENSION_STATE_READY The ExtensionAbility has been created.
2 EXTENSION_STATE_CONNECTED The ExtensionAbility is connected to the client.
3 EXTENSION_STATE_DISCONNECTED The ExtensionAbility is disconnected from the client.
4 EXTENSION_STATE_TERMINATED The ExtensionAbility is terminated.

Ability Types

Value Type Description
0 UNKNOWN Unknown type.
1 PAGE Ability that has the UI.
2 SERVICE Ability that provides the background service.
3 DATA Ability that provides the data service.
4 FORM Ability that provides the widget service.
5 EXTENSION Ability that provides extension capabilities.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Ability Kit

harmony 鸿蒙AbilityAccessControl

harmony 鸿蒙AbilityBase

harmony 鸿蒙AbilityBase_Element

harmony 鸿蒙AbilityRuntime

harmony 鸿蒙bundle

harmony 鸿蒙OH_NativeBundle_ApplicationInfo

harmony 鸿蒙OH_NativeBundle_ElementName

harmony 鸿蒙ability_access_control.h

harmony 鸿蒙ability_base_common.h

0  赞