From eddb19e39aa56caa7b23a07ba2cec628debc5cc8 Mon Sep 17 00:00:00 2001 From: qianlf Date: Thu, 29 Dec 2022 14:24:18 +0800 Subject: [PATCH] add changelogs for window Signed-off-by: qianlf Change-Id: I3a1dd694624e94eafb6e85a686be0631c1532551 Signed-off-by: qianlf --- .../OpenHarmony_4.0.1.1/changelogs-window.md | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 zh-cn/release-notes/changelogs/OpenHarmony_4.0.1.1/changelogs-window.md diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.1.1/changelogs-window.md b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.1.1/changelogs-window.md new file mode 100644 index 0000000000..864bbb251e --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.1.1/changelogs-window.md @@ -0,0 +1,63 @@ +# 窗口子系统ChangeLog + +## cl.window.1 WindowStage生命周期监听类型名称变更 + +WindowStage生命周期的监听类型枚举定义自4.0.1.1版本起进行了变更。 + +**变更影响** + +4.0.1.1版本之前使用FOREGROUND/BACKGROUND类型开发的应用生命周期监听,在4.0.1.1版本之后失效。 + +**关键接口/组件变更** + +## WindowStageEventType9+ + +变更前: + +| 名称 | 值 | 说明 | +| ---------- | ---- | ---------- | +| FOREGROUND | 1 | 切到前台。 | +| BACKGROUND | 4 | 切到后台。 | + +变更后: +| 名称 | 值 | 说明 | +| ------ | ---- | ---------- | +| SHOWN | 1 | 切到前台。 | +| HIDDEN | 4 | 切到后台。 | + +**适配指导** + +在注册生命周期监听回调时,将前后台事件类型改为SHOWN/HIDDEN: + +``` +import Ability from '@ohos.application.Ability'; + +class myAbility extends Ability { + onWindowStageCreate(windowStage) { + console.log('onWindowStageCreate'); + try { + windowStage.on('windowStageEvent', (stageEventType) => { + switch (stageEventType) { + case window.WindowStageEventType.SHOWN: + console.log("windowStage shown"); + break; + case window.WindowStageEventType.ACTIVE: + console.log("windowStage active"); + break; + case window.WindowStageEventType.INACTIVE: + console.log("windowStage inActive"); + break; + case window.WindowStageEventType.HIDDEN: + console.log("windowStage hidden"); + break; + default: + break; + } + } ) + } catch (exception) { + console.error('Failed to enable the listener for window stage event changes. Cause:' + + JSON.stringify(exception)); + }; + } +}; +``` -- GitLab