• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AbilityRunningInfo
2
3The AbilityRunningInfo module defines the running information and state of an ability.
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 { abilityManager } from '@kit.AbilityKit';
13```
14
15## Usage
16
17The ability running information is obtained by calling [getAbilityRunningInfos](js-apis-app-ability-abilityManager.md#getabilityrunninginfos) in **abilityManager**.
18
19## Properties
20
21**System capability**: SystemCapability.Ability.AbilityRuntime.Core
22
23| Name| Type| Readable| Writable| Description|
24| -------- | -------- | -------- | -------- | -------- |
25| ability | ElementName | Yes| No| Information that matches an ability. |
26| pid | number | Yes| No| Process ID.|
27| uid | number | Yes| No| User ID. |
28| processName | string | Yes| No| Process name. |
29| startTime | number | Yes| No| Ability start time. |
30| abilityState | [abilityManager.AbilityState](js-apis-app-ability-abilityManager.md#abilitystate) | Yes| No| Ability state. |
31
32**Example**
33
34```ts
35import { abilityManager } from '@kit.AbilityKit';
36import { BusinessError } from '@kit.BasicServicesKit';
37
38try {
39  abilityManager.getAbilityRunningInfos()
40    .then((data: abilityManager.AbilityRunningInfo[]) => {
41      for (let i = 0; i < data.length; i++) {
42        let abilityInfo = data[i];
43        console.info(`getAbilityRunningInfos success, data: ${JSON.stringify(abilityInfo)}`);
44      }
45    })
46    .catch((error: BusinessError) => {
47      console.error(`getAbilityRunningInfos fail, error code: ${JSON.stringify(error.code)}, error msg: ${JSON.stringify(error.message)}`);
48    })
49} catch (e) {
50  let code = (e as BusinessError).code;
51  let msg = (e as BusinessError).message;
52  console.error(`getAbilityRunningInfos fail, error code: ${JSON.stringify(code)}, error msg: ${JSON.stringify(msg)}`);
53}
54```
55