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

add user

Signed-off-by: Nunknown <sijunjie@huawei.com>
上级 4dcf69c2
...@@ -21,6 +21,18 @@ ...@@ -21,6 +21,18 @@
**示例:** **示例:**
```ts ```ts
import hilog from '@ohos.hilog';
import Ability from '@ohos.application.Ability'
import Window from '@ohos.window'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
}
onDestroy() {
}
onWindowStageCreate(windowStage: Window.WindowStage) {
let envCallback = { let envCallback = {
onConfigurationUpdated(config) { onConfigurationUpdated(config) {
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`) console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`)
...@@ -32,6 +44,20 @@ ...@@ -32,6 +44,20 @@
let hasPointerDevice = config.hasPointerDevice; let hasPointerDevice = config.hasPointerDevice;
} }
}; };
var callbackId = applicationContext.registerEnvironmentCallback(envCallback);
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) ?? '');
});
}
}
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册