提交 4a401332 编写于 作者: U unknown

add user

Signed-off-by: Nunknown <sijunjie@huawei.com>
上级 4dcf69c2
...@@ -21,17 +21,43 @@ ...@@ -21,17 +21,43 @@
**示例:** **示例:**
```ts ```ts
let envCallback = { import hilog from '@ohos.hilog';
onConfigurationUpdated(config) { import Ability from '@ohos.application.Ability'
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`) import Window from '@ohos.window'
let language = config.language;
let colorMode = config.colorMode; export default class MainAbility extends Ability {
let direction = config.direction; onCreate(want, launchParam) {
let screenDensity = config.screenDensity; }
let displayId = config.displayId;
let hasPointerDevice = config.hasPointerDevice; onDestroy() {
}
onWindowStageCreate(windowStage: Window.WindowStage) {
let envCallback = {
onConfigurationUpdated(config) {
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`)
let language = config.language;
let colorMode = config.colorMode;
let direction = config.direction;
let screenDensity = config.screenDensity;
let displayId = config.displayId;
let hasPointerDevice = config.hasPointerDevice;
}
};
let applicationContext = this.context.getApplicationContext();
applicationContext.registerEnvironmentCallback(envCallback);
windowStage.loadContent('pages/index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
} }
}; }
var callbackId = applicationContext.registerEnvironmentCallback(envCallback);
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册