harmony 鸿蒙@ohos.application.ExtensionAbility (ExtensionAbility)

  • 2022-12-22
  • 浏览 (536)

@ohos.application.ExtensionAbility (ExtensionAbility)

The ExtensionAbility module manages the ExtensionAbility lifecycle and context, such as creating and destroying an ExtensionAbility, and dumping client information.

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. The APIs of this module can be used only in the stage model.

Modules to Import

import ExtensionAbility from '@ohos.application.ExtensionAbility';

ExtensionAbility.onConfigurationUpdated

onConfigurationUpdated(newConfig: Configuration): void;

Called when the configuration of the environment where the ability is running is updated.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Parameters

Name Type Mandatory Description
newConfig Configuration Yes New configuration.

Example

  class MyExtensionAbility extends ExtensionAbility {
      onConfigurationUpdated(config) {
          console.log('onConfigurationUpdated, config:' + JSON.stringify(config));
      }
  }

ExtensionAbility.onMemoryLevel

onMemoryLevel(level: AbilityConstant.MemoryLevel): void;

Called when the system has decided to adjust the memory level. For example, this API can be used when there is not enough memory to run as many background processes as possible.

System capability: SystemCapability.Ability.AbilityRuntime.AbilityCore

Parameters

Name Type Mandatory Description
level AbilityConstant.MemoryLevel Yes Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.

Example

  class MyExtensionAbility extends ExtensionAbility {
    onMemoryLevel(level) {
        console.log('onMemoryLevel, level:' + JSON.stringify(level));
    } 
  }

你可能感兴趣的鸿蒙文章

harmony 鸿蒙APIs

harmony 鸿蒙System Common Events

harmony 鸿蒙System Common Events

harmony 鸿蒙API Reference Document Description

harmony 鸿蒙BundleStatusCallback

harmony 鸿蒙@ohos.bundle.innerBundleManager (innerBundleManager)

harmony 鸿蒙@ohos.distributedBundle (Distributed Bundle Management)

harmony 鸿蒙@ohos.bundle (Bundle)

harmony 鸿蒙@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)

harmony 鸿蒙@ohos.WorkSchedulerExtensionAbility (Work Scheduler Callbacks)

0  赞