1e41f4b71Sopenharmony_ci# @ohos.application.Configuration (Configuration)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **Configuration** module defines environment change information. **Configuration** is an interface definition and is used only for field declaration.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> 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.
8e41f4b71Sopenharmony_ci> This module is deprecated since API version 9. You are advised to use [@ohos.app.ability.Configuration](js-apis-app-ability-configuration.md) instead.
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Modules to Import
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci```ts
13e41f4b71Sopenharmony_ciimport Configuration from '@ohos.application.Configuration';
14e41f4b71Sopenharmony_ci```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci## Properties
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityBase
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci  | Name| Type| Readable| Writable| Description|
21e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
22e41f4b71Sopenharmony_ci| language<sup>8+</sup> | string | Yes| Yes| Language of the application, for example, **zh**.|
23e41f4b71Sopenharmony_ci| colorMode<sup>8+</sup> | [ConfigurationConstant.ColorMode](js-apis-application-configurationConstant.md#colormode) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ciFor details about the fields, see the **ohos.application.Configuration.d.ts** file.
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**Example**
28e41f4b71Sopenharmony_ci  ```ts
29e41f4b71Sopenharmony_ciimport UIAbility from '@ohos.app.ability.UIAbility';
30e41f4b71Sopenharmony_ciimport AbilityConstant from '@ohos.app.ability.AbilityConstant';
31e41f4b71Sopenharmony_ciimport EnvironmentCallback from '@ohos.app.ability.EnvironmentCallback';
32e41f4b71Sopenharmony_ciimport Want from '@ohos.app.ability.Want';
33e41f4b71Sopenharmony_ciimport Window from '@ohos.window';
34e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base';
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
37e41f4b71Sopenharmony_ci    onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
38e41f4b71Sopenharmony_ci    }
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci    onDestroy() {
41e41f4b71Sopenharmony_ci    }
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci    onWindowStageCreate(windowStage: Window.WindowStage) {
44e41f4b71Sopenharmony_ci        let envCallback: EnvironmentCallback = {
45e41f4b71Sopenharmony_ci            onConfigurationUpdated(config) {
46e41f4b71Sopenharmony_ci                console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`);
47e41f4b71Sopenharmony_ci                let language = config.language;
48e41f4b71Sopenharmony_ci                let colorMode = config.colorMode;
49e41f4b71Sopenharmony_ci            },
50e41f4b71Sopenharmony_ci            onMemoryLevel(level){
51e41f4b71Sopenharmony_ci                console.log(`onMemoryLevel level: ${JSON.stringify(level)}`);
52e41f4b71Sopenharmony_ci            }
53e41f4b71Sopenharmony_ci        };
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci        let applicationContext = this.context.getApplicationContext();
56e41f4b71Sopenharmony_ci        try {
57e41f4b71Sopenharmony_ci            applicationContext.on('environment',envCallback);
58e41f4b71Sopenharmony_ci        } catch (paramError) {
59e41f4b71Sopenharmony_ci            console.error(`error: ${(paramError as BusinessError).code}, ${(paramError as BusinessError).message}`);
60e41f4b71Sopenharmony_ci        }
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci        windowStage.loadContent('pages/index', (err, data) => {
63e41f4b71Sopenharmony_ci            if (err.code) {
64e41f4b71Sopenharmony_ci                console.error(`failed to load the content, error: ${JSON.stringify(err)}`);
65e41f4b71Sopenharmony_ci                return;
66e41f4b71Sopenharmony_ci            }
67e41f4b71Sopenharmony_ci            console.info(`Succeeded in loading the content, data: ${JSON.stringify(data)}`);
68e41f4b71Sopenharmony_ci        });
69e41f4b71Sopenharmony_ci    }
70e41f4b71Sopenharmony_ci}
71e41f4b71Sopenharmony_ci  ```
72