1# @ohos.app.ability.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> 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**System capability**: SystemCapability.Ability.AbilityBase 10 11| Name| Type| Readable| Writable| Description| 12| -------- | -------- | -------- | -------- | -------- | 13| language | string | Yes| Yes| Language of the application, for example, **zh**.| 14| colorMode | [ColorMode](js-apis-app-ability-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode. The default value is **COLOR_MODE_LIGHT**. The options are as follows:<br>- **COLOR_MODE_NOT_SET**: The color mode is not set.<br>- **COLOR_MODE_LIGHT**: light mode.<br>- **COLOR_MODE_DARK**: dark mode.| 15| direction | [Direction](js-apis-app-ability-configurationConstant.md#configurationconstantdirection) | Yes| No| Screen orientation. The options are as follows:<br>- **DIRECTION_NOT_SET**: The screen orientation is not set.<br>- **DIRECTION_HORIZONTAL**: horizontal direction.<br>- **DIRECTION_VERTICAL**: vertical direction.| 16| screenDensity | [ScreenDensity](js-apis-app-ability-configurationConstant.md#configurationconstantscreendensity) | Yes| No| Pixel density of the screen. The options are as follows:<br>- **SCREEN_DENSITY_NOT_SET**: The pixel density is not set.<br>- **SCREEN_DENSITY_SDPI**: 120.<br>- **SCREEN_DENSITY_MDPI**: 160.<br>- **SCREEN_DENSITY_LDPI**: 240.<br>- **SCREEN_DENSITY_XLDPI**: 320.<br>- **SCREEN_DENSITY_XXLDPI**: 480.<br>- **SCREEN_DENSITY_XXXLDPI**: 640.| 17| displayId | number | Yes| No| ID of the display where the application is located.| 18| hasPointerDevice | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.| 19 20For details about the fields, see the **ohos.app.ability.Configuration.d.ts** file. 21 22**Example** 23 24 ```ts 25 import UIAbility from '@ohos.app.ability.UIAbility'; 26 27 export default class EntryAbility extends UIAbility { 28 onCreate(want, launchParam) { 29 let envCallback = { 30 onConfigurationUpdated(config) { 31 console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`); 32 let language = config.language; 33 let colorMode = config.colorMode; 34 let direction = config.direction; 35 let screenDensity = config.screenDensity; 36 let displayId = config.displayId; 37 let hasPointerDevice = config.hasPointerDevice; 38 } 39 }; 40 try { 41 let applicationContext = this.context.getApplicationContext(); 42 let callbackId = applicationContext.on('environment', envCallback); 43 console.log('callbackId: ' + callbackId); 44 } catch (paramError) { 45 console.log('error: ' + paramError.code + ', ' + paramError.message); 46 } 47 } 48 } 49 ``` 50