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