未验证 提交 513460dc 编写于 作者: O openharmony_ci 提交者: Gitee

!7628 【元能力子系统】支持指定应用查询应用生命周期资料新增

Merge pull request !7628 from 周士成/master
......@@ -210,7 +210,7 @@ getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): vo
registerApplicationStateObserver(observer: ApplicationStateObserver): number;
注册应用程序状态观测器。
注册全部应用程序状态观测器。
**需要权限**:ohos.permission.RUNNING_STATE_OBSERVER
......@@ -244,6 +244,48 @@ registerApplicationStateObserver(observer: ApplicationStateObserver): number;
const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
```
## appManager.registerApplicationStateObserver<sup>9+</sup>
registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameList: Array<string>): number;
注册指定应用程序状态观测器。
**需要权限**:ohos.permission.RUNNING_STATE_OBSERVER
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| observer | ApplicationStateObserver | 否 | 返回观察者的数字代码。 |
| bundleNameList | Array<string> | 否 | 表示需要注册监听的bundleName数组。最大值128。 |
**示例:**
```js
var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
}
}
var bundleNameList = ['bundleName1', 'bundleName2'];
const observerCode = app.registerApplicationStateObserver(applicationStateObserver, bundleNameList);
console.log('-------- observerCode: ---------', observerCode);
```
## appManager.unregisterApplicationStateObserver<sup>8+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册