• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ProcessData
2
3The **ProcessData** module defines process data. If a lifecycle change listener is registered by calling [registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8), the **onProcessCreated** callback in [ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md) is invoked when the lifecycle of an application or ability changes.
4
5**System capability**: SystemCapability.Ability.AbilityRuntime.Core
6
7**System API**: This is a system API and cannot be called by third-party applications.
8
9| Name                    | Type    | Readable| Writable| Description                      |
10| ----------------------- | ---------| ---- | ---- | ------------------------- |
11| pid<sup>8+</sup>         | number   | Yes  | No  | Process ID.                   |
12| bundleName<sup>8+</sup>  | string   | Yes  | No | Bundle name of the application.                 |
13| uid<sup>8+</sup>         | number   | Yes  | No  | UID of the application.                 |
14| isContinuousTask<sup>9+</sup>         | boolean   | Yes  | No  | Whether the task is a continuous task. The value **true** means that the task is a continuous task, and **false** means the opposite.                |
15| isKeepAlive<sup>9+</sup>         | boolean   | Yes  | No  | Whether the process is a resident task. The value **true** means that the process is a resident, and **false** means the opposite.                  |
16
17**Example**
18```ts
19import appManager from '@ohos.application.appManager';
20
21let applicationStateObserver = {
22    onForegroundApplicationChanged(appStateData) {
23        console.log('onForegroundApplicationChanged appStateData: ' +  JSON.stringify(appStateData));
24    },
25    onAbilityStateChanged(abilityStateData) {
26        console.log('onAbilityStateChanged onAbilityStateChanged: ' +  JSON.stringify(abilityStateData));
27    },
28    onProcessCreated(processData) {
29        console.log('onProcessCreated onProcessCreated: '  +  JSON.stringify(processData));
30    },
31    onProcessDied(processData) {
32        console.log('onProcessDied onProcessDied: '  +  JSON.stringify(processData));
33    },
34    onProcessStateChanged(processData) {
35        console.log('onProcessStateChanged processData.pid : ' +  JSON.stringify(processData.pid));
36        console.log('onProcessStateChanged processData.bundleName : ' +  JSON.stringify(processData.bundleName));
37        console.log('onProcessStateChanged processData.uid : ' +  JSON.stringify(processData.uid));
38        console.log('onProcessStateChanged processData.isContinuousTask : ' +  JSON.stringify(processData.isContinuousTask));
39        console.log('onProcessStateChanged processData.isKeepAlive : ' +  JSON.stringify(processData.isKeepAlive));
40    }
41};
42let observerCode = appManager.registerApplicationStateObserver(applicationStateObserver);
43```
44