提交 9683fe88 编写于 作者: G gongyuechen

Description:js-apis-app-ability-configuration example fix

Sig:SIG_ApplicationFramework
Feature or Bugfix:Bugfix
Binary Source:No
Signed-off-by: Ngongyuechen <gongyuechen@huawei.com>
上级 73af0a7a
...@@ -28,21 +28,23 @@ import Configuration from '@ohos.app.ability.Configuration' ...@@ -28,21 +28,23 @@ import Configuration from '@ohos.app.ability.Configuration'
**示例:** **示例:**
```ts ```ts
let envCallback = { import UIAbility from '@ohos.app.ability.UIAbility';
onConfigurationUpdated(config) {
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`) export default class EntryAbility extends UIAbility {
let language = config.language; onCreate(want, launchParam) {
let colorMode = config.colorMode; let envCallback = {
let direction = config.direction; onConfigurationUpdated(config) {
let screenDensity = config.screenDensity; console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`)
let displayId = config.displayId; }
let hasPointerDevice = config.hasPointerDevice; };
try {
let applicationContext = this.context.getApplicationContext();
let callbackId = applicationContext.on("environment", envCallback);
console.log("callbackId: " + callbackId);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
} }
};
try {
let callbackId = applicationContext.on("environment", envCallback);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册