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> The APIs of this module can be used only in the stage model. 9 10## Modules to Import 11 12```ts 13import Ability from '@ohos.app.ability.Ability'; 14``` 15 16## Ability.onConfigurationUpdate 17 18onConfigurationUpdate(newConfig: Configuration): void; 19 20Called when the configuration of the environment where the ability is running is updated. 21 22**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore 23 24**Parameters** 25 26| Name| Type| Mandatory| Description| 27| -------- | -------- | -------- | -------- | 28| newConfig | [Configuration](js-apis-app-ability-configuration.md) | Yes| New configuration.| 29 30**Example** 31 ```ts 32// You are not allowed to inherit from the top-level base class Ability. Therefore, the derived class UIAbility is used as an example. 33import UIAbility from '@ohos.app.ability.UIAbility'; 34import { Configuration } from '@ohos.app.ability.Configuration'; 35 36class MyUIAbility extends UIAbility { 37 onConfigurationUpdate(config: Configuration) { 38 console.log(`onConfigurationUpdate, config: ${JSON.stringify(config)}`); 39 } 40} 41 ``` 42 43## Ability.onMemoryLevel 44 45onMemoryLevel(level: AbilityConstant.MemoryLevel): void; 46 47Called when the system adjusts the memory level. 48 49**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore 50 51**Parameters** 52 53| Name| Type| Mandatory| Description| 54| -------- | -------- | -------- | -------- | 55| level | [AbilityConstant.MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel) | Yes| New memory level.| 56 57**Example** 58 59 ```ts 60// You are not allowed to inherit from the top-level base class Ability. Therefore, the derived class UIAbility is used as an example. 61import UIAbility from '@ohos.app.ability.UIAbility'; 62import AbilityConstant from '@ohos.app.ability.AbilityConstant'; 63 64class MyUIAbility extends UIAbility { 65 onMemoryLevel(level: AbilityConstant.MemoryLevel) { 66 console.log(`onMemoryLevel, level: ${JSON.stringify(level)}`); 67 } 68} 69 ``` 70