1# @ohos.application.Configuration (Configuration) 2 3The **Configuration** module defines environment change information. **Configuration** is an interface definition and is used only for field declaration. 4 5> **NOTE** 6> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. 7> This module is deprecated since API version 9. You are advised to use [@ohos.app.ability.Configuration](js-apis-app-ability-configuration.md) instead. 8 9**System capability**: SystemCapability.Ability.AbilityBase 10 11 | Name| Type| Readable| Writable| Description| 12| -------- | -------- | -------- | -------- | -------- | 13| language<sup>8+</sup> | string | Yes| Yes| Language of the application.| 14| colorMode<sup>8+</sup> | [ColorMode](js-apis-application-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.| 15 16For details about the fields, see the **ohos.application.Configuration.d.ts** file. 17 18**Example** 19 20 ```ts 21import Ability from '@ohos.app.ability.UIAbility'; 22import Window from '@ohos.window' 23 24export default class MainAbility extends Ability { 25 onCreate(want, launchParam) { 26 } 27 28 onDestroy() { 29 } 30 31 onWindowStageCreate(windowStage: Window.WindowStage) { 32 let envCallback = { 33 onConfigurationUpdated(config) { 34 console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`); 35 let language = config.language; 36 let colorMode = config.colorMode; 37 }, 38 onMemoryLevel(level){ 39 console.log('onMemoryLevel level: ${JSON.stringify(level)}'); 40 } 41 }; 42 43 let applicationContext = this.context.getApplicationContext(); 44 applicationContext.on('environment',envCallback); 45 46 windowStage.loadContent('pages/index', (err, data) => { 47 if (err.code) { 48 console.error('failed to load the content, error: + ${JSON.stringify(err)}'); 49 return; 50 } 51 console.info('Succeeded in loading the content, data: + ${JSON.stringify(data)}'); 52 }); 53 } 54} 55 ``` 56