• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Window Manager Subsystem Changelog
2
3## cl.window.1 Change of Window Stage Lifecycle Listener Types
4
5Changed the enumerated listener types of the window stage lifecycle in version 3.2.10.5 and later.
6
7**Change Impacts**
8
9Application lifecycle listeners developed using **FOREGROUND** and **BACKGROUND** in versions earlier than 3.2.10.5 will be invalidated in version 3.2.10.5 and later.
10
11**Key API/Component Changes**
12
13##  WindowStageEventType<sup>9+</sup>
14
15Before change
16
17| Name      | Value  | Description      |
18| ---------- | ---- | ---------- |
19| FOREGROUND | 1    | The window stage is running in the foreground.|
20| BACKGROUND | 4    | The window stage is running in the background.|
21
22After change
23| Name  | Value  | Description      |
24| ------ | ---- | ---------- |
25| SHOWN  | 1    | The window stage is running in the foreground.|
26| HIDDEN | 4    | The window stage is running in the background.|
27
28**Adaptation Guide**
29
30When registering lifecycle listeners, change the foreground and background event types to **SHOWN** and **HIDDEN**, respectively.
31
32```
33import Ability from '@ohos.application.Ability';
34
35class myAbility extends Ability {
36    onWindowStageCreate(windowStage) {
37        console.log('onWindowStageCreate');
38        try {
39            windowStage.on('windowStageEvent', (stageEventType) => {
40                switch (stageEventType) {
41                    case window.WindowStageEventType.SHOWN:
42                        console.log("windowStage shown");
43                        break;
44                    case window.WindowStageEventType.ACTIVE:
45                        console.log("windowStage active");
46                        break;
47                    case window.WindowStageEventType.INACTIVE:
48                        console.log("windowStage inActive");
49                        break;
50                    case window.WindowStageEventType.HIDDEN:
51                        console.log("windowStage hidden");
52                        break;
53                    default:
54                        break;
55                }
56        	} )
57        } catch (exception) {
58            console.error('Failed to enable the listener for window stage event changes. Cause:' +
59                JSON.stringify(exception));
60        };
61    }
62};
63```
64