harmony 鸿蒙Window Subsystem ChangeLog

  • 2023-02-03
  • 浏览 (290)

Window Subsystem ChangeLog

cl.window.1 Change of Window Stage Lifecycle Listener Types

Changed the enumerated listener types of the window stage lifecycle in version 3.2.10.5 and later.

Change Impacts

Application 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.

Key API/Component Changes

WindowStageEventType9+

Before change

Name Value Description
FOREGROUND 1 The window stage is running in the foreground.
BACKGROUND 4 The window stage is running in the background.

After change |Name|Value|Description | |——|—-|———-| |SHOWN|1 |The window stage is running in the foreground.| |HIDDEN|4 |The window stage is running in the background.|

Adaptation Guide

When registering lifecycle listeners, change the foreground and background event types to SHOWN and HIDDEN, respectively.

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));
        };
    }
};

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Resource Scheduler Subsystem ChangeLog

harmony 鸿蒙ArkUI Subsystem ChangeLog

harmony 鸿蒙Bundle Manager Subsystem ChangeLog

harmony 鸿蒙File Management Subsystem Changelog

harmony 鸿蒙Input Method Framework ChangeLog

harmony 鸿蒙Location Subsystem ChangeLog

harmony 鸿蒙Location Subsystem ChangeLog

harmony 鸿蒙Location Subsystem ChangeLog

harmony 鸿蒙User IAM Subsystem ChangeLog

0  赞