提交 368c0192 编写于 作者: Z zhoushicheng

IssueNo: #I5K5L0

Signed-off-by: Nzhoushicheng <zhoushicheng2@huawei.com>
Change-Id: I19df814ab2a6abef01cd19995c6a1292f058d62a
上级 63f836a8
...@@ -210,7 +210,7 @@ getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): vo ...@@ -210,7 +210,7 @@ getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): vo
registerApplicationStateObserver(observer: ApplicationStateObserver): number; registerApplicationStateObserver(observer: ApplicationStateObserver): number;
注册应用程序状态观测器。 注册全部应用程序状态观测器。
**需要权限**:ohos.permission.RUNNING_STATE_OBSERVER **需要权限**:ohos.permission.RUNNING_STATE_OBSERVER
...@@ -244,6 +244,48 @@ registerApplicationStateObserver(observer: ApplicationStateObserver): number; ...@@ -244,6 +244,48 @@ registerApplicationStateObserver(observer: ApplicationStateObserver): number;
const observerCode = app.registerApplicationStateObserver(applicationStateObserver); const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode); 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> ## appManager.unregisterApplicationStateObserver<sup>8+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册