js-apis-inner-application-extensionRunningInfo.md 2.4 KB
Newer Older
1 2
# ExtensionRunningInfo

G
Gloria 已提交
3
The **ExtensionRunningInfo** module provides APIs for setting and querying ExtensionAbility running information, which can be obtained through [getExtensionRunningInfos](js-apis-app-ability-abilityManager.md#getextensionrunninginfos).
4 5 6

> **NOTE**
> 
G
Gloria 已提交
7 8 9 10 11 12 13 14
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module are system APIs and cannot be called by third-party applications.

## Modules to Import

```ts
import abilityManager from '@ohos.app.ability.abilityManager';
```
15 16 17

## Usage

G
Gloria 已提交
18
The ExtensionAbility running information is obtained through an **abilityManager** instance.
19 20 21 22 23 24 25

## Attributes

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
G
Gloria 已提交
26
| extension | ElementName | Yes| No| ExtensionAbility information..|
27
| pid | number | Yes| No| Process ID.|
G
Gloria 已提交
28
| uid | number | Yes| No| User ID.|
29
| processName | string | Yes| No| Process name.|
G
Gloria 已提交
30
| startTime | number | Yes| No| Start time of the ExtensionAbility.|
31
| clientPackage | Array<String> | Yes| No| Names of all packages in the process.|
32
| type | [bundle.ExtensionAbilityType](js-apis-Bundle.md) | Yes| No| ExtensionAbility type.|
33 34 35

**Example**
```ts
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
import abilityManager from '@ohos.application.abilityManager';
let upperLimit = 1;
abilityManager.getExtensionRunningInfos(upperLimit, (err,data) => {
    console.log('getExtensionRunningInfos err: '  + err + ' data: ' + JSON.stringify(data));
    for (let i = 0; i < data.length; i++) {
        let extensionRunningInfo = data[i];
        console.log('extensionRunningInfo.extension: ' + JSON.stringify(extensionRunningInfo.extension));
        console.log('extensionRunningInfo.pid: ' + JSON.stringify(extensionRunningInfo.pid));
        console.log('extensionRunningInfo.uid: ' + JSON.stringify(extensionRunningInfo.uid));
        console.log('extensionRunningInfo.processName: ' + JSON.stringify(extensionRunningInfo.processName));
        console.log('extensionRunningInfo.startTime: ' + JSON.stringify(extensionRunningInfo.startTime));
        console.log('extensionRunningInfo.clientPackage: ' + JSON.stringify(extensionRunningInfo.clientPackage));
        console.log('extensionRunningInfo.type: ' + JSON.stringify(extensionRunningInfo.type));
    }
});
51
```