1e41f4b71Sopenharmony_ci# ProcessData (系统接口)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci进程数据的对象定义。使用接口[registerApplicationStateObserver](js-apis-application-appManager-sys.md#appmanagerregisterapplicationstateobserver)注册生命周期变化监听后,当应用或组件的生命周期变化时,系统通过[ApplicationStateObserver](js-apis-inner-application-applicationStateObserver-sys.md)的onProcessCreated等方法回调给开发者。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **说明:**
6e41f4b71Sopenharmony_ci> 
7e41f4b71Sopenharmony_ci> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8e41f4b71Sopenharmony_ci> 本模块接口为系统接口。
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## 导入模块
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci```ts
13e41f4b71Sopenharmony_ciimport { appManager } from '@kit.AbilityKit';
14e41f4b71Sopenharmony_ci```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci## 属性
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci**系统API**:该接口为系统接口,三方应用不支持调用。
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci| 名称                     | 类型     | 只读 | 必填 | 说明                       |
23e41f4b71Sopenharmony_ci| ----------------------- | ---------| ---- | ---- | ------------------------- |
24e41f4b71Sopenharmony_ci| pid         | number   | 否   | 是   | 进程ID。                    |
25e41f4b71Sopenharmony_ci| bundleName  | string   | 否   | 是  | 应用包名。                  |
26e41f4b71Sopenharmony_ci| uid         | number   | 否   | 是   | 应用的uid。                  |
27e41f4b71Sopenharmony_ci| isContinuousTask<sup>9+</sup>         | boolean   | 否   | 是   | 是否为长时任务,true表示是,false表示不是。                 |
28e41f4b71Sopenharmony_ci| isKeepAlive<sup>9+</sup>         | boolean   | 否   | 是   | 是否为常驻进程,true表示是,false表示不是                   |
29e41f4b71Sopenharmony_ci| state<sup>9+</sup>       | number   | 否   | 是   | 应用的状态,取值及对应的状态为:<br>0 - 刚创建,<br>1 - 准备就绪,<br>2 - 前台,<br>4 - 后台,<br>5 - 已终止。     |
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci**示例:**
32e41f4b71Sopenharmony_ci```ts
33e41f4b71Sopenharmony_ciimport { appManager } from '@kit.AbilityKit';
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_cilet observerCode = appManager.on('applicationState', {
36e41f4b71Sopenharmony_ci  onForegroundApplicationChanged(appStateData) {
37e41f4b71Sopenharmony_ci    console.log(`onForegroundApplicationChanged appStateData: ${JSON.stringify(appStateData)}`);
38e41f4b71Sopenharmony_ci  },
39e41f4b71Sopenharmony_ci  onAbilityStateChanged(abilityStateData) {
40e41f4b71Sopenharmony_ci    console.log(`onAbilityStateChanged onAbilityStateChanged: ${JSON.stringify(abilityStateData)}`);
41e41f4b71Sopenharmony_ci  },
42e41f4b71Sopenharmony_ci  onProcessCreated(processData) {
43e41f4b71Sopenharmony_ci    console.log(`onProcessCreated onProcessCreated: ${JSON.stringify(processData)}`);
44e41f4b71Sopenharmony_ci  },
45e41f4b71Sopenharmony_ci  onProcessDied(processData) {
46e41f4b71Sopenharmony_ci    console.log(`onProcessDied onProcessDied: ${JSON.stringify(processData)}`);
47e41f4b71Sopenharmony_ci  },
48e41f4b71Sopenharmony_ci  onProcessStateChanged(processData) {
49e41f4b71Sopenharmony_ci    console.log(`onProcessStateChanged processData.pid : ${JSON.stringify(processData.pid)}`);
50e41f4b71Sopenharmony_ci    console.log(`onProcessStateChanged processData.bundleName : ${JSON.stringify(processData.bundleName)}`);
51e41f4b71Sopenharmony_ci    console.log(`onProcessStateChanged processData.uid : ${JSON.stringify(processData.uid)}`);
52e41f4b71Sopenharmony_ci    console.log(`onProcessStateChanged processData.isContinuousTask : ${JSON.stringify(processData.isContinuousTask)}`);
53e41f4b71Sopenharmony_ci    console.log(`onProcessStateChanged processData.isKeepAlive : ${JSON.stringify(processData.isKeepAlive)}`);
54e41f4b71Sopenharmony_ci  },
55e41f4b71Sopenharmony_ci  onAppStarted(appStateData) {
56e41f4b71Sopenharmony_ci    console.log(`onAppStarted appStateData: ${JSON.stringify(appStateData)}`);
57e41f4b71Sopenharmony_ci  },
58e41f4b71Sopenharmony_ci  onAppStopped(appStateData) {
59e41f4b71Sopenharmony_ci    console.log(`onAppStopped appStateData: ${JSON.stringify(appStateData)}`);
60e41f4b71Sopenharmony_ci  }
61e41f4b71Sopenharmony_ci});
62e41f4b71Sopenharmony_ci```