harmony(鸿蒙)AbilityMonitor
AbilityMonitor
The AbilityMonitor module provides monitors for abilities that meet specified conditions. The latest matched abilities are stored in an AbilityMonitor object.
NOTE
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.
Usage
The ability monitor is set by calling addAbilityMonitor in abilityDelegator.
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.addAbilityMonitor(monitor, (err : any) => {
console.info("addAbilityMonitor callback");
});
AbilityMonitor
Describes an ability monitor.
System capability: SystemCapability.Ability.AbilityRuntime.Core
Name | Type | Readable | Writable | Description |
---|---|---|---|---|
abilityName | string | Yes | Yes | Name of the ability bound to the ability monitor. |
onAbilityCreate?:(data: Ability) | function | Yes | Yes | Called when the ability is created. If this attribute is not set, the corresponding lifecycle callback cannot be received. |
onAbilityForeground?:(data: Ability) | function | Yes | Yes | Called when the ability starts to run in the foreground. If this attribute is not set, the corresponding lifecycle callback cannot be received. |
onAbilityBackground?:(data: Ability) | function | Yes | Yes | Called when the ability starts to run in the background. If this attribute is not set, the corresponding lifecycle callback cannot be received. |
onAbilityDestroy?:(data: Ability) | function | Yes | Yes | Called when the ability is destroyed. If this attribute is not set, the corresponding lifecycle callback cannot be received. |
onWindowStageCreate?:(data: Ability) | function | Yes | Yes | Called when the window stage is created. If this attribute is not set, the corresponding lifecycle callback cannot be received. |
onWindowStageRestore?:(data: Ability) | function | Yes | Yes | Called when the window stage is restored. If this attribute is not set, the corresponding lifecycle callback cannot be received. |
onWindowStageDestroy?:(data: Ability) | function | Yes | Yes | Called when the window stage is destroyed. If this attribute is not set, the corresponding lifecycle callback cannot be received. |
你可能感兴趣的鸿蒙文章
harmony(鸿蒙)API Reference Document Description
harmony(鸿蒙)BundleStatusCallback
harmony(鸿蒙)innerBundleManager(deprecated)
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦