1# @ohos.app.ability.Ability (Ability Base Class) 2 3This is the base class of [UIAbility](js-apis-app-ability-uiAbility.md) and [ExtensionAbility](js-apis-app-ability-extensionAbility.md). It provides the callbacks for system configuration updates and memory level updates. You cannot inherit from this base class. 4 5> **NOTE** 6> 7> 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. 8> 9> The APIs of this module can be used only in the stage model. 10 11## Modules to Import 12 13```ts 14import { Ability } from '@kit.AbilityKit'; 15``` 16 17## Ability Inheritance Relationship 18 19The following figure shows the inheritance relationship of a variety of abilities. 20 21> **NOTE** 22> 23> Some ExtensionAbilities (such as [FormExtensionAbility](../apis-form-kit/js-apis-app-form-formExtensionAbility.md) and [InputMethodExtensionAbility](../apis-ime-kit/js-apis-inputmethod-extension-ability.md)) do not inherit from the ExtensionAbility base class and therefore are not provided in the following figure. 24 25 26 27## Ability.onConfigurationUpdate 28 29onConfigurationUpdate(newConfig: Configuration): void 30 31Called when the configuration of the environment where the ability is running is updated. 32 33**Atomic service API**: This API can be used in atomic services since API version 11. 34 35**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore 36 37**Parameters** 38 39| Name| Type| Mandatory| Description| 40| -------- | -------- | -------- | -------- | 41| newConfig | [Configuration](js-apis-app-ability-configuration.md) | Yes| New configuration.| 42 43**Example** 44 ```ts 45// You are not allowed to inherit from the top-level base class Ability. Therefore, the derived class UIAbility is used as an example. 46import { UIAbility, Configuration } from '@kit.AbilityKit'; 47 48class MyUIAbility extends UIAbility { 49 onConfigurationUpdate(config: Configuration) { 50 console.log(`onConfigurationUpdate, config: ${JSON.stringify(config)}`); 51 } 52} 53 ``` 54 55## Ability.onMemoryLevel 56 57onMemoryLevel(level: AbilityConstant.MemoryLevel): void 58 59Called when the system adjusts the memory level. 60 61**Atomic service API**: This API can be used in atomic services since API version 11. 62 63**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore 64 65**Parameters** 66 67| Name| Type| Mandatory| Description| 68| -------- | -------- | -------- | -------- | 69| level | [AbilityConstant.MemoryLevel](js-apis-app-ability-abilityConstant.md#memorylevel) | Yes| New memory level.| 70 71**Example** 72 73 ```ts 74// You are not allowed to inherit from the top-level base class Ability. Therefore, the derived class UIAbility is used as an example. 75import { UIAbility, AbilityConstant } from '@kit.AbilityKit'; 76 77class MyUIAbility extends UIAbility { 78 onMemoryLevel(level: AbilityConstant.MemoryLevel) { 79 console.log(`onMemoryLevel, level: ${JSON.stringify(level)}`); 80 } 81} 82 ``` 83