• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.window (窗口)
2
3窗口提供管理窗口的一些基础能力,包括对当前窗口的创建、销毁、各属性设置,以及对各窗口间的管理调度。
4
5该模块提供以下窗口相关的常用功能:
6
7- [Window](#window):当前窗口实例,窗口管理器管理的基本单元。
8- [WindowStage](#windowstage9):窗口管理器。管理各个基本窗口单元。
9
10> **说明:**
11>
12> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
13
14## 导入模块
15
16```ts
17import window from '@ohos.window';
18```
19
20## WindowType<sup>7+</sup>
21
22窗口类型枚举。
23
24**系统能力:** SystemCapability.WindowManager.WindowManager.Core
25
26| 名称              | 值 | 说明               |
27| ----------------- | ------ | ------------------ |
28| TYPE_APP          | 0      | 表示应用子窗口。<br>**模型约束:** 此接口仅可在FA模型下使用。 |
29| TYPE_SYSTEM_ALERT | 1      | 表示系统告警窗口。 |
30| TYPE_INPUT_METHOD<sup>9+</sup> | 2      | 表示输入法窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
31| TYPE_STATUS_BAR<sup>9+</sup>   | 3      | 表示状态栏窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
32| TYPE_PANEL<sup>9+</sup>        | 4      | 表示通知栏。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
33| TYPE_KEYGUARD<sup>9+</sup>     | 5      | 表示锁屏。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
34| TYPE_VOLUME_OVERLAY<sup>9+</sup> | 6      | 表示音量条。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
35| TYPE_NAVIGATION_BAR<sup>9+</sup> | 7      | 表示导航栏窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
36| TYPE_FLOAT<sup>9+</sup> | 8      | 表示悬浮窗。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**需要权限:** ohos.permission.SYSTEM_FLOAT_WINDOW |
37| TYPE_WALLPAPER<sup>9+</sup> | 9      | 表示壁纸。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
38| TYPE_DESKTOP<sup>9+</sup> | 10      | 表示桌面。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
39| TYPE_LAUNCHER_RECENT<sup>9+</sup> | 11      | 表示多任务中心。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
40| TYPE_LAUNCHER_DOCK<sup>9+</sup> | 12      | 表示桌面Dock栏。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
41| TYPE_VOICE_INTERACTION<sup>9+</sup> | 13      | 表示智慧语音。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
42| TYPE_POINTER<sup>9+</sup> | 14      | 表示鼠标。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
43| TYPE_FLOAT_CAMERA<sup>9+</sup> | 15      | 表示相机类型悬浮窗。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
44| TYPE_DIALOG<sup>10+</sup>  | 16      | 表示模态窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。 |
45| TYPE_SCREENSHOT<sup>9+</sup>  | 17      | 表示截屏窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
46
47## Configuration<sup>9+</sup>
48
49创建子窗口或系统窗口时的参数。
50
51**系统能力:** SystemCapability.WindowManager.WindowManager.Core
52
53| 名称 | 类型 | 必填 | 说明                                                                          |
54| ---------- | -------------------------- | -- |-----------------------------------------------------------------------------|
55| name       | string                     | 是 | 窗口名字。                                                                       |
56| windowType | [WindowType](#windowtype7) | 是 | 窗口类型。                                                                       |
57| ctx        | [BaseContext](js-apis-inner-application-baseContext.md) | 否 | 当前应用上下文信息。不设置,则默认为空。<br>FA模型下不需要使用该参数,即可创建子窗口。<br>Stage模型下需要使用该参数,用于创建系统窗口。 |
58| displayId  | number                     | 否 | 当前物理屏幕id。不设置,则默认为-1,该参数应为整数。                                             |
59| parentId   | number                     | 否 | 父窗口id。不设置,则默认为-1,该参数应为整数。                                                           |
60
61## AvoidAreaType<sup>7+</sup>
62
63窗口内容需要规避区域的类型枚举。
64
65**系统能力:** SystemCapability.WindowManager.WindowManager.Core
66
67| 名称                             | 值   | 说明                                                         |
68| -------------------------------- | ---- | ------------------------------------------------------------ |
69| TYPE_SYSTEM                      | 0    | 表示系统默认区域。一般包括状态栏、导航栏,各设备系统定义可能不同。 |
70| TYPE_CUTOUT                      | 1    | 表示刘海屏区域。                                             |
71| TYPE_SYSTEM_GESTURE<sup>9+</sup> | 2    | 表示手势区域。                                               |
72| TYPE_KEYBOARD<sup>9+</sup>       | 3    | 表示软键盘区域。                                             |
73
74## WindowMode<sup>7+</sup>
75
76窗口模式枚举。
77
78**系统接口:** 此接口为系统接口。
79
80**系统能力:** SystemCapability.WindowManager.WindowManager.Core
81
82| 名称       | 值   | 说明                          |
83| ---------- | ---- | ----------------------------- |
84| UNDEFINED  | 1    | 表示APP未定义窗口模式。       |
85| FULLSCREEN | 2    | 表示APP全屏模式。             |
86| PRIMARY    | 3    | 表示APP分屏多窗口主要模式。   |
87| SECONDARY  | 4    | 表示APP分屏多窗口次要模式。   |
88| FLOATING   | 5    | 表示APP自由悬浮形式窗口模式。 |
89
90## WindowLayoutMode<sup>9+</sup>
91
92窗口布局模式枚举。
93
94**系统接口:** 此接口为系统接口。
95
96**系统能力:** SystemCapability.WindowManager.WindowManager.Core
97
98| 名称       | 值   | 说明                          |
99| ---------- | ---- | ----------------------------- |
100| WINDOW_LAYOUT_MODE_CASCADE  | 0    | 表示使用层叠布局模式。       |
101| WINDOW_LAYOUT_MODE_TILE | 1    | 表示使用平铺布局模式。             |
102
103## SystemBarProperties
104
105状态栏、导航栏的属性。
106
107**系统能力:** SystemCapability.WindowManager.WindowManager.Core
108
109| 名称                                   | 类型 |  必填 | 说明                                                         |
110| -------------------------------------- | -------- | ---- | ------------------------------------------------------------ |
111| statusBarColor                         | string   |  否   | 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。默认值:`#0x66000000`。 |
112| isStatusBarLightIcon<sup>7+</sup>      | boolean  |  否   | 状态栏图标是否为高亮状态。true表示高亮;false表示不高亮。默认值:false。 |
113| statusBarContentColor<sup>8+</sup>     | string   |  否   | 状态栏文字颜色。当设置此属性后, `isStatusBarLightIcon`属性设置无效。默认值:`0xE5FFFFFF。` |
114| navigationBarColor                     | string   |  否   | 导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。默认值:`#0x66000000。` |
115| isNavigationBarLightIcon<sup>7+</sup>  | boolean  |  否   | 导航栏图标是否为高亮状态。true表示高亮;false表示不高亮。默认值:false。 |
116| navigationBarContentColor<sup>8+</sup> | string   |  否   | 导航栏文字颜色。当设置此属性后, `isNavigationBarLightIcon`属性设置无效。默认值:`#0xE5FFFFFF。` |
117
118## Orientation<sup>9+</sup>
119
120窗口显示方向类型枚举。
121
122**系统能力:** SystemCapability.WindowManager.WindowManager.Core
123
124| 名称                                  | 值   | 说明                          |
125| ------------------------------------- | ---- | ----------------------------- |
126| UNSPECIFIED                           | 0    | 表示未定义方向模式,由系统判定。 |
127| PORTRAIT                              | 1    | 表示竖屏显示模式。             |
128| LANDSCAPE                             | 2    | 表示横屏显示模式。   |
129| PORTRAIT_INVERTED                     | 3    | 表示反向竖屏显示模式。   |
130| LANDSCAPE_INVERTED                    | 4    | 表示反向横屏显示模式。 |
131| AUTO_ROTATION                         | 5    | 表示传感器自动旋转模式。 |
132| AUTO_ROTATION_PORTRAIT                | 6    | 表示传感器自动竖向旋转模式。 |
133| AUTO_ROTATION_LANDSCAPE               | 7    | 表示传感器自动横向旋转模式。 |
134| AUTO_ROTATION_RESTRICTED              | 8    | 表示受开关控制的自动旋转模式。 |
135| AUTO_ROTATION_PORTRAIT_RESTRICTED     | 9    | 表示受开关控制的自动竖向旋转模式。 |
136| AUTO_ROTATION_LANDSCAPE_RESTRICTED    | 10   | 表述受开关控制的自动横向旋转模式。 |
137| LOCKED                                | 11   | 表示锁定模式。 |
138
139## BlurStyle<sup>9+</sup>
140
141窗口模糊类型枚举。
142
143**系统接口:** 此接口为系统接口。
144
145**系统能力:** SystemCapability.WindowManager.WindowManager.Core
146
147| 名称    | 值   | 说明                 |
148| ------- | ---- | -------------------- |
149| OFF     | 0    | 表示关闭模糊。       |
150| THIN    | 1    | 表示较薄的模糊类型。 |
151| REGULAR | 2    | 表示适中的模糊类型。 |
152| THICK   | 3    | 表示较厚的模糊类型。 |
153
154## SystemBarRegionTint<sup>8+</sup>
155
156单个导航栏或状态栏回调信息。
157
158**系统接口:** 此接口为系统接口。
159
160**系统能力:** SystemCapability.WindowManager.WindowManager.Core
161
162| 名称            | 类型                  | 可读 | 可写 | 说明                                                         |
163| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
164| type            | [WindowType](#windowtype7) | 是   | 否   | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 |
165| isEnable        | boolean                   | 是   | 否   | 当前系统栏是否显示。true表示显示;false表示不显示。 |
166| region          | [Rect](#rect7)             | 是   | 否   | 当前系统栏的位置及大小。                                     |
167| backgroundColor | string                    | 是   | 否   | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 |
168| contentColor    | string                    | 是   | 否   | 系统栏文字颜色。                                             |
169
170## SystemBarTintState<sup>8+</sup>
171
172当前系统栏回调信息集合。
173
174**系统接口:** 此接口为系统接口。
175
176**系统能力:** SystemCapability.WindowManager.WindowManager.Core
177
178| 名称       | 类型                                            | 可读 | 可写 | 说明                         |
179| ---------- | --------------------------------------------------- | ---- | ---- | ---------------------------- |
180| displayId  | number                                              | 是   | 否   | 当前物理屏幕id,该参数应为整数。             |
181| regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | 是   | 否   | 当前已改变的所有系统栏信息。 |
182
183## Rect<sup>7+</sup>
184
185窗口矩形区域。
186
187**系统能力:** SystemCapability.WindowManager.WindowManager.Core
188
189| 名称   | 类型 | 可读 | 可写 | 说明               |
190| ------ | -------- | ---- | ---- | ------------------ |
191| left   | number   | 是   | 是   | 矩形区域的左边界,单位为px,该参数为整数。 |
192| top    | number   | 是   | 是   | 矩形区域的上边界,单位为px,该参数应为整数。 |
193| width  | number   | 是   | 是   | 矩形区域的宽度,单位为px,该参数应为整数。 |
194| height | number   | 是   | 是   | 矩形区域的高度,单位为px,该参数应为整数。 |
195
196## AvoidArea<sup>7+</sup>
197
198窗口内容规避区域。
199
200**系统能力:** SystemCapability.WindowManager.WindowManager.Core
201
202| 名称       | 类型      | 可读 | 可写 | 说明               |
203| ---------- | ------------- | ---- | ---- | ------------------ |
204| visible<sup>9+</sup>    | boolean       | 是   | 是   | 规避区域是否可见。true表示可见;false表示不可见。 |
205| leftRect   | [Rect](#rect7) | 是   | 是   | 屏幕左侧的矩形区。 |
206| topRect    | [Rect](#rect7) | 是   | 是   | 屏幕顶部的矩形区。 |
207| rightRect  | [Rect](#rect7) | 是   | 是   | 屏幕右侧的矩形区。 |
208| bottomRect | [Rect](#rect7) | 是   | 是   | 屏幕底部的矩形区。 |
209
210## Size<sup>7+</sup>
211
212窗口大小。
213
214**系统能力:** SystemCapability.WindowManager.WindowManager.Core
215
216| 名称   | 类型 | 可读 | 可写 | 说明       |
217| ------ | -------- | ---- | ---- | ---------- |
218| width  | number   | 是   | 是   | 窗口宽度,单位为px,该参数应为整数。 |
219| height | number   | 是   | 是   | 窗口高度,单位为px,该参数应为整数。 |
220
221## WindowProperties
222
223窗口属性。
224
225**系统能力:** SystemCapability.WindowManager.WindowManager.Core
226
227| 名称                                  | 类型                  | 可读 | 可写 | 说明                                                                                                     |
228| ------------------------------------- | ------------------------- | ---- | ---- |--------------------------------------------------------------------------------------------------------|
229| windowRect<sup>7+</sup>               | [Rect](#rect7)             | 是   | 是   | 窗口尺寸。                                                                                                  |
230| type<sup>7+</sup>                     | [WindowType](#windowtype7) | 是   | 是   | 窗口类型。                                                                                                  |
231| isFullScreen                          | boolean                   | 是   | 是   | 是否全屏,默认为false。true表示全屏;false表示非全屏。                                                                     |
232| isLayoutFullScreen<sup>7+</sup>       | boolean                   | 是   | 是   | 窗口是否为沉浸式,默认为false。true表示沉浸式;false表示非沉浸式。                                                               |
233| focusable<sup>7+</sup>                | boolean                   | 是   | 否   | 窗口是否可聚焦,默认为true。true表示可聚焦;false表示不可聚焦。                                                                 |
234| touchable<sup>7+</sup>                | boolean                   | 是   | 否   | 窗口是否可触摸,默认为true。true表示可触摸;false表示不可触摸。                                                                 |
235| brightness                            | number                    | 是   | 是   | 屏幕亮度。该参数为浮点数,可设置的亮度范围为[0.0, 1.0],其取1.0时表示最大亮度值。如果窗口没有设置亮度值,表示亮度跟随系统,此时获取到的亮度值为-1。                      |
236| dimBehindValue<sup>(deprecated)</sup> | number                    | 是   | 是   | 靠后窗口的暗度值。该参数为浮点数,取值范围为[0.0, 1.0],其取1.0表示最暗。<br>- **说明:** 从API version 9开始废弃。<br>- 从 API version 7开始支持。 |
237| isKeepScreenOn                        | boolean                   | 是   | 是   | 屏幕是否常亮,默认为false。true表示常亮;false表示不常亮。                                                                   |
238| isPrivacyMode<sup>7+</sup>            | boolean                   | 是   | 是   | 隐私模式,默认为false。true表示模式开启;false表示模式关闭。                                                                  |
239| isRoundCorner<sup>(deprecated)</sup>  | boolean                   | 是   | 是   | 窗口是否为圆角。默认为false。true表示圆角;false表示非圆角。<br>- **说明:** 从API version 9开始废弃。<br/>- 从 API version 7开始支持。      |
240| isTransparent<sup>7+</sup>            | boolean                   | 是   | 是   | 窗口是否透明。默认为false。true表示透明;false表示不透明。                                                                   |
241| id<sup>9+</sup>                       | number                    | 是   | 否   | 窗口ID,默认值为0,该参数应为整数。                                                                                    |
242
243## ColorSpace<sup>8+</sup>
244
245色域模式。
246
247**系统能力:** SystemCapability.WindowManager.WindowManager.Core
248
249| 名称       | 值 | 说明           |
250| ---------- | ------ | -------------- |
251| DEFAULT    | 0      | 默认SRGB色域模式。 |
252| WIDE_GAMUT | 1      | 广色域模式。   |
253
254## ScaleOptions<sup>9+</sup>
255
256缩放参数。
257
258**系统接口:** 此接口为系统接口。
259
260**系统能力**:SystemCapability.WindowManager.WindowManager.Core
261
262| 名称   | 类型 | 可读 | 可写 | 说明                                         |
263| ------ | -------- | ---- | ---- |--------------------------------------------|
264| x      | number   | 否   | 是   | X轴的缩放参数。该参数为浮点数,默认值为1.0。                   |
265| y      | number   | 否   | 是   | Y轴的缩放参数。该参数为浮点数,默认值为1.0。                   |
266| pivotX | number   | 否   | 是   | 缩放中心点X轴坐标。该参数为浮点数,默认值为0.5, 取值范围[0.0, 1.0]。 |
267| pivotY | number   | 否   | 是   | 缩放中心点Y轴坐标。该参数为浮点数,默认值为0.5, 取值范围[0.0, 1.0]。 |
268
269## RotateOptions<sup>9+</sup>
270
271旋转参数。
272
273**系统接口:** 此接口为系统接口。
274
275**系统能力**:SystemCapability.WindowManager.WindowManager.Core
276
277| 名称   | 类型 | 可读 | 可写 | 说明                                          |
278| ------ | -------- | ---- | ---- |---------------------------------------------|
279| x      | number   | 否   | 是   | 绕X轴的旋转角度。该参数为浮点数,默认值为0.0。                   |
280| y      | number   | 否   | 是   | 绕Y轴的旋转角度。该参数为浮点数,默认值为0.0。                   |
281| z      | number   | 否   | 是   | 绕Z轴的旋转角度。该参数为浮点数,默认值为0.0。                   |
282| pivotX | number   | 否   | 是   | 旋转中心点X轴坐标。该参数为浮点数,默认值为0.5, 取值范围为[0.0, 1.0]。 |
283| pivotY | number   | 否   | 是   | 旋转中心点Y轴坐标。该参数为浮点数,默认值为0.5, 取值范围为[0.0, 1.0]。  |
284
285## TranslateOptions<sup>9+</sup>
286
287平移参数。
288
289**系统接口:** 此接口为系统接口。
290
291**系统能力**:SystemCapability.WindowManager.WindowManager.Core
292
293| 名称 | 类型 | 可读 | 可写 | 说明                         |
294| ---- | -------- | ---- | ---- | ---------------------------- |
295| x    | number   | 否   | 是   | X轴的平移参数。该参数为浮点数,默认值为0.0。 |
296| y    | number   | 否   | 是   | Y轴的平移参数。该参数为浮点数,默认值为0.0。 |
297| z    | number   | 否   | 是   | Z轴的平移参数。该参数为浮点数,默认值为0.0。 |
298
299## WindowEventType<sup>10+</sup>
300
301窗口生命周期。
302
303**系统能力**:SystemCapability.WindowManager.WindowManager.Core
304
305| 名称       | 值 | 说明       |
306| ---------- | ------ | ---------- |
307| WINDOW_SHOWN      | 1      | 切到前台。 |
308| WINDOW_ACTIVE     | 2      | 获焦状态。 |
309| WINDOW_INACTIVE   | 3      | 失焦状态。 |
310| WINDOW_HIDDEN     | 4      | 切到后台。 |
311
312## window.createWindow<sup>9+</sup>
313
314createWindow(config: Configuration, callback: AsyncCallback&lt;Window&gt;): void
315
316创建子窗口或者系统窗口,使用callback异步回调。
317
318**系统能力:** SystemCapability.WindowManager.WindowManager.Core
319
320**参数:**
321
322| 参数名 | 类型 | 必填 | 说明 |
323| -------- | -------------------------------------- | -- | --------------------------------- |
324| config   | [Configuration](#configuration9)       | 是 | 创建窗口时的参数。   |
325| callback | AsyncCallback&lt;[Window](#window)&gt; | 是 | 回调函数。返回当前创建的窗口对象。 |
326
327**错误码:**
328
329以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
330
331| 错误码ID | 错误信息 |
332| ------- | -------------------------------- |
333| 1300001 | Repeated operation. |
334| 1300006 | This window context is abnormal. |
335| 1300008 | The operation is on invalid display. |
336| 1300009 | The parent window is invalid. |
337
338**示例:**
339
340```ts
341import { BusinessError } from '@ohos.base';
342
343let windowClass: window.Window = window.findWindow("test");
344let config: window.Configuration = {
345  name: "alertWindow",
346  windowType: window.WindowType.TYPE_SYSTEM_ALERT
347};
348try {
349  window.createWindow(config, (err: BusinessError, data) => {
350    const errCode: number = err.code;
351    if (errCode) {
352      console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
353      return;
354    }
355    windowClass = data;
356    console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data));
357    windowClass.resetSize(500, 1000);
358  });
359} catch (exception) {
360  console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
361}
362```
363
364## window.createWindow<sup>9+</sup>
365
366createWindow(config: Configuration): Promise&lt;Window&gt;
367
368创建子窗口或者系统窗口,使用Promise异步回调。
369
370**系统能力:** SystemCapability.WindowManager.WindowManager.Core
371
372**参数:**
373
374| 参数名 | 类型 | 必填 | 说明 |
375| ------ | -------------------------------- | -- | ------------------ |
376| config | [Configuration](#configuration9) | 是 | 创建窗口时的参数。 |
377
378**返回值:**
379
380| 类型 | 说明 |
381| -------------------------------- | ------------------------------------ |
382| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前创建的窗口对象。 |
383
384**错误码:**
385
386以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
387
388| 错误码ID | 错误信息 |
389| ------- | -------------------------------- |
390| 1300001 | Repeated operation. |
391| 1300006 | This window context is abnormal. |
392| 1300008 | The operation is on invalid display. |
393| 1300009 | The parent window is invalid. |
394
395**示例:**
396
397```ts
398import { BusinessError } from '@ohos.base';
399
400let windowClass: window.Window = window.findWindow("test");
401let config: window.Configuration = {
402  name: "alertWindow",
403  windowType: window.WindowType.TYPE_SYSTEM_ALERT
404};
405try {
406  let promise = window.createWindow(config);
407  promise.then((data) => {
408    windowClass = data;
409    console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
410  }).catch((err: BusinessError) => {
411    console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
412  });
413} catch (exception) {
414  console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
415}
416```
417
418## window.findWindow<sup>9+</sup>
419
420findWindow(name: string): Window
421
422查找name所对应的窗口。
423
424**系统能力:** SystemCapability.WindowManager.WindowManager.Core
425
426**参数:**
427
428| 参数名 | 类型   | 必填 | 说明     |
429| ------ | ------ | ---- | -------- |
430| name   | string | 是   | 窗口id。 |
431
432**返回值:**
433
434| 类型 | 说明 |
435| ----------------- | ------------------- |
436| [Window](#window) | 当前查找的窗口对象。 |
437
438**错误码:**
439
440以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
441
442| 错误码ID | 错误信息 |
443| ------- | -------------------------------- |
444| 1300002 | This window state is abnormal. |
445
446**示例:**
447
448```ts
449let windowClass: window.Window = window.findWindow("test");
450try {
451  windowClass = window.findWindow('alertWindow');
452} catch (exception) {
453  console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception));
454}
455```
456
457## window.getLastWindow<sup>9+</sup>
458
459getLastWindow(ctx: BaseContext, callback: AsyncCallback&lt;Window&gt;): void
460
461获取当前应用内最后显示的窗口,使用callback异步回调。
462
463**系统能力:** SystemCapability.WindowManager.WindowManager.Core
464
465**参数:**
466
467| 参数名 | 类型 | 必填 | 说明 |
468| -------- | -------------------------------------- | -- | ---------------------------------------- |
469| ctx      | [BaseContext](js-apis-inner-application-baseContext.md) | 是 | 当前应用上下文信息。 |
470| callback | AsyncCallback&lt;[Window](#window)&gt; | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 |
471
472**错误码:**
473
474以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
475
476| 错误码ID | 错误信息 |
477| ------- | -------------------------------- |
478| 1300002 | This window state is abnormal.   |
479| 1300006 | This window context is abnormal. |
480
481**示例:**
482
483```ts
484import { BusinessError } from '@ohos.base';
485
486let windowClass: window.Window = window.findWindow("test");
487try {
488  class BaseContext {
489      stageMode: boolean = false;
490    }
491    let context: BaseContext = { stageMode: false };
492  window.getLastWindow(context, (err: BusinessError, data) => {
493    const errCode: number = err.code;
494    if (errCode) {
495      console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
496      return;
497    }
498    windowClass = data;
499    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
500  });
501} catch (exception) {
502  console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
503}
504```
505
506## window.getLastWindow<sup>9+</sup>
507
508getLastWindow(ctx: BaseContext): Promise&lt;Window&gt;
509
510获取当前应用内最后显示的窗口,使用Promise异步回调。
511
512**系统能力:** SystemCapability.WindowManager.WindowManager.Core
513
514**参数:**
515
516| 参数名 | 类型 | 必填 | 说明 |
517| ------ | ----------- | ---- | ------------------------------------------------------------ |
518| ctx    | [BaseContext](js-apis-inner-application-baseContext.md) | 是   | 当前应用上下文信息。 |
519
520**返回值:**
521
522| 类型 | 说明 |
523| -------------------------------- | ------------------------------------------- |
524| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前应用内最后显示的窗口对象。 |
525
526**错误码:**
527
528以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
529
530| 错误码ID | 错误信息 |
531| ------- | -------------------------------- |
532| 1300002 | This window state is abnormal.   |
533| 1300006 | This window context is abnormal. |
534
535**示例:**
536
537```ts
538import { BusinessError } from '@ohos.base';
539
540let windowClass: window.Window = window.findWindow("test");
541class BaseContext {
542  stageMode: boolean = false;
543}
544let context: BaseContext = { stageMode: false };
545try {
546  let promise = window.getLastWindow(context);
547  promise.then((data) => {
548    windowClass = data;
549    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
550  }).catch((err: BusinessError) => {
551    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
552  });
553} catch (exception) {
554  console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
555}
556```
557
558## window.minimizeAll<sup>9+</sup>
559minimizeAll(id: number, callback: AsyncCallback&lt;void&gt;): void
560
561最小化某显示设备下的所有窗口。
562
563**系统接口:** 此接口为系统接口。
564
565**系统能力:** SystemCapability.WindowManager.WindowManager.Core
566
567**参数:**
568
569| 参数名   | 类型                      | 必填 | 说明           |
570| -------- | ------------------------- | ---- | -------------- |
571| id       | number                    | 是   | 显示设备[Display](js-apis-display.md#display)的ID号,该参数仅支持整数输入。 |
572| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。     |
573
574**错误码:**
575
576以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
577
578| 错误码ID | 错误信息 |
579| ------- | -------------------------------------------- |
580| 1300003 | This window manager service works abnormally. |
581
582**示例:**
583
584```ts
585import display from '@ohos.display'
586import { BusinessError } from '@ohos.base';
587
588let displayClass: display.Display | null = null;
589try {
590  displayClass = display.getDefaultDisplaySync();
591
592  try {
593    window.minimizeAll(displayClass.id, (err: BusinessError) => {
594      const errCode: number = err.code;
595      if (errCode) {
596        console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
597        return;
598      }
599      console.info('Succeeded in minimizing all windows.');
600    });
601  } catch (exception) {
602    console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
603  }
604} catch (exception) {
605  console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
606}
607```
608
609## window.minimizeAll<sup>9+</sup>
610minimizeAll(id: number): Promise&lt;void&gt;
611
612最小化某显示设备下的所有窗口。
613
614**系统接口:** 此接口为系统接口。
615
616**系统能力:** SystemCapability.WindowManager.WindowManager.Core
617
618**参数:**
619
620| 参数名   | 类型                      | 必填 | 说明           |
621| -------- | ------------------------- | ---- | -------------- |
622| id       | number                    | 是   | 显示设备[Display](js-apis-display.md#display)的ID号,该参数仅支持整数输入。 |
623
624**返回值:**
625
626| 类型                | 说明                      |
627| ------------------- | ------------------------- |
628| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
629
630**错误码:**
631
632以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
633
634| 错误码ID | 错误信息 |
635| ------- | -------------------------------------------- |
636| 1300003 | This window manager service works abnormally. |
637
638**示例:**
639
640```ts
641import display from '@ohos.display'
642import { BusinessError } from '@ohos.base';
643
644let displayClass: display.Display | null = null;
645try {
646  displayClass = display.getDefaultDisplaySync();
647
648  try {
649    let promise = window.minimizeAll(displayClass.id);
650    promise.then(() => {
651      console.info('Succeeded in minimizing all windows.');
652    }).catch((err: BusinessError) => {
653      console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
654    });
655  } catch (exception) {
656    console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
657  }
658} catch (exception) {
659  console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
660}
661```
662
663## window.toggleShownStateForAllAppWindows<sup>9+</sup>
664toggleShownStateForAllAppWindows(callback: AsyncCallback&lt;void&gt;): void
665
666多窗口快速切换时隐藏或者恢复应用窗口。
667
668**系统接口:** 此接口为系统接口。
669
670**系统能力:** SystemCapability.WindowManager.WindowManager.Core
671
672**参数:**
673
674| 参数名   | 类型                      | 必填 | 说明           |
675| -------- | ------------------------- | ---- | -------------- |
676| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。     |
677
678**错误码:**
679
680以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
681
682| 错误码ID | 错误信息 |
683| ------- | -------------------------------------------- |
684| 1300003 | This window manager service works abnormally. |
685
686**示例:**
687
688```ts
689import { BusinessError } from '@ohos.base';
690
691window.toggleShownStateForAllAppWindows((err: BusinessError) => {
692  const errCode: number = err.code;
693  if (errCode) {
694    console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
695    return;
696  }
697  console.info('Succeeded in toggling shown state for all app windows.');
698});
699```
700
701## window.toggleShownStateForAllAppWindows<sup>9+</sup>
702toggleShownStateForAllAppWindows(): Promise&lt;void&gt;
703
704多窗口快速切换时隐藏或者恢复应用窗口。
705
706**系统接口:** 此接口为系统接口。
707
708**系统能力:** SystemCapability.WindowManager.WindowManager.Core
709
710**返回值:**
711
712| 类型                | 说明                      |
713| ------------------- | ------------------------- |
714| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
715
716**错误码:**
717
718以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
719
720| 错误码ID | 错误信息 |
721| ------- | -------------------------------------------- |
722| 1300003 | This window manager service works abnormally. |
723
724**示例:**
725
726```ts
727import { BusinessError } from '@ohos.base';
728
729let promise = window.toggleShownStateForAllAppWindows();
730promise.then(() => {
731  console.info('Succeeded in toggling shown state for all app windows.');
732}).catch((err: BusinessError) => {
733  console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
734});
735```
736
737## window.setWindowLayoutMode<sup>9+</sup>
738setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback&lt;void&gt;): void
739
740设置窗口布局模式。
741
742**系统接口:** 此接口为系统接口。
743
744**系统能力:** SystemCapability.WindowManager.WindowManager.Core
745
746**参数:**
747
748| 参数名   | 类型                      | 必填 | 说明           |
749| -------- | ------------------------- | ---- | -------------- |
750| mode       | [WindowLayoutMode](#windowlayoutmode9)                  | 是   | 设置的窗口布局模式。 |
751| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。     |
752
753**错误码:**
754
755以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
756
757| 错误码ID | 错误信息 |
758| ------- | -------------------------------------------- |
759| 1300003 | This window manager service works abnormally. |
760
761**示例:**
762
763```ts
764import { BusinessError } from '@ohos.base';
765
766try {
767  window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (err: BusinessError) => {
768    const errCode: number = err.code;
769    if (errCode) {
770      console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
771      return;
772    }
773    console.info('Succeeded in setting window layout mode.');
774  });
775} catch (exception) {
776  console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
777}
778```
779
780## window.setWindowLayoutMode<sup>9+</sup>
781setWindowLayoutMode(mode: WindowLayoutMode): Promise&lt;void&gt;
782
783设置窗口布局模式。
784
785**系统接口:** 此接口为系统接口。
786
787**系统能力:** SystemCapability.WindowManager.WindowManager.Core
788
789**参数:**
790
791| 参数名   | 类型                      | 必填 | 说明           |
792| -------- | ------------------------- | ---- | -------------- |
793| mode       | [WindowLayoutMode](#windowlayoutmode9)                    | 是   | 设置的窗口布局模式。 |
794
795**返回值:**
796
797| 类型                | 说明                      |
798| ------------------- | ------------------------- |
799| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
800
801**错误码:**
802
803以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
804
805| 错误码ID | 错误信息 |
806| ------- | -------------------------------------------- |
807| 1300003 | This window manager service works abnormally. |
808
809**示例:**
810
811```ts
812import { BusinessError } from '@ohos.base';
813
814try {
815  let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE);
816  promise.then(() => {
817    console.info('Succeeded in setting window layout mode.');
818  }).catch((err: BusinessError) => {
819    console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
820  });
821} catch (exception) {
822  console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
823}
824```
825
826## window.on('systemBarTintChange')<sup>8+</sup>
827
828on(type: 'systemBarTintChange', callback: Callback&lt;SystemBarTintState&gt;): void
829
830开启状态栏、导航栏属性变化的监听。
831
832**系统接口:** 此接口为系统接口。
833
834**系统能力:** SystemCapability.WindowManager.WindowManager.Core
835
836**参数:**
837
838| 参数名   | 类型                                                       | 必填 | 说明                                                         |
839| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
840| type     | string                                                     | 是   | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
841| callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | 是   | 回调函数。返回当前的状态栏、导航栏信息集合。                 |
842
843**示例:**
844
845```ts
846try {
847  window.on('systemBarTintChange', (data) => {
848    console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
849  });
850} catch (exception) {
851  console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
852}
853```
854
855## window.off('systemBarTintChange')<sup>8+</sup>
856
857off(type: 'systemBarTintChange', callback?: Callback&lt;SystemBarTintState &gt;): void
858
859关闭状态栏、导航栏属性变化的监听。
860
861**系统接口:** 此接口为系统接口。
862
863**系统能力:** SystemCapability.WindowManager.WindowManager.Core
864
865**参数:**
866
867| 参数名   | 类型                                                       | 必填 | 说明                                                         |
868| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
869| type     | string                                                     | 是   | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
870| callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | 否   | 回调函数。返回当前的状态栏、导航栏信息集合。如果传入参数,则关闭该监听。如果未传入参数,则关闭所有状态栏、导航栏属性变化的监听。                |
871
872**示例:**
873
874```ts
875try {
876  window.off('systemBarTintChange');
877} catch (exception) {
878  console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
879}
880```
881
882## window.on('gestureNavigationEnabledChange')<sup>10+</sup>
883
884on(type: 'gestureNavigationEnabledChange', callback: Callback&lt;boolean&gt;): void
885
886添加手势导航启用状态变化的监听。
887
888**系统接口:** 此接口为系统接口。
889
890**系统能力:** SystemCapability.WindowManager.WindowManager.Core
891
892**参数:**
893
894| 参数名   | 类型                     | 必填 | 说明                                                                          |
895| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- |
896| type     | string                  | 是   | 监听事件,固定为'gestureNavigationEnabledChange',即手势导航启用状态变化事件。    |
897| callback | Callback&lt;boolean&gt; | 是   | 回调函数。返回当前手势导航的启用状态。true表示手势导航状态变化为启用;false表示手势导航状态变化为禁用。 |
898
899**错误码:**
900
901以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
902
903| 错误码ID | 错误信息 |
904| ------- | -------------------------------------------- |
905| 1300002 | This window state is abnormal. |
906| 1300003 | This window manager service works abnormally. |
907
908**示例:**
909
910```ts
911try {
912  window.on('gestureNavigationEnabledChange', (data) => {
913    console.info('Succeeded in enabling the listener for gesture navigation status changes. Data: ' + JSON.stringify(data));
914  });
915} catch (exception) {
916  console.error('Failed to enable the listener for gesture navigation status changes. Cause: ' + JSON.stringify(exception));
917}
918```
919
920## window.off('gestureNavigationEnabledChange')<sup>10+</sup>
921
922off(type: 'gestureNavigationEnabledChange', callback?: Callback&lt;boolean&gt;): void
923
924移除手势导航启用状态变化的监听。
925
926**系统接口:** 此接口为系统接口。
927
928**系统能力:** SystemCapability.WindowManager.WindowManager.Core
929
930**参数:**
931
932| 参数名   | 类型                     | 必填 | 说明                                                        |
933| -------- | ----------------------- | -- | ------------------------------------------------------------ |
934| type     | string                  | 是 | 监听事件,固定为'gestureNavigationEnabledChange',即手势导航启用状态变化事件。 |
935| callback | Callback&lt;boolean&gt; | 否 | 已注册的回调函数。如果传入参数,则关闭该监听。如果未传入参数,则关闭所有手势导航启用状态变化的监听。 |
936
937**错误码:**
938
939以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
940
941| 错误码ID | 错误信息 |
942| ------- | -------------------------------------------- |
943| 1300002 | This window state is abnormal. |
944| 1300003 | This window manager service works abnormally. |
945
946**示例:**
947
948```ts
949try {
950  window.off('gestureNavigationEnabledChange');
951} catch (exception) {
952  console.error('Failed to disable the listener for gesture navigation status changes. Cause: ' + JSON.stringify(exception));
953}
954```
955
956## window.on('waterMarkFlagChange')<sup>10+</sup>
957
958on(type: 'waterMarkFlagChange', callback: Callback&lt;boolean&gt;): void
959
960添加水印启用状态变化的监听。
961
962**系统接口:** 此接口为系统接口。
963
964**系统能力:** SystemCapability.WindowManager.WindowManager.Core
965
966**参数:**
967
968| 参数名   | 类型                     | 必填 | 说明                                                                          |
969| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- |
970| type     | string                  | 是   | 监听事件,固定为'waterMarkFlagChange',即水印启用状态变化事件。    |
971| callback | Callback&lt;boolean&gt; | 是   | 回调函数。返回当前水印的启用状态。true表示当前已启用水印;false表示当前未启用水印。 |
972
973**错误码:**
974
975以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
976
977| 错误码ID | 错误信息 |
978| ------- | -------------------------------------------- |
979| 1300003 | This window manager service works abnormally. |
980
981**示例:**
982
983```ts
984try {
985  window.on('waterMarkFlagChange', (data) => {
986    console.info('Succeeded in enabling the listener for watermark flag changes. Data: ' + JSON.stringify(data));
987  });
988} catch (exception) {
989  console.error('Failed to enable the listener for watermark flag changes. Cause: ' + JSON.stringify(exception));
990}
991```
992
993## window.off('waterMarkFlagChange')<sup>10+</sup>
994
995off(type: 'waterMarkFlagChange', callback?: Callback&lt;boolean&gt;): void
996
997移除水印启用状态变化的监听。
998
999**系统接口:** 此接口为系统接口。
1000
1001**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1002
1003**参数:**
1004
1005| 参数名   | 类型                     | 必填 | 说明                                                        |
1006| -------- | ----------------------- | -- | ------------------------------------------------------------ |
1007| type     | string                  | 是 | 监听事件,固定为'waterMarkFlagChange',即水印启用状态变化事件。 |
1008| callback | Callback&lt;boolean&gt; | 否 | 已注册的回调函数。如果传入参数,则关闭该监听。如果未传入参数,则关闭所有水印启用状态变化的监听。 |
1009
1010**错误码:**
1011
1012以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1013
1014| 错误码ID | 错误信息 |
1015| ------- | -------------------------------------------- |
1016| 1300003 | This window manager service works abnormally. |
1017
1018**示例:**
1019
1020```ts
1021try {
1022  window.off('waterMarkFlagChange');
1023} catch (exception) {
1024  console.error('Failed to disable the listener for watermark flag changes. Cause: ' + JSON.stringify(exception));
1025}
1026```
1027
1028## window.setGestureNavigationEnabled<sup>10+</sup>
1029setGestureNavigationEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
1030
1031设置手势导航启用状态。使用callback异步回调。
1032
1033**系统接口:** 此接口为系统接口。
1034
1035**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1036
1037**参数:**
1038
1039| 参数名   | 类型                      | 必填 | 说明           |
1040| -------- | ------------------------- | ---- | -------------- |
1041| enable   | boolean                  | 是   | 设置手势导航启用状态。true表示启用手势导航;false表示禁用手势导航。 |
1042| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。 |
1043
1044**错误码:**
1045
1046以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1047
1048| 错误码ID | 错误信息 |
1049| ------- | --------------------------------------------- |
1050| 1300002 | This window state is abnormal.                |
1051| 1300003 | This window manager service works abnormally. |
1052
1053**示例:**
1054
1055```ts
1056import { BusinessError } from '@ohos.base';
1057
1058try {
1059  window.setGestureNavigationEnabled(true, (err: BusinessError) => {
1060    const errCode: number = err.code;
1061    if (errCode) {
1062      console.error('Failed to set gesture navigation enabled. Cause: ' + JSON.stringify(err));
1063      return;
1064    }
1065    console.info('Succeeded in setting gesture navigation enabled.');
1066  });
1067} catch (exception) {
1068  console.error('Failed to set gesture navigation enabled. Cause: ' + JSON.stringify(exception));
1069}
1070```
1071
1072## window.setGestureNavigationEnabled<sup>10+</sup>
1073setGestureNavigationEnabled(enable: boolean): Promise&lt;void&gt;
1074
1075设置手势导航启用状态。使用Promise异步回调。
1076
1077**系统接口:** 此接口为系统接口。
1078
1079**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1080
1081**参数:**
1082
1083| 参数名 | 类型     | 必填  | 说明                 |
1084| ------ | ------- | ---- | -------------------- |
1085| enable | boolean | 是   | 设置手势导航启用状态。true表示启用手势导航;false表示禁用手势导航。 |
1086
1087**返回值:**
1088
1089| 类型                | 说明                      |
1090| ------------------- | ------------------------- |
1091| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1092
1093**错误码:**
1094
1095以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1096
1097| 错误码ID | 错误信息 |
1098| ------- | -------------------------------------------- |
1099| 1300002 | This window state is abnormal.                |
1100| 1300003 | This window manager service works abnormally. |
1101
1102**示例:**
1103
1104```ts
1105import { BusinessError } from '@ohos.base';
1106
1107try {
1108  let promise = window.setGestureNavigationEnabled(true);
1109  promise.then(() => {
1110    console.info('Succeeded in setting gesture navigation enabled.');
1111  }).catch((err: BusinessError) => {
1112    console.error('Failed to set gesture navigation enabled. Cause: ' + JSON.stringify(err));
1113  });
1114} catch (exception) {
1115  console.error('Failed to set gesture navigation enabled. Cause: ' + JSON.stringify(exception));
1116}
1117```
1118
1119## window.setWaterMarkImage<sup>10+</sup>
1120setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean, callback: AsyncCallback&lt;void&gt;): void
1121
1122设置水印图片显示状态。使用callback异步回调。
1123
1124**系统接口:** 此接口为系统接口。
1125
1126**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1127
1128**参数:**
1129
1130| 参数名   | 类型                      | 必填 | 说明           |
1131| -------- | ------------------------- | ---- | -------------- |
1132| pixelMap | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 水印图片。 |
1133| enable   | boolean                  | 是   | 设置是否显示水印图片。true显示水印图片;false表示不显示水印图片。 |
1134| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。 |
1135
1136**错误码:**
1137
1138以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1139
1140| 错误码ID | 错误信息 |
1141| ------- | --------------------------------------------- |
1142| 1300003 | This window manager service works abnormally. |
1143
1144**示例:**
1145
1146```ts
1147import image from '@ohos.multimedia.image';
1148import { BusinessError } from '@ohos.base';
1149
1150let enable: boolean = true;
1151let color: ArrayBuffer = new ArrayBuffer(0);
1152let initializationOptions: image.InitializationOptions = {
1153  size: {
1154    height: 100,
1155    width: 100
1156  }
1157};
1158image.createPixelMap(color, initializationOptions).then((pixelMap: image.PixelMap) => {
1159  console.info('Succeeded in creating pixelmap.');
1160  try {
1161    window.setWaterMarkImage(pixelMap, enable, (err: BusinessError) => {
1162      const errCode: number = err.code;
1163      if (errCode) {
1164        console.error('Failed to show watermark image. Cause: ' + JSON.stringify(err));
1165        return;
1166      }
1167      console.info('Succeeded in showing watermark image.');
1168    });
1169  } catch (exception) {
1170    console.error('Failed to show watermark image. Cause: ' + JSON.stringify(exception));
1171  }
1172}).catch((err: BusinessError) => {
1173  console.error('Failed to create PixelMap. Cause: ' + JSON.stringify(err));
1174});
1175```
1176
1177## window.setWaterMarkImage<sup>10+</sup>
1178setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean): Promise&lt;void&gt;
1179
1180设置水印图片显示状态。使用Promise异步回调。
1181
1182**系统接口:** 此接口为系统接口。
1183
1184**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1185
1186**参数:**
1187
1188| 参数名 | 类型                        | 必填  | 说明                 |
1189| ------ | --------------------------- | ---- | -------------------- |
1190| pixelMap | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 水印图片。 |
1191| enable   | boolean                  | 是   | 设置是否显示水印图片。true显示水印图片;false表示不显示水印图片。 |
1192
1193**返回值:**
1194
1195| 类型                | 说明                      |
1196| ------------------- | ------------------------- |
1197| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1198
1199**错误码:**
1200
1201以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1202
1203| 错误码ID | 错误信息 |
1204| ------- | -------------------------------------------- |
1205| 1300003 | This window manager service works abnormally. |
1206
1207**示例:**
1208
1209```ts
1210import image from '@ohos.multimedia.image';
1211import { BusinessError } from '@ohos.base';
1212
1213let enable: boolean = true;
1214let color: ArrayBuffer = new ArrayBuffer(0);
1215let initializationOptions: image.InitializationOptions = {
1216  size: {
1217    height: 100,
1218    width: 100
1219  }
1220};
1221image.createPixelMap(color, initializationOptions).then((pixelMap: image.PixelMap) => {
1222  console.info('Succeeded in creating pixelmap.');
1223  try {
1224    let promise = window.setWaterMarkImage(pixelMap, enable);
1225    promise.then(() => {
1226      console.info('Succeeded in showing watermark image.');
1227    }).catch((err: BusinessError) => {
1228      console.error('Failed to show watermark image. Cause: ' + JSON.stringify(err));
1229    });
1230  } catch (exception) {
1231    console.error('Failed to show watermark image. Cause: ' + JSON.stringify(exception));
1232  }
1233}).catch((err: BusinessError) => {
1234  console.error('Failed to create PixelMap. Cause: ' + JSON.stringify(err));
1235});
1236```
1237
1238## window.create<sup>(deprecated)</sup>
1239
1240create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
1241
1242创建子窗口,使用callback异步回调。
1243
1244> **说明:**
1245>
1246> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9)。
1247
1248**模型约束:** 此接口仅可在FA模型下使用。
1249
1250**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1251
1252**参数:**
1253
1254| 参数名   | 类型                                   | 必填 | 说明                                 |
1255| -------- | -------------------------------------- | ---- | ------------------------------------ |
1256| id       | string                                 | 是   | 窗口id。                             |
1257| type     | [WindowType](#windowtype7)              | 是   | 窗口类型。                           |
1258| callback | AsyncCallback&lt;[Window](#window)&gt; | 是   | 回调函数。返回当前创建的子窗口对象。 |
1259
1260**示例:**
1261
1262```ts
1263import { BusinessError } from '@ohos.base';
1264
1265let windowClass: window.Window = window.findWindow("test");
1266window.create('first', window.WindowType.TYPE_APP, (err: BusinessError, data) => {
1267  const errCode: number = err.code;
1268  if (errCode) {
1269    console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
1270    return;
1271  }
1272  windowClass = data;
1273  console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
1274});
1275```
1276
1277## window.create<sup>(deprecated)</sup>
1278
1279create(id: string, type: WindowType): Promise&lt;Window&gt;
1280
1281创建子窗口,使用Promise异步回调。
1282
1283> **说明:**
1284>
1285> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9-1)。
1286
1287**模型约束:** 此接口仅可在FA模型下使用。
1288
1289**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1290
1291**参数:**
1292
1293| 参数名 | 类型                      | 必填 | 说明       |
1294| ------ | ------------------------- | ---- | ---------- |
1295| id     | string                    | 是   | 窗口id。   |
1296| type   | [WindowType](#windowtype7) | 是   | 窗口类型。 |
1297
1298**返回值:**
1299
1300| 类型                             | 说明                                    |
1301| -------------------------------- | --------------------------------------- |
1302| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前创建的子窗口对象。 |
1303
1304**示例:**
1305
1306```ts
1307import { BusinessError } from '@ohos.base';
1308
1309let windowClass: window.Window = window.findWindow("test");
1310let promise = window.create('first', window.WindowType.TYPE_APP);
1311promise.then((data) => {
1312  windowClass = data;
1313  console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
1314}).catch((err: BusinessError) => {
1315  console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
1316});
1317```
1318
1319## window.create<sup>(deprecated)</sup>
1320
1321create(ctx: BaseContext, id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
1322
1323创建系统窗口,使用callback异步回调。
1324
1325> **说明:**
1326>
1327> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9)。
1328
1329**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1330
1331**参数:**
1332
1333| 参数名   | 类型                                                    | 必填 | 说明                                 |
1334| -------- | ------------------------------------------------------- | ---- | ------------------------------------ |
1335| ctx      | [BaseContext](js-apis-inner-application-baseContext.md) | 是   | 当前应用上下文信息。                 |
1336| id       | string                                                  | 是   | 窗口id。                             |
1337| type     | [WindowType](#windowtype7)                              | 是   | 窗口类型。                           |
1338| callback | AsyncCallback&lt;[Window](#window)&gt;                  | 是   | 回调函数。返回当前创建的子窗口对象。 |
1339
1340**示例:**
1341
1342```ts
1343import { BusinessError } from '@ohos.base';
1344
1345let windowClass: window.Window = window.findWindow("test");
1346window.create('alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err: BusinessError, data) => {
1347  const errCode: number = err.code;
1348  if (errCode) {
1349    console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
1350    return;
1351  }
1352  windowClass = data;
1353  console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data));
1354  windowClass.resetSize(500, 1000);
1355});
1356```
1357
1358## window.create<sup>(deprecated)</sup>
1359
1360create(ctx: BaseContext, id: string, type: WindowType): Promise&lt;Window&gt;
1361
1362创建系统窗口,使用Promise异步回调。
1363
1364> **说明:**
1365>
1366> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9-1)。
1367
1368**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1369
1370**参数:**
1371
1372| 参数名 | 类型                      | 必填 | 说明                                                         |
1373| ------ | ------------------------- | ---- | ------------------------------------------------------------ |
1374| ctx    | [BaseContext](js-apis-inner-application-baseContext.md) | 是   | 当前应用上下文信息。 |
1375| id     | string                    | 是   | 窗口id。                                                     |
1376| type   | [WindowType](#windowtype7) | 是   | 窗口类型。                                                   |
1377
1378**返回值:**
1379
1380| 类型                             | 说明                                    |
1381| -------------------------------- | --------------------------------------- |
1382| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前创建的子窗口对象。 |
1383
1384**示例:**
1385
1386```ts
1387import { BusinessError } from '@ohos.base';
1388
1389let windowClass: window.Window = window.findWindow("test");
1390let promise = window.create('alertWindow', window.WindowType.TYPE_SYSTEM_ALERT);
1391promise.then((data) => {
1392  windowClass = data;
1393  console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
1394}).catch((err: BusinessError) => {
1395  console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
1396});
1397```
1398
1399## window.find<sup>(deprecated)</sup>
1400
1401find(id: string, callback: AsyncCallback&lt;Window&gt;): void
1402
1403查找id所对应的窗口,使用callback异步回调。
1404
1405> **说明:**
1406>
1407> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[findWindow()](#windowfindwindow9)。
1408
1409**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1410
1411**参数:**
1412
1413| 参数名   | 类型                                   | 必填 | 说明                                 |
1414| -------- | -------------------------------------- | ---- | ------------------------------------ |
1415| id       | string                                 | 是   | 窗口id。                             |
1416| callback | AsyncCallback&lt;[Window](#window)&gt; | 是   | 回调函数。返回当前查找到的窗口对象。 |
1417
1418**示例:**
1419
1420```ts
1421import { BusinessError } from '@ohos.base';
1422
1423let windowClass: window.Window = window.findWindow("test");
1424window.find('alertWindow', (err: BusinessError, data) => {
1425  const errCode: number = err.code;
1426  if (errCode) {
1427    console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
1428    return;
1429  }
1430  windowClass = data;
1431  console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
1432});
1433```
1434
1435## window.find<sup>(deprecated)</sup>
1436
1437find(id: string): Promise&lt;Window&gt;
1438
1439查找id所对应的窗口,使用Promise异步回调。
1440
1441> **说明:**
1442>
1443> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[findWindow()](#windowfindwindow9)。
1444
1445**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1446
1447**参数:**
1448
1449| 参数名 | 类型   | 必填 | 说明     |
1450| ------ | ------ | ---- | -------- |
1451| id     | string | 是   | 窗口id。 |
1452
1453**返回值:**
1454
1455| 类型                             | 说明                                  |
1456| -------------------------------- | ------------------------------------- |
1457| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前查找的窗口对象。 |
1458
1459**示例:**
1460
1461```ts
1462import { BusinessError } from '@ohos.base';
1463
1464let windowClass: window.Window = window.findWindow("test");
1465let promise = window.find('alertWindow');
1466promise.then((data) => {
1467  windowClass = data;
1468  console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
1469}).catch((err: BusinessError) => {
1470  console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
1471});
1472```
1473
1474## window.getTopWindow<sup>(deprecated)</sup>
1475
1476getTopWindow(callback: AsyncCallback&lt;Window&gt;): void
1477
1478获取当前应用内最后显示的窗口,使用callback异步回调。
1479
1480> **说明:**
1481>
1482> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9)。
1483
1484**模型约束:** 此接口仅可在FA模型下使用。
1485
1486**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1487
1488**参数:**
1489
1490| 参数名   | 类型                                   | 必填 | 说明                                         |
1491| -------- | -------------------------------------- | ---- | -------------------------------------------- |
1492| callback | AsyncCallback&lt;[Window](#window)&gt; | 是   | 回调函数。返回当前应用内最后显示的窗口对象。 |
1493
1494**示例:**
1495
1496```ts
1497import { BusinessError } from '@ohos.base';
1498
1499let windowClass: window.Window = window.findWindow("test");
1500window.getTopWindow((err: BusinessError, data) => {
1501  const errCode: number = err.code;
1502  if (errCode) {
1503    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
1504    return;
1505  }
1506  windowClass = data;
1507  console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
1508});
1509```
1510
1511## window.getTopWindow<sup>(deprecated)</sup>
1512
1513getTopWindow(): Promise&lt;Window&gt;
1514
1515获取当前应用内最后显示的窗口,使用Promise异步回调。
1516
1517> **说明:**
1518>
1519> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9-1)。
1520
1521**模型约束:** 此接口仅可在FA模型下使用。
1522
1523**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1524
1525**返回值:**
1526
1527| 类型                             | 说明                                            |
1528| -------------------------------- | ----------------------------------------------- |
1529| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前应用内最后显示的窗口对象。 |
1530
1531**示例:**
1532
1533```ts
1534import { BusinessError } from '@ohos.base';
1535
1536let windowClass: window.Window = window.findWindow("test");
1537let promise = window.getTopWindow();
1538promise.then((data)=> {
1539    windowClass = data;
1540    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
1541}).catch((err: BusinessError)=>{
1542    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
1543});
1544```
1545
1546## window.getTopWindow<sup>(deprecated)</sup>
1547
1548getTopWindow(ctx: BaseContext, callback: AsyncCallback&lt;Window&gt;): void
1549
1550获取当前应用内最后显示的窗口,使用callback异步回调。
1551
1552> **说明:**
1553>
1554> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9)。
1555
1556**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1557
1558**参数:**
1559
1560| 参数名   | 类型                                   | 必填 | 说明                                                         |
1561| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
1562| ctx      | [BaseContext](js-apis-inner-application-baseContext.md)                            | 是   | 当前应用上下文信息。 |
1563| callback | AsyncCallback&lt;[Window](#window)&gt; | 是   | 回调函数。返回当前应用内最后显示的窗口对象。                 |
1564
1565**示例:**
1566
1567```ts
1568import { BusinessError } from '@ohos.base';
1569
1570let windowClass: window.Window = window.findWindow("test");
1571let promise = window.getTopWindow();
1572promise.then((data) => {
1573  windowClass = data;
1574  console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
1575}).catch((err: BusinessError) => {
1576  console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
1577});
1578```
1579
1580## window.getTopWindow<sup>(deprecated)</sup>
1581
1582getTopWindow(ctx: BaseContext): Promise&lt;Window&gt;
1583
1584获取当前应用内最后显示的窗口,使用Promise异步回调。
1585
1586> **说明:**
1587>
1588> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9-1)。
1589
1590**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1591
1592**参数:**
1593
1594| 参数名 | 类型    | 必填 | 说明                                                         |
1595| ------ | ----------- | ---- | ------------------------------------------------------------ |
1596| ctx    | [BaseContext](js-apis-inner-application-baseContext.md) | 是   | 当前应用上下文信息。 |
1597
1598**返回值:**
1599
1600| 类型                             | 说明                                            |
1601| -------------------------------- | ----------------------------------------------- |
1602| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前应用内最后显示的窗口对象。 |
1603
1604**示例:**
1605
1606```ts
1607import { BusinessError } from '@ohos.base';
1608
1609let windowClass: window.Window = window.findWindow("test");
1610let promise = window.getTopWindow();
1611promise.then((data) => {
1612  windowClass = data;
1613  console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
1614}).catch((err: BusinessError) => {
1615  console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
1616});
1617```
1618
1619## Window
1620
1621当前窗口实例,窗口管理器管理的基本单元。
1622
1623下列API示例中都需先使用[getLastWindow()](#windowgetlastwindow9)、[createWindow()](#windowcreatewindow9)、[findWindow()](#windowfindwindow9)中的任一方法获取到Window实例,再通过此实例调用对应方法。
1624
1625### hide<sup>7+</sup>
1626
1627hide (callback: AsyncCallback&lt;void&gt;): void
1628
1629隐藏当前窗口,使用callback异步回调。
1630
1631**系统接口:** 此接口为系统接口。
1632
1633**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1634
1635**参数:**
1636
1637| 参数名   | 类型                      | 必填 | 说明       |
1638| -------- | ------------------------- | ---- | ---------- |
1639| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
1640
1641**错误码:**
1642
1643以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1644
1645| 错误码ID | 错误信息 |
1646| ------- | ------------------------------ |
1647| 1300002 | This window state is abnormal. |
1648
1649**示例:**
1650
1651```ts
1652import { BusinessError } from '@ohos.base';
1653
1654let windowClass: window.Window = window.findWindow("test");
1655windowClass.hide((err: BusinessError) => {
1656  const errCode: number = err.code;
1657  if (errCode) {
1658    console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
1659    return;
1660  }
1661  console.info('Succeeded in hiding the window.');
1662});
1663```
1664
1665### hide<sup>7+</sup>
1666
1667hide(): Promise&lt;void&gt;
1668
1669隐藏当前窗口,使用Promise异步回调。
1670
1671**系统接口:** 此接口为系统接口。
1672
1673**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1674
1675**返回值:**
1676
1677| 类型                | 说明                      |
1678| ------------------- | ------------------------- |
1679| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1680
1681**错误码:**
1682
1683以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1684
1685| 错误码ID | 错误信息 |
1686| ------- | ------------------------------ |
1687| 1300002 | This window state is abnormal. |
1688
1689**示例:**
1690
1691```ts
1692import { BusinessError } from '@ohos.base';
1693
1694let windowClass: window.Window = window.findWindow("test");
1695let promise = windowClass.hide();
1696promise.then(() => {
1697  console.info('Succeeded in hiding the window.');
1698}).catch((err: BusinessError) => {
1699  console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
1700});
1701```
1702
1703### hideWithAnimation<sup>9+</sup>
1704
1705hideWithAnimation(callback: AsyncCallback&lt;void&gt;): void
1706
1707隐藏当前窗口,过程中播放动画,使用callback异步回调。
1708
1709**系统接口:** 此接口为系统接口。
1710
1711**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1712
1713**参数:**
1714
1715| 参数名   | 类型                      | 必填 | 说明       |
1716| -------- | ------------------------- | ---- | ---------- |
1717| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
1718
1719**错误码:**
1720
1721以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1722
1723| 错误码ID | 错误信息 |
1724| ------- | -------------------------------------------- |
1725| 1300002 | This window state is abnormal.               |
1726| 1300003 | This window manager service works abnormally. |
1727| 1300004 | Unauthorized operation.                |
1728
1729**示例:**
1730
1731```ts
1732import { BusinessError } from '@ohos.base';
1733
1734let windowClass: window.Window = window.findWindow("test");
1735windowClass.hideWithAnimation((err: BusinessError) => {
1736  const errCode: number = err.code;
1737  if (errCode) {
1738    console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
1739    return;
1740  }
1741  console.info('Succeeded in hiding the window with animation.');
1742});
1743```
1744
1745### hideWithAnimation<sup>9+</sup>
1746
1747hideWithAnimation(): Promise&lt;void&gt;
1748
1749隐藏当前窗口,过程中播放动画,使用Promise异步回调。
1750
1751**系统接口:** 此接口为系统接口。
1752
1753**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1754
1755**返回值:**
1756
1757| 类型                | 说明                      |
1758| ------------------- | ------------------------- |
1759| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1760
1761**错误码:**
1762
1763以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1764
1765| 错误码ID | 错误信息 |
1766| ------- | -------------------------------------------- |
1767| 1300002 | This window state is abnormal.               |
1768| 1300003 | This window manager service works abnormally. |
1769| 1300004 | Unauthorized operation.                |
1770
1771**示例:**
1772
1773```ts
1774import { BusinessError } from '@ohos.base';
1775
1776let windowClass: window.Window = window.findWindow("test");
1777let promise = windowClass.hideWithAnimation();
1778promise.then(() => {
1779  console.info('Succeeded in hiding the window with animation.');
1780}).catch((err: BusinessError) => {
1781  console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
1782});
1783```
1784
1785### showWindow<sup>9+</sup>
1786
1787showWindow(callback: AsyncCallback&lt;void&gt;): void
1788
1789显示当前窗口,使用callback异步回调。
1790
1791**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1792
1793**参数:**
1794
1795| 参数名 | 类型 | 必填 | 说明 |
1796| -------- | ------------------------- | -- | --------- |
1797| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
1798
1799**错误码:**
1800
1801以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1802
1803| 错误码ID | 错误信息 |
1804| ------- | ------------------------------ |
1805| 1300002 | This window state is abnormal. |
1806
1807**示例:**
1808
1809```ts
1810import { BusinessError } from '@ohos.base';
1811
1812let windowClass: window.Window = window.findWindow("test");
1813windowClass.showWindow((err: BusinessError) => {
1814  const errCode: number = err.code;
1815  if (errCode) {
1816    console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
1817    return;
1818  }
1819  console.info('Succeeded in showing the window.');
1820});
1821```
1822
1823### showWindow<sup>9+</sup>
1824
1825showWindow(): Promise&lt;void&gt;
1826
1827显示当前窗口,使用Promise异步回调。
1828
1829**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1830
1831**返回值:**
1832
1833| 类型 | 说明 |
1834| ------------------- | ----------------------- |
1835| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1836
1837**错误码:**
1838
1839以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1840
1841| 错误码ID | 错误信息 |
1842| ------- | ------------------------------ |
1843| 1300002 | This window state is abnormal. |
1844
1845**示例:**
1846
1847```ts
1848import { BusinessError } from '@ohos.base';
1849
1850let windowClass: window.Window = window.findWindow("test");
1851let promise = windowClass.showWindow();
1852promise.then(() => {
1853  console.info('Succeeded in showing the window.');
1854}).catch((err: BusinessError) => {
1855  console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
1856});
1857```
1858
1859### showWithAnimation<sup>9+</sup>
1860
1861showWithAnimation(callback: AsyncCallback&lt;void&gt;): void
1862
1863显示当前窗口,过程中播放动画,使用callback异步回调。
1864
1865**系统接口:** 此接口为系统接口。
1866
1867**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1868
1869**参数:**
1870
1871| 参数名   | 类型                      | 必填 | 说明       |
1872| -------- | ------------------------- | ---- | ---------- |
1873| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
1874
1875**错误码:**
1876
1877以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1878
1879| 错误码ID | 错误信息 |
1880| ------- | -------------------------------------------- |
1881| 1300002 | This window state is abnormal.               |
1882| 1300003 | This window manager service works abnormally. |
1883| 1300004 | Unauthorized operation.                |
1884
1885**示例:**
1886
1887```ts
1888import { BusinessError } from '@ohos.base';
1889
1890let windowClass: window.Window = window.findWindow("test");
1891windowClass.showWithAnimation((err: BusinessError) => {
1892  const errCode: number = err.code;
1893  if (errCode) {
1894    console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
1895    return;
1896  }
1897  console.info('Succeeded in showing the window with animation.');
1898});
1899```
1900
1901### showWithAnimation<sup>9+</sup>
1902
1903showWithAnimation(): Promise&lt;void&gt;
1904
1905显示当前窗口,过程中播放动画,使用Promise异步回调。
1906
1907**系统接口:** 此接口为系统接口。
1908
1909**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1910
1911**返回值:**
1912
1913| 类型                | 说明                      |
1914| ------------------- | ------------------------- |
1915| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1916
1917**错误码:**
1918
1919以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1920
1921| 错误码ID | 错误信息 |
1922| ------- | -------------------------------------------- |
1923| 1300002 | This window state is abnormal.               |
1924| 1300003 | This window manager service works abnormally. |
1925| 1300004 | Unauthorized operation.                |
1926
1927**示例:**
1928
1929```ts
1930import { BusinessError } from '@ohos.base';
1931
1932let windowClass: window.Window = window.findWindow("test");
1933let promise = windowClass.showWithAnimation();
1934promise.then(() => {
1935  console.info('Succeeded in showing the window with animation.');
1936}).catch((err: BusinessError) => {
1937  console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
1938});
1939```
1940
1941### destroyWindow<sup>9+</sup>
1942
1943destroyWindow(callback: AsyncCallback&lt;void&gt;): void
1944
1945销毁当前窗口,使用callback异步回调。
1946
1947**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1948
1949**参数:**
1950
1951| 参数名 | 类型 | 必填 | 说明 |
1952| -------- | ------------------------- | -- | --------- |
1953| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
1954
1955**错误码:**
1956
1957以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1958
1959| 错误码ID | 错误信息 |
1960| ------- | -------------------------------------------- |
1961| 1300002 | This window state is abnormal.               |
1962| 1300003 | This window manager service works abnormally. |
1963
1964**示例:**
1965
1966```ts
1967import { BusinessError } from '@ohos.base';
1968
1969let windowClass: window.Window = window.findWindow("test");
1970windowClass.destroyWindow((err) => {
1971  const errCode: number = err.code;
1972  if (errCode) {
1973    console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
1974    return;
1975  }
1976  console.info('Succeeded in destroying the window.');
1977});
1978```
1979
1980### destroyWindow<sup>9+</sup>
1981
1982destroyWindow(): Promise&lt;void&gt;
1983
1984销毁当前窗口,使用Promise异步回调。
1985
1986**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1987
1988**返回值:**
1989
1990| 类型 | 说明 |
1991| ------------------- | ------------------------ |
1992| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1993
1994**错误码:**
1995
1996以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
1997
1998| 错误码ID | 错误信息 |
1999| ------- | -------------------------------------------- |
2000| 1300002 | This window state is abnormal.               |
2001| 1300003 | This window manager service works abnormally. |
2002
2003**示例:**
2004
2005```ts
2006import { BusinessError } from '@ohos.base';
2007
2008let windowClass: window.Window = window.findWindow("test");
2009let promise = windowClass.destroyWindow();
2010promise.then(() => {
2011  console.info('Succeeded in destroying the window.');
2012}).catch((err: BusinessError) => {
2013  console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
2014});
2015```
2016
2017### moveWindowTo<sup>9+</sup>
2018
2019moveWindowTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void
2020
2021移动窗口位置,使用callback异步回调。
2022
2023全屏模式窗口不支持该操作。
2024
2025**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2026
2027**参数:**
2028
2029| 参数名 | 类型 | 必填 | 说明 |
2030| -------- | ------------------------- | -- | --------------------------------------------- |
2031| x        | number                    | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px,该参数仅支持整数输入。 |
2032| y        | number                    | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px,该参数仅支持整数输入。 |
2033| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。                                     |
2034
2035**错误码:**
2036
2037以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2038
2039| 错误码ID | 错误信息 |
2040| ------- | -------------------------------------------- |
2041| 1300002 | This window state is abnormal.               |
2042| 1300003 | This window manager service works abnormally. |
2043
2044**示例:**
2045
2046```ts
2047import { BusinessError } from '@ohos.base';
2048
2049try {
2050  let windowClass: window.Window = window.findWindow("test");
2051  windowClass.moveWindowTo(300, 300, (err: BusinessError) => {
2052    const errCode: number = err.code;
2053    if (errCode) {
2054      console.error('Failed to move the window. Cause:' + JSON.stringify(err));
2055      return;
2056    }
2057    console.info('Succeeded in moving the window.');
2058  });
2059} catch (exception) {
2060  console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
2061}
2062```
2063
2064### moveWindowTo<sup>9+</sup>
2065
2066moveWindowTo(x: number, y: number): Promise&lt;void&gt;
2067
2068移动窗口位置,使用Promise异步回调。
2069
2070全屏模式窗口不支持该操作。
2071
2072**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2073
2074**参数:**
2075
2076| 参数名 | 类型 | 必填 | 说明 |
2077| -- | ----- | -- | --------------------------------------------- |
2078| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px,该参数仅支持整数输入。 |
2079| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px,该参数仅支持整数输入。 |
2080
2081**返回值:**
2082
2083| 类型 | 说明 |
2084| ------------------- | ------------------------ |
2085| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2086
2087**错误码:**
2088
2089以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2090
2091| 错误码ID | 错误信息 |
2092| ------- | -------------------------------------------- |
2093| 1300002 | This window state is abnormal.               |
2094| 1300003 | This window manager service works abnormally. |
2095
2096**示例:**
2097
2098```ts
2099import { BusinessError } from '@ohos.base';
2100
2101try {
2102  let windowClass: window.Window = window.findWindow("test");
2103  let promise = windowClass.moveWindowTo(300, 300);
2104  promise.then(() => {
2105    console.info('Succeeded in moving the window.');
2106  }).catch((err: BusinessError) => {
2107    console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
2108  });
2109} catch (exception) {
2110  console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
2111}
2112```
2113
2114### resize<sup>9+</sup>
2115
2116resize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void
2117
2118改变当前窗口大小,使用callback异步回调。
2119
2120应用主窗口与子窗口存在大小限制,宽度范围:[320, 2560],高度范围:[240, 2560],单位为vp。
2121
2122系统窗口存在大小限制,宽度范围:[0, 2560],高度范围:[0, 2560],单位为vp。
2123
2124设置的宽度与高度受到此约束限制。
2125
2126全屏模式窗口不支持该操作。
2127
2128**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2129
2130**参数:**
2131
2132| 参数名 | 类型 | 必填 | 说明 |
2133| -------- | ------------------------- | -- | ------------------------ |
2134| width    | number                    | 是 | 目标窗口的宽度,单位为px,该参数仅支持整数输入。 |
2135| height   | number                    | 是 | 目标窗口的高度,单位为px,该参数仅支持整数输入。 |
2136| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。                |
2137
2138**错误码:**
2139
2140以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2141
2142| 错误码ID | 错误信息 |
2143| ------- | -------------------------------------------- |
2144| 1300002 | This window state is abnormal.               |
2145| 1300003 | This window manager service works abnormally. |
2146
2147**示例:**
2148
2149```ts
2150import { BusinessError } from '@ohos.base';
2151
2152try {
2153  let windowClass: window.Window = window.findWindow("test");
2154  windowClass.resize(500, 1000, (err: BusinessError) => {
2155    const errCode: number = err.code;
2156    if (errCode) {
2157      console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
2158      return;
2159    }
2160    console.info('Succeeded in changing the window size.');
2161  });
2162} catch (exception) {
2163  console.error('Failed to change the window size. Cause:' + JSON.stringify(exception));
2164}
2165```
2166
2167### resize<sup>9+</sup>
2168
2169resize(width: number, height: number): Promise&lt;void&gt;
2170
2171改变当前窗口大小,使用Promise异步回调。
2172
2173应用主窗口与子窗口存在大小限制,宽度范围:[320, 2560],高度范围:[240, 2560],单位为vp。
2174
2175系统窗口存在大小限制,宽度范围:[0, 2560],高度范围:[0, 2560],单位为vp。
2176
2177设置的宽度与高度受到此约束限制。
2178
2179全屏模式窗口不支持该操作。
2180
2181**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2182
2183**参数:**
2184
2185| 参数名 | 类型 | 必填 | 说明 |
2186| ------ | ------ | -- | ------------------------ |
2187| width  | number | 是 | 目标窗口的宽度,单位为px,该参数仅支持整数输入。 |
2188| height | number | 是 | 目标窗口的高度,单位为px,该参数仅支持整数输入。 |
2189
2190**返回值:**
2191
2192| 类型 | 说明 |
2193| ------------------- | ------------------------ |
2194| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2195
2196**错误码:**
2197
2198以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2199
2200| 错误码ID | 错误信息 |
2201| ------- | -------------------------------------------- |
2202| 1300002 | This window state is abnormal.               |
2203| 1300003 | This window manager service works abnormally. |
2204
2205**示例:**
2206
2207```ts
2208import { BusinessError } from '@ohos.base';
2209
2210try {
2211  let windowClass: window.Window = window.findWindow("test");
2212  let promise = windowClass.resize(500, 1000);
2213  promise.then(() => {
2214    console.info('Succeeded in changing the window size.');
2215  }).catch((err: BusinessError) => {
2216    console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
2217  });
2218} catch (exception) {
2219  console.error('Failed to change the window size. Cause: ' + JSON.stringify(exception));
2220}
2221```
2222
2223### setWindowMode<sup>9+</sup>
2224
2225setWindowMode(mode: WindowMode, callback: AsyncCallback&lt;void&gt;): void
2226
2227设置窗口模式,使用callback异步回调。
2228
2229**系统接口:** 此接口为系统接口。
2230
2231**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2232
2233**参数:**
2234
2235| 参数名 | 类型 | 必填 | 说明 |
2236| -------- | -------------------------- | -- | --------- |
2237| mode     | [WindowMode](#windowmode7) | 是 | 窗口模式。 |
2238| callback | AsyncCallback&lt;void&gt;  | 是 | 回调函数。 |
2239
2240**错误码:**
2241
2242以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2243
2244| 错误码ID | 错误信息 |
2245| ------- | -------------------------------------------- |
2246| 1300002 | This window state is abnormal.               |
2247| 1300003 | This window manager service works abnormally. |
2248
2249**示例:**
2250
2251```ts
2252import { BusinessError } from '@ohos.base';
2253
2254let mode = window.WindowMode.FULLSCREEN;
2255try {
2256  let windowClass: window.Window = window.findWindow("test");
2257  windowClass.setWindowMode(mode, (err: BusinessError) => {
2258    const errCode: number = err.code;
2259    if (errCode) {
2260      console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err));
2261      return;
2262    }
2263    console.info('Succeeded in setting the window mode.');
2264  });
2265} catch (exception) {
2266  console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
2267}
2268```
2269
2270### setWindowMode<sup>9+</sup>
2271
2272setWindowMode(mode: WindowMode): Promise&lt;void&gt;
2273
2274设置窗口类型,使用Promise异步回调。
2275
2276**系统接口:** 此接口为系统接口。
2277
2278**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2279
2280**参数:**
2281
2282| 参数名 | 类型 | 必填 | 说明 |
2283| -------- | -------------------------- | -- | --------- |
2284| mode     | [WindowMode](#windowmode7) | 是 | 窗口模式。 |
2285
2286**返回值:**
2287
2288| 类型 | 说明 |
2289| ------------------- | ----------------------- |
2290| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2291
2292**错误码:**
2293
2294以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2295
2296| 错误码ID | 错误信息 |
2297| ------- | -------------------------------------------- |
2298| 1300002 | This window state is abnormal.               |
2299| 1300003 | This window manager service works abnormally. |
2300
2301**示例:**
2302
2303```ts
2304import { BusinessError } from '@ohos.base';
2305
2306let mode = window.WindowMode.FULLSCREEN;
2307try {
2308  let windowClass: window.Window = window.findWindow("test");
2309  let promise = windowClass.setWindowMode(mode);
2310  promise.then(() => {
2311    console.info('Succeeded in setting the window mode.');
2312  }).catch((err: BusinessError) => {
2313    console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err));
2314  });
2315} catch (exception) {
2316  console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
2317}
2318```
2319
2320### getWindowProperties<sup>9+</sup>
2321
2322getWindowProperties(): WindowProperties
2323
2324获取当前窗口的属性,返回WindowProperties。
2325
2326**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2327
2328**返回值:**
2329
2330| 类型 | 说明 |
2331| ------------------------------------- | ------------- |
2332| [WindowProperties](#windowproperties) | 当前窗口属性。 |
2333
2334**错误码:**
2335
2336以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2337
2338| 错误码ID | 错误信息 |
2339| ------- | ------------------------------ |
2340| 1300002 | This window state is abnormal. |
2341
2342**示例:**
2343
2344```ts
2345try {
2346  let windowClass: window.Window = window.findWindow("test");
2347  let properties = windowClass.getWindowProperties();
2348} catch (exception) {
2349  console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
2350}
2351```
2352
2353### getWindowAvoidArea<sup>9+</sup>
2354
2355getWindowAvoidArea(type: AvoidAreaType): AvoidArea
2356
2357获取窗口内容规避的区域;如系统栏区域、刘海屏区域、手势区域、软键盘区域等与窗口内容重叠时,需要窗口内容避让的区域。
2358
2359**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2360
2361**参数:**
2362
2363| 参数名 | 类型 | 必填 | 说明 |
2364| ---- |----------------------------------| -- | ------------------------------------------------------------ |
2365| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。 |
2366
2367**返回值:**
2368
2369| 类型 | 说明 |
2370|--------------------------| ----------------- |
2371| [AvoidArea](#avoidarea7) | 窗口内容规避区域。 |
2372
2373**错误码:**
2374
2375以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2376
2377| 错误码ID | 错误信息 |
2378| ------- | ------------------------------ |
2379| 1300002 | This window state is abnormal. |
2380
2381**示例:**
2382
2383```ts
2384let type = window.AvoidAreaType.TYPE_SYSTEM;
2385try {
2386  let windowClass: window.Window = window.findWindow("test");
2387  let avoidArea = windowClass.getWindowAvoidArea(type);
2388} catch (exception) {
2389  console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception));
2390}
2391```
2392
2393### setWindowLayoutFullScreen<sup>9+</sup>
2394
2395setWindowLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void
2396
2397设置窗口的布局是否为沉浸式布局,使用callback异步回调。
2398沉浸式布局是指布局不避让状态栏与导航栏,组件可能产生与其重叠的情况。
2399非沉浸式布局是指布局避让状态栏与导航栏,组件不会与其重叠。
2400
2401**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2402
2403**参数:**
2404
2405| 参数名 | 类型 | 必填 | 说明 |
2406| ------------------ | ------------------------- | -- | --------- |
2407| isLayoutFullScreen | boolean                   | 是 | 窗口的布局是否为沉浸式布局(该沉浸式布局状态栏、导航栏仍然显示)。true表示沉浸式布局;false表示非沉浸式布局。 |
2408| callback           | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
2409
2410**错误码:**
2411
2412以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2413
2414| 错误码ID | 错误信息 |
2415| ------- | -------------------------------------------- |
2416| 1300002 | This window state is abnormal.               |
2417| 1300003 | This window manager service works abnormally. |
2418
2419**示例:**
2420
2421```ts
2422import { BusinessError } from '@ohos.base';
2423
2424let isLayoutFullScreen = true;
2425try {
2426  let windowClass: window.Window = window.findWindow("test");
2427  windowClass.setWindowLayoutFullScreen(isLayoutFullScreen, (err: BusinessError) => {
2428    const errCode: number = err.code;
2429    if (errCode) {
2430      console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
2431      return;
2432    }
2433    console.info('Succeeded in setting the window layout to full-screen mode.');
2434  });
2435} catch (exception) {
2436  console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
2437}
2438```
2439
2440### setWindowLayoutFullScreen<sup>9+</sup>
2441
2442setWindowLayoutFullScreen(isLayoutFullScreen: boolean): Promise&lt;void&gt;
2443
2444设置窗口的布局是否为沉浸式布局,使用Promise异步回调。
2445沉浸式布局是指布局不避让状态栏与导航栏,组件可能产生与其重叠的情况。
2446非沉浸式布局是指布局避让状态栏与导航栏,组件不会与其重叠。
2447
2448**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2449
2450**参数:**
2451
2452| 参数名 | 类型 | 必填 | 说明 |
2453| ------------------ | ------- | -- | ------------------------------------------------------------------------------------------------ |
2454| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为沉浸式布局(该沉浸式布局状态栏、导航栏仍然显示)。true表示沉浸式布局;false表示非沉浸式布局。 |
2455
2456**返回值:**
2457
2458| 类型 | 说明 |
2459| ------------------- | ------------------------ |
2460| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2461
2462**错误码:**
2463
2464以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2465
2466| 错误码ID | 错误信息 |
2467| ------- | -------------------------------------------- |
2468| 1300002 | This window state is abnormal.               |
2469| 1300003 | This window manager service works abnormally. |
2470
2471**示例:**
2472
2473```ts
2474import { BusinessError } from '@ohos.base';
2475
2476let isLayoutFullScreen = true;
2477try {
2478  let windowClass: window.Window = window.findWindow("test");
2479  let promise = windowClass.setWindowLayoutFullScreen(isLayoutFullScreen);
2480  promise.then(() => {
2481    console.info('Succeeded in setting the window layout to full-screen mode.');
2482  }).catch((err: BusinessError) => {
2483    console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
2484  });
2485} catch (exception) {
2486  console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
2487}
2488```
2489
2490### setWindowSystemBarEnable<sup>9+</sup>
2491
2492setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback&lt;void&gt;): void
2493
2494设置窗口全屏模式时导航栏、状态栏的可见模式,使用callback异步回调。
2495
2496**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2497
2498**参数:**
2499
2500| 参数名 | 类型 | 必填 | 说明 |
2501| -------- | ---------------------------- | -- | --------- |
2502| names    | Array<'status'\|'navigation'> | 是 | 设置窗口全屏模式时状态栏和导航栏是否显示。<br>例如,需全部显示,该参数设置为['status',&nbsp;'navigation'];不设置,则默认不显示。 |
2503| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
2504
2505**错误码:**
2506
2507以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2508
2509| 错误码ID | 错误信息 |
2510| ------- | -------------------------------------------- |
2511| 1300002 | This window state is abnormal.               |
2512| 1300003 | This window manager service works abnormally. |
2513
2514**示例:**
2515
2516```ts
2517// 此处以不显示导航栏、状态栏为例
2518import { BusinessError } from '@ohos.base';
2519
2520let names: Array<'status' | 'navigation'> = [];
2521try {
2522  let windowClass: window.Window = window.findWindow("test");
2523  windowClass.setWindowSystemBarEnable(names, (err: BusinessError) => {
2524    const errCode: number = err.code;
2525    if (errCode) {
2526      console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
2527      return;
2528    }
2529    console.info('Succeeded in setting the system bar to be invisible.');
2530  });
2531} catch (exception) {
2532  console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
2533}
2534```
2535
2536### setWindowSystemBarEnable<sup>9+</sup>
2537
2538setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt;
2539
2540设置窗口全屏模式时导航栏、状态栏的可见模式,使用Promise异步回调。
2541
2542**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2543
2544**参数:**
2545
2546| 参数名 | 类型  | 必填 | 说明 |
2547| ----- | ---------------------------- | -- | --------------------------------- |
2548| names | Array<'status'\|'navigation'> | 是 | 设置窗口全屏模式时状态栏和导航栏是否显示。<br>例如,需全部显示,该参数设置为['status',&nbsp;'navigation'];不设置,则默认不显示。 |
2549
2550**返回值:**
2551
2552| 类型 | 说明 |
2553| ------------------- | ------------------------ |
2554| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2555
2556**错误码:**
2557
2558以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2559
2560| 错误码ID | 错误信息 |
2561| ------- | -------------------------------------------- |
2562| 1300002 | This window state is abnormal.               |
2563| 1300003 | This window manager service works abnormally. |
2564
2565**示例:**
2566
2567```ts
2568// 此处以不显示导航栏、状态栏为例
2569import { BusinessError } from '@ohos.base';
2570
2571let names: Array<'status' | 'navigation'> = [];
2572try {
2573  let windowClass: window.Window = window.findWindow("test");
2574  let promise = windowClass.setWindowSystemBarEnable(names);
2575  promise.then(() => {
2576    console.info('Succeeded in setting the system bar to be invisible.');
2577  }).catch((err: BusinessError) => {
2578    console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
2579  });
2580} catch (exception) {
2581  console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
2582}
2583```
2584
2585### setWindowSystemBarProperties<sup>9+</sup>
2586
2587setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback&lt;void&gt;): void
2588
2589设置窗口全屏模式时窗口内导航栏、状态栏的属性,使用callback异步回调。
2590
2591**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2592
2593**参数:**
2594
2595| 参数名              | 类型                                        | 必填 | 说明                   |
2596| ------------------- | ------------------------------------------- | ---- | ---------------------- |
2597| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是   | 导航栏、状态栏的属性。 |
2598| callback            | AsyncCallback&lt;void&gt;                   | 是   | 回调函数。             |
2599
2600**错误码:**
2601
2602以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2603
2604| 错误码ID | 错误信息 |
2605| ------- | -------------------------------------------- |
2606| 1300002 | This window state is abnormal.               |
2607| 1300003 | This window manager service works abnormally. |
2608
2609**示例:**
2610
2611```ts
2612import { BusinessError } from '@ohos.base';
2613
2614let SystemBarProperties: window.SystemBarProperties = {
2615  statusBarColor: '#ff00ff',
2616  navigationBarColor: '#00ff00',
2617  //以下两个属性从API Version8开始支持
2618  statusBarContentColor: '#ffffff',
2619  navigationBarContentColor: '#00ffff'
2620};
2621try {
2622  let windowClass: window.Window = window.findWindow("test");
2623  windowClass.setWindowSystemBarProperties(SystemBarProperties, (err: BusinessError) => {
2624    const errCode: number = err.code;
2625    if (errCode) {
2626      console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
2627      return;
2628    }
2629    console.info('Succeeded in setting the system bar properties.');
2630  });
2631} catch (exception) {
2632  console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
2633}
2634```
2635
2636### setWindowSystemBarProperties<sup>9+</sup>
2637
2638setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise&lt;void&gt;
2639
2640设置窗口全屏模式时窗口内导航栏、状态栏的属性,使用Promise异步回调。
2641
2642**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2643
2644**参数:**
2645
2646| 参数名              | 类型                                        | 必填 | 说明                   |
2647| ------------------- | ------------------------------------------- | ---- | ---------------------- |
2648| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是   | 导航栏、状态栏的属性。 |
2649
2650**返回值:**
2651
2652| 类型                | 说明                      |
2653| ------------------- | ------------------------- |
2654| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2655
2656**错误码:**
2657
2658以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2659
2660| 错误码ID | 错误信息 |
2661| ------- | -------------------------------------------- |
2662| 1300002 | This window state is abnormal.               |
2663| 1300003 | This window manager service works abnormally. |
2664
2665**示例:**
2666
2667```ts
2668import { BusinessError } from '@ohos.base';
2669
2670let SystemBarProperties: window.SystemBarProperties = {
2671  statusBarColor: '#ff00ff',
2672  navigationBarColor: '#00ff00',
2673  //以下两个属性从API Version8开始支持
2674  statusBarContentColor: '#ffffff',
2675  navigationBarContentColor: '#00ffff'
2676};
2677try {
2678  let windowClass: window.Window = window.findWindow("test");
2679  let promise = windowClass.setWindowSystemBarProperties(SystemBarProperties);
2680  promise.then(() => {
2681    console.info('Succeeded in setting the system bar properties.');
2682  }).catch((err: BusinessError) => {
2683    console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
2684  });
2685} catch (exception) {
2686  console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
2687}
2688```
2689
2690### setPreferredOrientation<sup>9+</sup>
2691
2692setPreferredOrientation(orientation: Orientation, callback: AsyncCallback&lt;void&gt;): void
2693
2694设置窗口的显示方向属性,使用callback异步回调。
2695
2696**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2697
2698**参数:**
2699
2700| 参数名              | 类型                                        | 必填 | 说明                   |
2701| ------------------- | ------------------------------------------- | ---- | ---------------------- |
2702| Orientation         | [Orientation](#orientation9)                | 是   | 窗口显示方向的属性。         |
2703| callback            | AsyncCallback&lt;void&gt;                   | 是   | 回调函数。             |
2704
2705**错误码:**
2706
2707以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2708
2709| 错误码ID | 错误信息 |
2710| ------- | ------------------------------ |
2711| 1300002 | This window state is abnormal. |
2712
2713**示例:**
2714
2715```ts
2716import { BusinessError } from '@ohos.base';
2717
2718let orientation = window.Orientation.AUTO_ROTATION;
2719try {
2720  let windowClass: window.Window = window.findWindow("test");
2721  windowClass.setPreferredOrientation(orientation, (err: BusinessError) => {
2722    const errCode: number = err.code;
2723    if (errCode) {
2724      console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err));
2725      return;
2726    }
2727    console.info('Succeeded in setting window orientation.');
2728  });
2729} catch (exception) {
2730  console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception));
2731}
2732```
2733
2734### setPreferredOrientation<sup>9+</sup>
2735
2736setPreferredOrientation(orientation: Orientation): Promise&lt;void&gt;
2737
2738设置窗口的显示方向属性,使用Promise异步回调。
2739
2740**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2741
2742**参数:**
2743
2744| 参数名              | 类型                                        | 必填 | 说明                   |
2745| ------------------- | ------------------------------------------- | ---- | ---------------------- |
2746| Orientation         | [Orientation](#orientation9)                | 是   | 窗口显示方向的属性。       |
2747
2748**返回值:**
2749
2750| 类型                | 说明                      |
2751| ------------------- | ------------------------- |
2752| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2753
2754**错误码:**
2755
2756以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2757
2758| 错误码ID | 错误信息 |
2759| ------- | ------------------------------ |
2760| 1300002 | This window state is abnormal. |
2761
2762**示例:**
2763
2764```ts
2765import { BusinessError } from '@ohos.base';
2766
2767let orientation = window.Orientation.AUTO_ROTATION;
2768try {
2769  let windowClass: window.Window = window.findWindow("test");
2770  let promise = windowClass.setPreferredOrientation(orientation);
2771  promise.then(() => {
2772    console.info('Succeeded in setting the window orientation.');
2773  }).catch((err: BusinessError) => {
2774    console.error('Failed to set the window orientation. Cause: ' + JSON.stringify(err));
2775  });
2776} catch (exception) {
2777  console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception));
2778}
2779```
2780
2781### getUIContext<sup>10+</sup>
2782
2783getUIContext(): UIContext
2784
2785获取UIContext实例。
2786
2787**模型约束:** 此接口仅可在Stage模型下使用。
2788
2789**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2790
2791**返回值:**
2792
2793| 类型       | 说明                   |
2794| ---------- | ---------------------- |
2795| [UIContext](./js-apis-arkui-UIContext.md#uicontext) | 返回UIContext实例对象。 |
2796
2797**错误码:**
2798
2799以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2800
2801| 错误码ID | 错误信息 |
2802| ------- | ------------------------------ |
2803| 1300002 | This window state is abnormal. |
2804
2805**示例:**
2806
2807```ts
2808import UIAbility from '@ohos.app.ability.UIAbility';
2809import window from '@ohos.window';
2810import { BusinessError } from '@ohos.base';
2811import { UIContext } from '@ohos.arkui.UIContext';
2812
2813export default class EntryAbility extends UIAbility {
2814  onWindowStageCreate(windowStage: window.WindowStage) {
2815    // 为主窗口加载对应的目标页面。
2816    windowStage.loadContent("pages/page2", (err: BusinessError) => {
2817      let errCode: number = err.code;
2818      if (errCode) {
2819        console.error('Failed to load the content. Cause:' + JSON.stringify(err));
2820        return;
2821      }
2822      console.info('Succeeded in loading the content.');
2823      // 获取应用主窗口。
2824      let windowClass: window.Window = window.findWindow("test");
2825      windowStage.getMainWindow((err: BusinessError, data) => {
2826        let errCode: number = err.code;
2827        if (errCode) {
2828          console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
2829          return;
2830        }
2831        windowClass = data;
2832        console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
2833        // 获取UIContext实例。
2834        let uiContext: UIContext | null = null;
2835        uiContext = windowClass.getUIContext();
2836      })
2837    });
2838  }
2839};
2840```
2841
2842### setUIContent<sup>9+</sup>
2843
2844setUIContent(path: string, callback: AsyncCallback&lt;void&gt;): void
2845
2846为当前窗口加载具体页面内容,使用callback异步回调。
2847
2848**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2849
2850**参数:**
2851
2852| 参数名 | 类型 | 必填 | 说明 |
2853| -------- | ------------------------- | -- | -------------------- |
2854| path     | string                    | 是 | 设置加载页面的路径。 |
2855| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。          |
2856
2857**错误码:**
2858
2859以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2860
2861| 错误码ID | 错误信息 |
2862| ------- | -------------------------------------------- |
2863| 1300002 | This window state is abnormal.               |
2864| 1300003 | This window manager service works abnormally. |
2865
2866**示例:**
2867
2868```ts
2869import { BusinessError } from '@ohos.base';
2870
2871try {
2872  let windowClass: window.Window = window.findWindow("test");
2873  windowClass.setUIContent('pages/page2/page2', (err: BusinessError) => {
2874    const errCode: number = err.code;
2875    if (errCode) {
2876      console.error('Failed to load the content. Cause:' + JSON.stringify(err));
2877      return;
2878    }
2879    console.info('Succeeded in loading the content.');
2880  });
2881} catch (exception) {
2882  console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
2883}
2884```
2885
2886### setUIContent<sup>9+</sup>
2887
2888setUIContent(path: string): Promise&lt;void&gt;
2889
2890为当前窗口加载具体页面内容,使用Promise异步回调。
2891
2892**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2893
2894**参数:**
2895
2896| 参数名 | 类型 | 必填 | 说明 |
2897| ---- | ------ | -- | ------------------ |
2898| path | string | 是 | 设置加载页面的路径。 |
2899
2900**返回值:**
2901
2902| 类型 | 说明 |
2903| ------------------- | ------------------------ |
2904| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2905
2906**错误码:**
2907
2908以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2909
2910| 错误码ID | 错误信息 |
2911| ------- | -------------------------------------------- |
2912| 1300002 | This window state is abnormal.               |
2913| 1300003 | This window manager service works abnormally. |
2914
2915**示例:**
2916
2917```ts
2918import { BusinessError } from '@ohos.base';
2919
2920try {
2921  let windowClass: window.Window = window.findWindow("test");
2922  let promise = windowClass.setUIContent('pages/page2/page2');
2923  promise.then(() => {
2924    console.info('Succeeded in loading the content.');
2925  }).catch((err: BusinessError) => {
2926    console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
2927  });
2928} catch (exception) {
2929  console.error('Failed to load the content. Cause: ' + JSON.stringify(exception));
2930}
2931```
2932
2933### loadContent<sup>9+</sup>
2934
2935loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void&gt;): void
2936
2937为当前窗口加载与LocalStorage相关联的具体页面内容,使用callback异步回调。
2938
2939**模型约束:** 此接口仅可在Stage模型下使用。
2940
2941**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2942
2943**参数:**
2944
2945| 参数名   | 类型                                            | 必填 | 说明                                                         |
2946| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
2947| path     | string                                          | 是   | 设置加载页面的路径。                                         |
2948| storage  | [LocalStorage](../../quick-start/arkts-localstorage.md) | 是   | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 |
2949| callback | AsyncCallback&lt;void&gt;                       | 是   | 回调函数。                                                   |
2950
2951**错误码:**
2952
2953以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
2954
2955| 错误码ID | 错误信息 |
2956| ------- | -------------------------------------------- |
2957| 1300002 | This window state is abnormal.               |
2958| 1300003 | This window manager service works abnormally. |
2959
2960**示例:**
2961
2962```ts
2963import UIAbility from '@ohos.app.ability.UIAbility';
2964import window from '@ohos.window';
2965import { BusinessError } from '@ohos.base';
2966
2967export default class EntryAbility extends UIAbility {
2968  // ...
2969
2970  onWindowStageCreate(windowStage: window.WindowStage) {
2971    console.log('onWindowStageCreate');
2972    let windowClass: window.Window = window.findWindow("test");
2973    let storage: LocalStorage = new LocalStorage();
2974    storage.setOrCreate('storageSimpleProp', 121);
2975    try {
2976      if (!windowClass) {
2977        console.info('Failed to load the content. Cause: windowClass is null');
2978      }
2979      else {
2980        (windowClass as window.Window).loadContent('pages/page2', storage, (err: BusinessError) => {
2981          const errCode: number = err.code;
2982          if (errCode) {
2983            console.error('Failed to load the content. Cause:' + JSON.stringify(err));
2984            return;
2985          }
2986          console.info('Succeeded in loading the content.');
2987        });
2988      }
2989    } catch (exception) {
2990      console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
2991    }
2992  }
2993};
2994```
2995
2996### loadContent<sup>9+</sup>
2997
2998loadContent(path: string, storage: LocalStorage): Promise&lt;void&gt;
2999
3000为当前窗口加载与LocalStorage相关联的具体页面内容,使用Promise异步回调。
3001
3002**模型约束:** 此接口仅可在Stage模型下使用。
3003
3004**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3005
3006**参数:**
3007
3008| 参数名  | 类型                                            | 必填 | 说明                                                         |
3009| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
3010| path    | string                                          | 是   | 设置加载页面的路径。                                         |
3011| storage | [LocalStorage](../../quick-start/arkts-localstorage.md) | 是   | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 |
3012
3013**返回值:**
3014
3015| 类型                | 说明                      |
3016| ------------------- | ------------------------- |
3017| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
3018
3019**错误码:**
3020
3021以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
3022
3023| 错误码ID | 错误信息 |
3024| ------- | -------------------------------------------- |
3025| 1300002 | This window state is abnormal.               |
3026| 1300003 | This window manager service works abnormally. |
3027
3028**示例:**
3029
3030```ts
3031import UIAbility from '@ohos.app.ability.UIAbility';
3032import window from '@ohos.window';
3033import { BusinessError } from '@ohos.base';
3034
3035export default class EntryAbility extends UIAbility {
3036  // ...
3037
3038  onWindowStageCreate(windowStage: window.WindowStage) {
3039    console.log('onWindowStageCreate');
3040    let windowClass: window.Window = window.findWindow("test");
3041    let storage: LocalStorage = new LocalStorage();
3042    storage.setOrCreate('storageSimpleProp', 121);
3043    try {
3044      if (!windowClass) {
3045        console.info('Failed to load the content. Cause: windowClass is null');
3046      }
3047      else {
3048        let promise = (windowClass as window.Window).loadContent('pages/page2', storage);
3049        promise.then(() => {
3050          console.info('Succeeded in loading the content.');
3051        }).catch((err: BusinessError) => {
3052          console.error('Failed to load the content. Cause:' + JSON.stringify(err));
3053        });
3054      }
3055    } catch (exception) {
3056      console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
3057    }
3058  }
3059};
3060```
3061
3062### isWindowShowing<sup>9+</sup>
3063
3064isWindowShowing(): boolean
3065
3066判断当前窗口是否已显示。
3067
3068**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3069
3070**返回值:**
3071
3072| 类型 | 说明 |
3073| ------- | ------------------------------------------------------------------ |
3074| boolean | 当前窗口是否已显示。true表示当前窗口已显示,false则表示当前窗口未显示。 |
3075
3076**错误码:**
3077
3078以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
3079
3080| 错误码ID | 错误信息 |
3081| ------- | ------------------------------ |
3082| 1300002 | This window state is abnormal. |
3083
3084**示例:**
3085
3086```ts
3087try {
3088  let windowClass: window.Window = window.findWindow("test");
3089  let data = windowClass.isWindowShowing();
3090  console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
3091} catch (exception) {
3092  console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception));
3093}
3094```
3095
3096### on('windowSizeChange')<sup>7+</sup>
3097
3098on(type:  'windowSizeChange', callback: Callback&lt;Size&gt;): void
3099
3100开启窗口尺寸变化的监听。
3101
3102**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3103
3104**参数:**
3105
3106| 参数名   | 类型                           | 必填 | 说明                                                     |
3107| -------- | ------------------------------ | ---- | -------------------------------------------------------- |
3108| type     | string                         | 是   | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 |
3109| callback | Callback&lt;[Size](#size7)&gt; | 是   | 回调函数。返回当前的窗口尺寸。                           |
3110
3111**示例:**
3112
3113```ts
3114try {
3115  let windowClass: window.Window = window.findWindow("test");
3116  windowClass.on('windowSizeChange', (data) => {
3117    console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data));
3118  });
3119} catch (exception) {
3120  console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception));
3121}
3122```
3123
3124### off('windowSizeChange')<sup>7+</sup>
3125
3126off(type: 'windowSizeChange', callback?: Callback&lt;Size&gt;): void
3127
3128关闭窗口尺寸变化的监听。
3129
3130**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3131
3132**参数:**
3133
3134| 参数名   | 类型                          | 必填 | 说明                                                     |
3135| -------- | ----------------------------- | ---- | -------------------------------------------------------- |
3136| type     | string                        | 是   | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 |
3137| callback | Callback&lt;[Size](#size7)&gt; | 否   | 回调函数。返回当前的窗口尺寸。如果传入参数,则关闭该监听。如果未传入参数,则关闭窗口尺寸变化的监听。                           |
3138
3139**示例:**
3140
3141```ts
3142try {
3143  let windowClass: window.Window = window.findWindow("test");
3144  windowClass.off('windowSizeChange');
3145} catch (exception) {
3146  console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception));
3147}
3148```
3149
3150### on('avoidAreaChange')<sup>9+</sup>
3151
3152on(type: 'avoidAreaChange', callback: Callback&lt;{ type: AvoidAreaType, area: AvoidArea}&gt;): void
3153
3154开启系统规避区变化的监听。
3155
3156**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3157
3158**参数:**
3159
3160| 参数名   | 类型                                                               | 必填 | 说明                                   |
3161| -------- |------------------------------------------------------------------| ---- |--------------------------------------|
3162| type     | string                                                           | 是   | 监听事件,固定为'avoidAreaChange',即系统规避区变化事件。 |
3163| callback | Callback&lt;{ type: [AvoidAreaType](#avoidareatype7), area: [AvoidArea](#avoidarea7) }&gt; | 是   | 回调函数。返回当前规避区以及规避区类型。|
3164
3165**示例:**
3166
3167```ts
3168try {
3169  let windowClass: window.Window = window.findWindow("test");
3170  windowClass.on('avoidAreaChange', (data) => {
3171    console.info('Succeeded in enabling the listener for system avoid area changes. type:' +
3172    JSON.stringify(data.type) + ', area: ' + JSON.stringify(data.area));
3173  });
3174} catch (exception) {
3175  console.error('Failed to enable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
3176}
3177```
3178
3179### off('avoidAreaChange')<sup>9+</sup>
3180
3181off(type: 'avoidAreaChange', callback?: Callback&lt;{ type: AvoidAreaType, area: AvoidArea }&gt;): void
3182
3183关闭系统规避区变化的监听。
3184
3185**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3186
3187**参数:**
3188
3189| 参数名   | 类型                                                                          | 必填  | 说明                                 |
3190| -------- |-----------------------------------------------------------------------------|-----|------------------------------------|
3191| type     | string                                                                      | 是   | 监听事件,固定为'avoidAreaChange',即系统规避区变化事件。 |
3192| callback | Callback&lt;{ type: [AvoidAreaType](#avoidareatype7), area: [AvoidArea](#avoidarea7) }&gt; | 否   | 回调函数。返回当前规避区以及规避区类型。如果传入参数,则关闭该监听。如果未传入参数,则关闭所有系统规避区变化的监听。|
3193
3194**示例:**
3195
3196```ts
3197try {
3198  let windowClass: window.Window = window.findWindow("test");
3199  windowClass.off('avoidAreaChange');
3200} catch (exception) {
3201  console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
3202}
3203```
3204
3205### on('keyboardHeightChange')<sup>7+</sup>
3206
3207on(type: 'keyboardHeightChange', callback: Callback&lt;number&gt;): void
3208
3209开启固定态输入法窗口软键盘高度变化的监听。从API version 10开始,改变输入法窗口为固定态或者悬浮态方法详细介绍请参见[输入法服务](js-apis-inputmethodengine.md#changeflag10)。
3210
3211**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3212
3213**参数:**
3214
3215| 参数名   | 类型                | 必填 | 说明                                        |
3216| -------- | ------------------- | ---- |-------------------------------------------|
3217| type     | string              | 是   | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 |
3218| callback | Callback&lt;number&gt; | 是   | 回调函数。返回当前的键盘高度,返回值为整数。                    |
3219
3220**示例:**
3221
3222```ts
3223try {
3224  let windowClass: window.Window = window.findWindow("test");
3225  windowClass.on('keyboardHeightChange', (data) => {
3226    console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
3227  });
3228} catch (exception) {
3229  console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
3230}
3231```
3232
3233### off('keyboardHeightChange')<sup>7+</sup>
3234
3235off(type: 'keyboardHeightChange', callback?: Callback&lt;number&gt;): void
3236
3237关闭固定态输入法窗口软键盘高度变化的监听。从API version 10开始,改变输入法窗口为固定态或者悬浮态方法详细介绍请参见[输入法服务](js-apis-inputmethodengine.md#changeflag10)。
3238
3239**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3240
3241**参数:**
3242
3243| 参数名   | 类型                   | 必填 | 说明                                                         |
3244| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
3245| type     | string                 | 是   | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 |
3246| callback | Callback&lt;number&gt; | 否   | 回调函数。返回当前的键盘高度,返回值为整数。若传入参数,则关闭该监听。如果未传入参数,则关闭所有固定态输入法窗口软键盘高度变化的监听。                               |
3247
3248**示例:**
3249
3250```ts
3251try {
3252  let windowClass: window.Window = window.findWindow("test");
3253  windowClass.off('keyboardHeightChange');
3254} catch (exception) {
3255  console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
3256}
3257```
3258
3259### on('touchOutside')<sup>9+</sup>
3260
3261on(type: 'touchOutside', callback: Callback&lt;void&gt;): void
3262
3263开启本窗口区域范围外的点击事件的监听。
3264
3265**系统接口:** 此接口为系统接口。
3266
3267**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3268
3269**参数:**
3270
3271| 参数名   | 类型                | 必填 | 说明                                                         |
3272| -------- | ------------------- | ---- | ------------------------------------------------------------ |
3273| type     | string              | 是   | 监听事件,固定为'touchOutside',即本窗口范围外的点击事件。 |
3274| callback | Callback&lt;void&gt; | 是   | 回调函数。当点击事件发生在本窗口范围之外的回调。                               |
3275
3276**示例:**
3277
3278```ts
3279try {
3280  let windowClass: window.Window = window.findWindow("test");
3281  windowClass.on('touchOutside', () => {
3282    console.info('touch outside');
3283  });
3284} catch (exception) {
3285  console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
3286}
3287```
3288
3289### off('touchOutside')<sup>9+</sup>
3290
3291off(type: 'touchOutside', callback?: Callback&lt;void&gt;): void
3292
3293关闭本窗口区域范围外的点击事件的监听。
3294
3295**系统接口:** 此接口为系统接口。
3296
3297**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3298
3299**参数:**
3300
3301| 参数名   | 类型                   | 必填 | 说明                                   |
3302| -------- |----------------------| ---- |--------------------------------------|
3303| type     | string               | 是   | 监听事件,固定为'touchOutside',即本窗口范围外的点击事件。 |
3304| callback | Callback&lt;void&gt; | 否   | 回调函数。当点击事件发生在本窗口范围之外的回调。如果传入参数,则关闭该监听。如果未传入参数,则关闭所有本窗口区域范围外的点击事件的监听。            |
3305
3306**示例:**
3307
3308```ts
3309try {
3310  let windowClass: window.Window = window.findWindow("test");
3311  windowClass.off('touchOutside');
3312} catch (exception) {
3313  console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
3314}
3315```
3316
3317### on('screenshot')<sup>9+</sup>
3318
3319on(type: 'screenshot', callback: Callback&lt;void&gt;): void
3320
3321开启截屏事件的监听。
3322
3323**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3324
3325**参数:**
3326
3327| 参数名   | 类型                | 必填 | 说明                                                         |
3328| -------- | ------------------- | ---- | ------------------------------------------------------------ |
3329| type     | string              | 是   | 监听事件,固定为'screenshot',即截屏事件。 |
3330| callback | Callback&lt;void&gt; | 是   | 回调函数。发生截屏事件时的回调。                               |
3331
3332**示例:**
3333
3334```ts
3335try {
3336  let windowClass: window.Window = window.findWindow("test");
3337  windowClass.on('screenshot', () => {
3338    console.info('screenshot happened');
3339  });
3340} catch (exception) {
3341  console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
3342}
3343```
3344
3345### off('screenshot')<sup>9+</sup>
3346
3347off(type: 'screenshot', callback?: Callback&lt;void&gt;): void
3348
3349关闭截屏事件的监听。
3350
3351**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3352
3353**参数:**
3354
3355| 参数名   | 类型                   | 必填 | 说明                                                         |
3356| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
3357| type     | string                 | 是   | 监听事件,固定为'screenshot',即截屏事件。 |
3358| callback | Callback&lt;void&gt; | 否   | 回调函数。发生截屏事件时的回调。若传入参数,则关闭该监听。若未传入参数,则关闭所有截屏事件的监听。 |
3359
3360**示例:**
3361
3362```ts
3363let windowClass: window.Window = window.findWindow("test");
3364let callback = () => {
3365  console.info('screenshot happened');
3366};
3367try {
3368  windowClass.on('screenshot', callback);
3369} catch (exception) {
3370  console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
3371}
3372try {
3373  windowClass.off('screenshot', callback);
3374  // 如果通过on开启多个callback进行监听,同时关闭所有监听:
3375  windowClass.off('screenshot');
3376} catch (exception) {
3377  console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
3378}
3379```
3380
3381### on('dialogTargetTouch')<sup>10+</sup>
3382
3383on(type: 'dialogTargetTouch', callback: Callback&lt;void&gt;): void
3384
3385开启模态窗口目标窗口的点击事件的监听。
3386
3387**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3388
3389**参数:**
3390
3391| 参数名   | 类型                 | 必填 | 说明                                                          |
3392| -------- | ------------------- | ---- | ------------------------------------------------------------ |
3393| type     | string              | 是   | 监听事件,固定为'dialogTargetTouch',即模态窗口目标窗口的点击事件。 |
3394| callback | Callback&lt;void&gt;| 是   | 回调函数。当点击事件发生在模态窗口目标窗口的回调。 |
3395
3396**示例:**
3397
3398```ts
3399let windowClass: window.Window = window.findWindow("test");
3400try {
3401  windowClass.on('dialogTargetTouch', () => {
3402    console.info('touch dialog target');
3403  });
3404} catch (exception) {
3405  console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
3406}
3407```
3408
3409### off('dialogTargetTouch')<sup>10+</sup>
3410
3411off(type: 'dialogTargetTouch', callback?: Callback&lt;void&gt;): void
3412
3413关闭模态窗口目标窗口的点击事件的监听。
3414
3415**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3416
3417**参数:**
3418
3419| 参数名   | 类型                    | 必填 | 说明                                                          |
3420| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
3421| type     | string                 | 是   | 监听事件,固定为'dialogTargetTouch',即模态窗口目标窗口的点击事件。 |
3422| callback | Callback&lt;void&gt;      | 否   | 回调函数。当点击事件发生在模态窗口目标窗口的回调。若传入参数,则关闭该监听。若未传入参数,则关闭所有模态窗口目标窗口的点击事件的监听。 |
3423
3424**示例:**
3425
3426```ts
3427let windowClass: window.Window = window.findWindow("test");
3428try {
3429  windowClass.off('dialogTargetTouch');
3430} catch (exception) {
3431  console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
3432}
3433```
3434
3435### on('windowEvent')<sup>10+</sup>
3436
3437on(type: 'windowEvent', callback: Callback&lt;WindowEventType&gt;): void
3438
3439开启窗口生命周期变化的监听。
3440
3441**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3442
3443**参数:**
3444
3445| 参数名   | 类型                                                       | 必填 | 说明                                                         |
3446| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
3447| type     | string                                                     | 是   | 监听事件,固定为'windowEvent',即窗口生命周期变化事件。 |
3448| callback | Callback&lt;[WindowEventType](#windoweventtype10)&gt; | 是   | 回调函数。返回当前的窗口生命周期状态。                 |
3449
3450**示例:**
3451
3452```ts
3453let windowClass: window.Window = window.findWindow("test");
3454try {
3455  windowClass.on('windowEvent', (data) => {
3456    console.info('Window event happened. Event:' + JSON.stringify(data));
3457  });
3458} catch (exception) {
3459  console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
3460}
3461```
3462
3463### off('windowEvent')<sup>10+</sup>
3464
3465off(type: 'windowEvent', callback?: Callback&lt;WindowEventType &gt;): void
3466
3467关闭窗口生命周期变化的监听。
3468
3469**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3470
3471**参数:**
3472
3473| 参数名   | 类型                                                       | 必填 | 说明                                                         |
3474| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
3475| type     | string                                                     | 是   | 监听事件,固定为'windowEvent',即窗口生命周期变化事件。 |
3476| callback | Callback&lt;[WindowEventType](#windoweventtype10)&gt; | 否   | 回调函数。返回当前的窗口生命周期状态。若传入参数,则关闭该监听。若未传入参数,则关闭所有窗口生命周期变化的监听。                 |
3477
3478**示例:**
3479
3480```ts
3481let windowClass: window.Window = window.findWindow("test");
3482try {
3483  windowClass.off('windowEvent');
3484} catch (exception) {
3485  console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
3486}
3487```
3488
3489### bindDialogTarget<sup>9+</sup>
3490
3491bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;, callback: AsyncCallback&lt;void&gt;): void
3492
3493绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用callback异步回调。
3494
3495**系统接口:** 此接口为系统接口。
3496
3497**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3498
3499**参数:**
3500
3501| 参数名       | 类型                      | 必填 | 说明                  |
3502| ----------- | ------------------------- | ---- | -------------------- |
3503| token       | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是   | 目标窗口token值。 |
3504| deathCallback | Callback&lt;void&gt;        | 是   | 模态窗口销毁监听。 |
3505| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
3506
3507**错误码:**
3508
3509以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
3510
3511| 错误码ID | 错误信息 |
3512| ------- | -------------------------------------------- |
3513| 1300002 | This window state is abnormal.               |
3514| 1300003 | This window manager service works abnormally. |
3515
3516**示例:**
3517
3518```ts
3519import rpc from '@ohos.rpc';
3520import { BusinessError } from '@ohos.base';
3521
3522class MyDeathRecipient {
3523  onRemoteDied() {
3524    console.log('server died');
3525  }
3526}
3527
3528class TestRemoteObject extends rpc.RemoteObject {
3529  constructor(descriptor: string) {
3530    super(descriptor);
3531  }
3532
3533  addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
3534    return true;
3535  }
3536
3537  removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
3538    return true;
3539  }
3540
3541  isObjectDead(): boolean {
3542    return false;
3543  }
3544}
3545
3546let token: TestRemoteObject = new TestRemoteObject('testObject');
3547let windowClass: window.Window = window.findWindow("test");
3548let config: window.Configuration = { name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG };
3549try {
3550  window.createWindow(config, (err: BusinessError, data) => {
3551    let errCode: number = err.code;
3552    if (errCode) {
3553      console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
3554      return;
3555    }
3556    windowClass = data;
3557  });
3558  windowClass.bindDialogTarget(token, () => {
3559    console.info('Dialog Window Need Destroy.');
3560  }, (err: BusinessError) => {
3561    let errCode: number = err.code;
3562    if (errCode) {
3563      console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
3564      return;
3565    }
3566    console.info('Succeeded in binding dialog target.');
3567  });
3568} catch (exception) {
3569  console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
3570}
3571```
3572
3573### bindDialogTarget<sup>9+</sup>
3574
3575bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;): Promise&lt;void&gt;
3576
3577绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用Promise异步回调。
3578
3579**系统接口:** 此接口为系统接口。
3580
3581**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3582
3583**参数:**
3584
3585| 参数名       | 类型                      | 必填 | 说明                  |
3586| ----------- | ------------------------- | ---- | -------------------- |
3587| token       | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是   | 目标窗口token值。 |
3588| deathCallback | Callback&lt;void&gt;        | 是   | 模态窗口销毁监听。 |
3589
3590**返回值:**
3591
3592| 类型                | 说明                      |
3593| ------------------- | ------------------------- |
3594| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
3595
3596**错误码:**
3597
3598以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
3599
3600| 错误码ID | 错误信息 |
3601| ------- | -------------------------------------------- |
3602| 1300002 | This window state is abnormal.               |
3603| 1300003 | This window manager service works abnormally. |
3604
3605**示例:**
3606
3607```ts
3608import rpc from '@ohos.rpc';
3609import { BusinessError } from '@ohos.base';
3610
3611class MyDeathRecipient {
3612  onRemoteDied() {
3613    console.log('server died');
3614  }
3615}
3616
3617class TestRemoteObject extends rpc.RemoteObject {
3618  constructor(descriptor: string) {
3619    super(descriptor);
3620  }
3621
3622  addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
3623    return true;
3624  }
3625
3626  removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
3627    return true;
3628  }
3629
3630  isObjectDead(): boolean {
3631    return false;
3632  }
3633}
3634
3635let token: TestRemoteObject = new TestRemoteObject('testObject');
3636let windowClass: window.Window = window.findWindow("test");
3637let config: window.Configuration = {
3638  name: "dialogWindow",
3639  windowType: window.WindowType.TYPE_DIALOG
3640};
3641try {
3642  window.createWindow(config, (err: BusinessError, data) => {
3643    const errCode: number = err.code;
3644    if (errCode) {
3645      console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
3646      return;
3647    }
3648    windowClass = data;
3649  });
3650  let promise = windowClass.bindDialogTarget(token, () => {
3651    console.info('Dialog Window Need Destroy.');
3652  });
3653  promise.then(() => {
3654    console.info('Succeeded in binding dialog target.');
3655  }).catch((err: BusinessError) => {
3656    console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
3657  });
3658} catch (exception) {
3659  console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
3660}
3661```
3662
3663### bindDialogTarget<sup>9+</sup>
3664
3665bindDialogTarget(requestInfo: dialogRequest.RequestInfo, deathCallback: Callback&lt;void&gt;, callback: AsyncCallback&lt;void&gt;): void
3666
3667绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用callback异步回调。
3668
3669**系统接口:** 此接口为系统接口。
3670
3671**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3672
3673**参数:**
3674
3675| 参数名       | 类型                      | 必填 | 说明                  |
3676| ----------- | ------------------------- | ---- | -------------------- |
3677| requestInfo | [dialogRequest.RequestInfo](js-apis-app-ability-dialogRequest.md#requestinfo) | 是   | 目标窗口RequestInfo值。 |
3678| deathCallback | Callback&lt;void&gt;    | 是   | 模态窗口销毁监听。 |
3679| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
3680
3681**错误码:**
3682
3683以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
3684
3685| 错误码ID | 错误信息 |
3686| ------- | -------------------------------------------- |
3687| 1300002 | This window state is abnormal.               |
3688| 1300003 | This window manager service works abnormally. |
3689
3690**示例:**
3691
3692```ts
3693import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
3694import dialogRequest from '@ohos.app.ability.dialogRequest';
3695import Want from '@ohos.app.ability.Want';
3696import { BusinessError } from '@ohos.base';
3697
3698export default class ServiceExtAbility extends ServiceExtensionAbility {
3699  onRequest(want: Want, startId: number) {
3700    console.info('onRequest');
3701    let windowClass: window.Window = window.findWindow("test");
3702    let config: window.Configuration = {
3703      name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG
3704    };
3705    try {
3706      window.createWindow(config, (err: BusinessError, data) => {
3707        let errCode: number = err.code;
3708        if (errCode) {
3709          console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
3710          return;
3711        }
3712        windowClass = data;
3713      });
3714      let requestInfo = dialogRequest.getRequestInfo(want)
3715      windowClass.bindDialogTarget(requestInfo, () => {
3716        console.info('Dialog Window Need Destroy.');
3717      }, (err: BusinessError) => {
3718        let errCode: number = err.code;
3719        if (errCode) {
3720          console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
3721          return;
3722        }
3723        console.info('Succeeded in binding dialog target.');
3724      });
3725    } catch (err) {
3726      console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err))
3727    }
3728  }
3729}
3730```
3731
3732### bindDialogTarget<sup>9+</sup>
3733
3734bindDialogTarget(requestInfo: dialogRequest.RequestInfo, deathCallback: Callback&lt;void&gt;): Promise&lt;void&gt;
3735
3736绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用Promise异步回调。
3737
3738**系统接口:** 此接口为系统接口。
3739
3740**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3741
3742**参数:**
3743
3744| 参数名       | 类型                      | 必填 | 说明                  |
3745| ----------- | ------------------------- | ---- | -------------------- |
3746| requestInfo | [dialogRequest.RequestInfo](js-apis-app-ability-dialogRequest.md#requestinfo) | 是   | 目标窗口RequestInfo值。 |
3747| deathCallback | Callback&lt;void&gt;    | 是   | 模态窗口销毁监听。 |
3748
3749**返回值:**
3750
3751| 类型                | 说明                      |
3752| ------------------- | ------------------------- |
3753| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
3754
3755**错误码:**
3756
3757以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
3758
3759| 错误码ID | 错误信息 |
3760| ------- | -------------------------------------------- |
3761| 1300002 | This window state is abnormal.               |
3762| 1300003 | This window manager service works abnormally. |
3763
3764**示例:**
3765
3766```ts
3767import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
3768import dialogRequest from '@ohos.app.ability.dialogRequest';
3769import Want from '@ohos.app.ability.Want';
3770import { BusinessError } from '@ohos.base';
3771
3772export default class ServiceExtAbility extends ServiceExtensionAbility {
3773  onRequest(want: Want, startId: number) {
3774    console.info('onRequest');
3775    let windowClass: window.Window = window.findWindow("test");
3776    let config: window.Configuration = {
3777      name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG
3778    };
3779    try {
3780      window.createWindow(config, (err: BusinessError, data) => {
3781        const errCode: number = err.code;
3782        if (errCode) {
3783          console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
3784          return;
3785        }
3786        windowClass = data;
3787      });
3788      let requestInfo = dialogRequest.getRequestInfo(want)
3789      let promise = windowClass.bindDialogTarget(requestInfo, () => {
3790        console.info('Dialog Window Need Destroy.');
3791      });
3792      promise.then(() => {
3793        console.info('Succeeded in binding dialog target.');
3794      }).catch((err: BusinessError) => {
3795        console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
3796      });
3797    } catch (err) {
3798      console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err))
3799    }
3800  }
3801}
3802```
3803
3804### isWindowSupportWideGamut<sup>9+</sup>
3805
3806isWindowSupportWideGamut(callback: AsyncCallback&lt;boolean&gt;): void
3807
3808判断当前窗口是否支持广色域模式,使用callback异步回调。
3809
3810**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3811
3812**参数:**
3813
3814| 参数名 | 类型 | 必填 | 说明 |
3815| -------- | ---------------------------- | -- | -------------------------------------------------------------------------------- |
3816| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。返回true表示当前窗口支持广色域模式,返回false表示当前窗口不支持广色域模式。 |
3817
3818**错误码:**
3819
3820以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
3821
3822| 错误码ID | 错误信息 |
3823| ------- | ------------------------------ |
3824| 1300002 | This window state is abnormal. |
3825
3826**示例:**
3827
3828```ts
3829import { BusinessError } from '@ohos.base';
3830
3831let windowClass: window.Window = window.findWindow("test");
3832windowClass.isWindowSupportWideGamut((err: BusinessError, data) => {
3833  const errCode: number = err.code;
3834  if (errCode) {
3835    console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err));
3836    return;
3837  }
3838  console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
3839});
3840```
3841
3842### isWindowSupportWideGamut<sup>9+</sup>
3843
3844isWindowSupportWideGamut(): Promise&lt;boolean&gt;
3845
3846判断当前窗口是否支持广色域模式,使用Promise异步回调。
3847
3848**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3849
3850**返回值:**
3851
3852| 类型 | 说明 |
3853| ---------------------- | ------------------------------------------------------------------------------------ |
3854| Promise&lt;boolean&gt; | Promise对象。返回true表示当前窗口支持广色域模式,返回false表示当前窗口不支持广色域模式。 |
3855
3856**错误码:**
3857
3858以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
3859
3860| 错误码ID | 错误信息 |
3861| ------- | ------------------------------ |
3862| 1300002 | This window state is abnormal. |
3863
3864**示例:**
3865
3866```ts
3867import { BusinessError } from '@ohos.base';
3868
3869let windowClass: window.Window = window.findWindow("test");
3870let promise = windowClass.isWindowSupportWideGamut();
3871promise.then((data) => {
3872  console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
3873}).catch((err: BusinessError) => {
3874  console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
3875});
3876```
3877
3878### setWindowColorSpace<sup>9+</sup>
3879
3880setWindowColorSpace(colorSpace:ColorSpace, callback: AsyncCallback&lt;void&gt;): void
3881
3882设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。
3883
3884**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3885
3886**参数:**
3887
3888| 参数名 | 类型 | 必填 | 说明 |
3889| ---------- | ------------------------- | -- | ----------- |
3890| colorSpace | [ColorSpace](#colorspace8) | 是 | 设置色域模式。 |
3891| callback   | AsyncCallback&lt;void&gt; | 是 | 回调函数。   |
3892
3893**错误码:**
3894
3895以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
3896
3897| 错误码ID | 错误信息 |
3898| ------- | ------------------------------ |
3899| 1300002 | This window state is abnormal. |
3900
3901**示例:**
3902
3903```ts
3904import { BusinessError } from '@ohos.base';
3905
3906let windowClass: window.Window = window.findWindow("test");
3907try {
3908  windowClass.setWindowColorSpace(window.ColorSpace.WIDE_GAMUT, (err: BusinessError) => {
3909    const errCode: number = err.code;
3910    if (errCode) {
3911      console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err));
3912      return;
3913    }
3914    console.info('Succeeded in setting window colorspace.');
3915  });
3916} catch (exception) {
3917  console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
3918}
3919```
3920
3921### setWindowColorSpace<sup>9+</sup>
3922
3923setWindowColorSpace(colorSpace:ColorSpace): Promise&lt;void&gt;
3924
3925设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。
3926
3927**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3928
3929**参数:**
3930
3931| 参数名 | 类型 | 必填 | 说明 |
3932| ---------- | ------------------------- | -- | ------------- |
3933| colorSpace | [ColorSpace](#colorspace8) | 是 | 设置色域模式。 |
3934
3935**返回值:**
3936
3937| 类型 | 说明 |
3938| ------------------- | ------------------------ |
3939| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
3940
3941**错误码:**
3942
3943以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
3944
3945| 错误码ID | 错误信息 |
3946| ------- | ------------------------------ |
3947| 1300002 | This window state is abnormal. |
3948
3949**示例:**
3950
3951```ts
3952import { BusinessError } from '@ohos.base';
3953
3954let windowClass: window.Window = window.findWindow("test");
3955try {
3956  let promise = windowClass.setWindowColorSpace(window.ColorSpace.WIDE_GAMUT);
3957  promise.then(() => {
3958    console.info('Succeeded in setting window colorspace.');
3959  }).catch((err: BusinessError) => {
3960    console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
3961  });
3962} catch (exception) {
3963  console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
3964}
3965```
3966
3967### getWindowColorSpace<sup>9+</sup>
3968
3969getWindowColorSpace(): ColorSpace
3970
3971获取当前窗口色域模式。
3972
3973**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3974
3975**返回值:**
3976
3977| 类型 | 说明 |
3978| ------------------------- | ------------- |
3979| [ColorSpace](#colorspace8) | 当前色域模式。 |
3980
3981**错误码:**
3982
3983以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
3984
3985| 错误码ID | 错误信息 |
3986| ------- | ------------------------------ |
3987| 1300002 | This window state is abnormal. |
3988
3989**示例:**
3990
3991```ts
3992let colorSpace = windowClass.getWindowColorSpace();
3993```
3994
3995### setWindowBackgroundColor<sup>9+</sup>
3996
3997setWindowBackgroundColor(color: string): void
3998
3999设置窗口的背景色。Stage模型下,该接口需要在[loadContent()](#loadcontent9)或[setUIContent()](#setuicontent9)调用生效后使用。
4000
4001**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4002
4003**参数:**
4004
4005| 参数名 | 类型 | 必填 | 说明 |
4006| ----- | ------ | -- | ----------------------------------------------------------------------- |
4007| color | string | 是 | 需要设置的背景色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 |
4008
4009**错误码:**
4010
4011以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4012
4013| 错误码ID | 错误信息 |
4014| ------- | ------------------------------ |
4015| 1300002 | This window state is abnormal. |
4016
4017**示例:**
4018
4019```ts
4020let color: string = '#00ff33';
4021let windowClass: window.Window = window.findWindow("test");
4022try {
4023  windowClass.setWindowBackgroundColor(color);
4024} catch (exception) {
4025  console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception));
4026}
4027```
4028
4029### setWindowBrightness<sup>9+</sup>
4030
4031setWindowBrightness(brightness: number, callback: AsyncCallback&lt;void&gt;): void
4032
4033设置屏幕亮度值,使用callback异步回调。
4034
4035当前屏幕亮度规格:窗口设置屏幕亮度生效时,控制中心不可以调整系统屏幕亮度,窗口恢复默认系统亮度之后,控制中心可以调整系统屏幕亮度。
4036
4037**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4038
4039**参数:**
4040
4041| 参数名 | 类型 | 必填 | 说明                                        |
4042| ---------- | ------------------------- | -- |-------------------------------------------|
4043| brightness | number                    | 是 | 屏幕亮度值。该参数为浮点数,取值范围为[0.0, 1.0]或-1.0。1.0表示最亮,-1.0表示默认亮度。 |
4044| callback   | AsyncCallback&lt;void&gt; | 是 | 回调函数。                                     |
4045
4046**错误码:**
4047
4048以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4049
4050| 错误码ID | 错误信息 |
4051| ------- | -------------------------------------------- |
4052| 1300002 | This window state is abnormal.               |
4053| 1300003 | This window manager service works abnormally. |
4054
4055**示例:**
4056
4057```ts
4058import { BusinessError } from '@ohos.base';
4059
4060let brightness: number = 1;
4061let windowClass: window.Window = window.findWindow("test");
4062try {
4063  windowClass.setWindowBrightness(brightness, (err: BusinessError) => {
4064    const errCode: number = err.code;
4065    if (errCode) {
4066      console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
4067      return;
4068    }
4069    console.info('Succeeded in setting the brightness.');
4070  });
4071} catch (exception) {
4072  console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
4073}
4074```
4075
4076### setWindowBrightness<sup>9+</sup>
4077
4078setWindowBrightness(brightness: number): Promise&lt;void&gt;
4079
4080设置屏幕亮度值,使用Promise异步回调。
4081
4082当前屏幕亮度规格:窗口设置屏幕亮度生效时,控制中心不可以调整系统屏幕亮度,窗口恢复默认系统亮度之后,控制中心可以调整系统屏幕亮度。
4083
4084**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4085
4086**参数:**
4087
4088| 参数名 | 类型 | 必填 | 说明                                     |
4089| ---------- | ------ | -- |----------------------------------------|
4090| brightness | number | 是 | 屏幕亮度值。该参数为浮点数,取值范围为[0.0, 1.0]或-1.0。1.0表示最亮,-1.0表示默认亮度。 |
4091
4092**返回值:**
4093
4094| 类型 | 说明 |
4095| ------------------- | ------------------------ |
4096| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
4097
4098**错误码:**
4099
4100以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4101
4102| 错误码ID | 错误信息 |
4103| ------- | -------------------------------------------- |
4104| 1300002 | This window state is abnormal.               |
4105| 1300003 | This window manager service works abnormally. |
4106
4107**示例:**
4108
4109```ts
4110import { BusinessError } from '@ohos.base';
4111
4112let brightness: number = 1;
4113try {
4114  let promise = windowClass.setWindowBrightness(brightness);
4115  promise.then(() => {
4116    console.info('Succeeded in setting the brightness.');
4117  }).catch((err: BusinessError) => {
4118    console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
4119  });
4120} catch (exception) {
4121  console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
4122}
4123```
4124
4125### setWindowFocusable<sup>9+</sup>
4126
4127setWindowFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): void
4128
4129设置点击时是否支持切换焦点窗口,使用callback异步回调。
4130
4131**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4132
4133**参数:**
4134
4135| 参数名 | 类型 | 必填 | 说明 |
4136| ----------- | ------------------------- | -- | ------------------------------------------------------- |
4137| isFocusable | boolean                   | 是 | 点击时是否支持切换焦点窗口。true表示支持;false表示不支持。 |
4138| callback    | AsyncCallback&lt;void&gt; | 是 | 回调函数。                                               |
4139
4140**错误码:**
4141
4142以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4143
4144| 错误码ID | 错误信息 |
4145| ------- | -------------------------------------------- |
4146| 1300002 | This window state is abnormal.               |
4147| 1300003 | This window manager service works abnormally. |
4148
4149**示例:**
4150
4151```ts
4152import { BusinessError } from '@ohos.base';
4153
4154let isFocusable: boolean = true;
4155let windowClass: window.Window = window.findWindow("test");
4156try {
4157  windowClass.setWindowFocusable(isFocusable, (err: BusinessError) => {
4158    const errCode: number = err.code;
4159    if (errCode) {
4160      console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err));
4161      return;
4162    }
4163    console.info('Succeeded in setting the window to be focusable.');
4164  });
4165} catch (exception) {
4166  console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
4167}
4168```
4169
4170### setWindowFocusable<sup>9+</sup>
4171
4172setWindowFocusable(isFocusable: boolean): Promise&lt;void&gt;
4173
4174设置点击时是否支持切换焦点窗口,使用Promise异步回调。
4175
4176**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4177
4178**参数:**
4179
4180| 参数名 | 类型 | 必填 | 说明 |
4181| ----------- | ------- | -- | -------------------------------------------------------- |
4182| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。true表示支持;false表示不支持。  |
4183
4184**返回值:**
4185
4186| 类型 | 说明 |
4187| ------------------- | ------------------------ |
4188| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
4189
4190**错误码:**
4191
4192以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4193
4194| 错误码ID | 错误信息 |
4195| ------- | -------------------------------------------- |
4196| 1300002 | This window state is abnormal.               |
4197| 1300003 | This window manager service works abnormally. |
4198
4199**示例:**
4200
4201```ts
4202import { BusinessError } from '@ohos.base';
4203
4204let isFocusable: boolean = true;
4205let windowClass: window.Window = window.findWindow("test");
4206try {
4207  let promise = windowClass.setWindowFocusable(isFocusable);
4208  promise.then(() => {
4209    console.info('Succeeded in setting the window to be focusable.');
4210  }).catch((err: BusinessError) => {
4211    console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
4212  });
4213} catch (exception) {
4214  console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
4215}
4216```
4217
4218### setWindowKeepScreenOn<sup>9+</sup>
4219
4220setWindowKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback&lt;void&gt;): void
4221
4222设置屏幕是否为常亮状态,使用callback异步回调。
4223
4224**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4225
4226**参数:**
4227
4228| 参数名 | 类型 | 必填 | 说明 |
4229| -------------- | ------------------------- | -- | ---------------------------------------------------- |
4230| isKeepScreenOn | boolean                   | 是 | 设置屏幕是否为常亮状态。true表示常亮;false表示不常亮。  |
4231| callback       | AsyncCallback&lt;void&gt; | 是 | 回调函数。                                            |
4232
4233**错误码:**
4234
4235以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4236
4237| 错误码ID | 错误信息 |
4238| ------- | -------------------------------------------- |
4239| 1300002 | This window state is abnormal.               |
4240| 1300003 | This window manager service works abnormally. |
4241
4242**示例:**
4243
4244```ts
4245import { BusinessError } from '@ohos.base';
4246
4247let isKeepScreenOn: boolean = true;
4248let windowClass: window.Window = window.findWindow("test");
4249try {
4250  windowClass.setWindowKeepScreenOn(isKeepScreenOn, (err: BusinessError) => {
4251    const errCode: number = err.code;
4252    if (errCode) {
4253      console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
4254      return;
4255    }
4256    console.info('Succeeded in setting the screen to be always on.');
4257  });
4258} catch (exception) {
4259  console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
4260}
4261```
4262
4263### setWindowKeepScreenOn<sup>9+</sup>
4264
4265setWindowKeepScreenOn(isKeepScreenOn: boolean): Promise&lt;void&gt;
4266
4267设置屏幕是否为常亮状态,使用Promise异步回调。
4268
4269**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4270
4271**参数:**
4272
4273| 参数名 | 类型 | 必填 | 说明 |
4274| -------------- | ------- | -- | --------------------------------------------------- |
4275| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。true表示常亮;false表示不常亮。 |
4276
4277**返回值:**
4278
4279| 类型 | 说明 |
4280| ------------------- | ------------------------ |
4281| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
4282
4283**错误码:**
4284
4285以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4286
4287| 错误码ID | 错误信息 |
4288| ------- | -------------------------------------------- |
4289| 1300002 | This window state is abnormal.               |
4290| 1300003 | This window manager service works abnormally. |
4291
4292**示例:**
4293
4294```ts
4295import { BusinessError } from '@ohos.base';
4296
4297let isKeepScreenOn: boolean = true;
4298let windowClass: window.Window = window.findWindow("test");
4299try {
4300  let promise = windowClass.setWindowKeepScreenOn(isKeepScreenOn);
4301  promise.then(() => {
4302    console.info('Succeeded in setting the screen to be always on.');
4303  }).catch((err: BusinessError) => {
4304    console.info('Failed to set the screen to be always on. Cause:  ' + JSON.stringify(err));
4305  });
4306} catch (exception) {
4307  console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
4308}
4309```
4310
4311### setWakeUpScreen()<sup>9+</sup>
4312
4313setWakeUpScreen(wakeUp: boolean): void
4314
4315窗口唤醒屏幕。
4316
4317**系统接口:** 此接口为系统接口。
4318
4319**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4320
4321**参数:**
4322
4323| 参数名           | 类型    | 必填 | 说明                         |
4324| ---------------- | ------- | ---- | ---------------------------- |
4325| wakeUp           | boolean | 是   | 是否设置唤醒屏幕。true表示唤醒;false表示不唤醒。  |
4326
4327**错误码:**
4328
4329以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4330
4331| 错误码ID | 错误信息 |
4332| ------- | -------------------------------------------- |
4333| 1300002 | This window state is abnormal.               |
4334| 1300003 | This window manager service works abnormally. |
4335
4336**示例:**
4337
4338```ts
4339let wakeUp: boolean = true;
4340let windowClass: window.Window = window.findWindow("test");
4341try {
4342  windowClass.setWakeUpScreen(wakeUp);
4343} catch (exception) {
4344  console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception));
4345}
4346```
4347
4348### setWindowPrivacyMode<sup>9+</sup>
4349
4350setWindowPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback&lt;void&gt;): void
4351
4352设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。此接口可用于禁止截屏/录屏的场景。
4353
4354**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4355
4356**需要权限:** ohos.permission.PRIVACY_WINDOW
4357
4358**参数:**
4359
4360| 参数名 | 类型 | 必填 | 说明 |
4361| ------------- | ------------------------- | -- | ------------------------------------------------------ |
4362| isPrivacyMode | boolean                   | 是 | 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。  |
4363| callback      | AsyncCallback&lt;void&gt; | 是 | 回调函数。                                              |
4364
4365**错误码:**
4366
4367以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4368
4369| 错误码ID | 错误信息 |
4370| ------- | ------------------------------ |
4371| 1300002 | This window state is abnormal. |
4372
4373**示例:**
4374
4375```ts
4376import { BusinessError } from '@ohos.base';
4377
4378let isPrivacyMode: boolean = true;
4379let windowClass: window.Window = window.findWindow("test");
4380try {
4381  windowClass.setWindowPrivacyMode(isPrivacyMode, (err: BusinessError) => {
4382    const errCode: number = err.code;
4383    if (errCode) {
4384      console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
4385      return;
4386    }
4387    console.info('Succeeded in setting the window to privacy mode.');
4388  });
4389} catch (exception) {
4390  console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
4391}
4392```
4393
4394### setWindowPrivacyMode<sup>9+</sup>
4395
4396setWindowPrivacyMode(isPrivacyMode: boolean): Promise&lt;void&gt;
4397
4398设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。此接口可用于禁止截屏/录屏的场景。
4399
4400**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4401
4402**需要权限:** ohos.permission.PRIVACY_WINDOW
4403
4404**参数:**
4405
4406| 参数名 | 类型 | 必填 | 说明 |
4407| ------------- | ------- | -- | ----------------------------------------------------- |
4408| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 |
4409
4410**返回值:**
4411
4412| 类型 | 说明 |
4413| ------------------- | ------------------------ |
4414| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
4415
4416**错误码:**
4417
4418以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4419
4420| 错误码ID | 错误信息 |
4421| ------- | ------------------------------ |
4422| 1300002 | This window state is abnormal. |
4423
4424**示例:**
4425
4426```ts
4427import { BusinessError } from '@ohos.base';
4428
4429let isPrivacyMode: boolean = true;
4430let windowClass: window.Window = window.findWindow("test");
4431try {
4432  let promise = windowClass.setWindowPrivacyMode(isPrivacyMode);
4433  promise.then(() => {
4434    console.info('Succeeded in setting the window to privacy mode.');
4435  }).catch((err: BusinessError) => {
4436    console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
4437  });
4438} catch (exception) {
4439  console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
4440}
4441```
4442
4443### setSnapshotSkip<sup>9+</sup>
4444setSnapshotSkip(isSkip: boolean): void
4445
4446截屏录屏是否忽略当前窗口。此接口一般用于禁止截屏/录屏的场景。
4447
4448**系统接口:** 此接口为系统接口。
4449
4450**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4451
4452**参数:**
4453
4454| 参数名        | 类型    | 必填 | 说明                 |
4455| ------------- | ------- | ---- | -------------------- |
4456| isSkip | boolean | 是   | 截屏录屏是否忽略当前窗口,默认为false。<br>true表示忽略当前窗口,false表示不忽略当前窗口。</br> |
4457
4458**错误码:**
4459
4460以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4461
4462| 错误码ID | 错误信息 |
4463| ------- | ------------------------------ |
4464| 1300002 | This window state is abnormal. |
4465
4466```ts
4467let windowClass: window.Window = window.findWindow("test");
4468let isSkip: boolean = true;
4469try {
4470  windowClass.setSnapshotSkip(isSkip);
4471} catch (exception) {
4472  console.error('Failed to Skip. Cause: ' + JSON.stringify(exception));
4473}
4474```
4475
4476### setWindowTouchable<sup>9+</sup>
4477
4478setWindowTouchable(isTouchable: boolean, callback: AsyncCallback&lt;void&gt;): void
4479
4480设置窗口是否为可触状态,使用callback异步回调。
4481
4482**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4483
4484**参数:**
4485
4486| 参数名 | 类型 | 必填 | 说明 |
4487| ----------- | ------------------------- | -- | ----------------------------------------------- |
4488| isTouchable | boolean                   | 是 | 窗口是否为可触状态。true表示可触;false表示不可触。 |
4489| callback    | AsyncCallback&lt;void&gt; | 是 | 回调函数。                                        |
4490
4491**错误码:**
4492
4493以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4494
4495| 错误码ID | 错误信息 |
4496| ------- | -------------------------------------------- |
4497| 1300002 | This window state is abnormal.               |
4498| 1300003 | This window manager service works abnormally. |
4499
4500**示例:**
4501
4502```ts
4503import { BusinessError } from '@ohos.base';
4504
4505let isTouchable = true;
4506let windowClass: window.Window = window.findWindow("test");
4507try {
4508  windowClass.setWindowTouchable(isTouchable, (err: BusinessError) => {
4509    const errCode: number = err.code;
4510    if (errCode) {
4511      console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
4512      return;
4513    }
4514    console.info('Succeeded in setting the window to be touchable.');
4515  });
4516} catch (exception) {
4517  console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
4518}
4519```
4520
4521### setWindowTouchable<sup>9+</sup>
4522
4523setWindowTouchable(isTouchable: boolean): Promise&lt;void&gt;
4524
4525设置窗口是否为可触状态,使用Promise异步回调。
4526
4527**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4528
4529**参数:**
4530
4531| 参数名 | 类型 | 必填 | 说明 |
4532| ----------- | ------- | -- | ----------------------------------------------- |
4533| isTouchable | boolean | 是 | 窗口是否为可触状态。true表示可触;false表示不可触。 |
4534
4535**返回值:**
4536
4537| 类型 | 说明 |
4538| ------------------- | ------------------------- |
4539| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
4540
4541**错误码:**
4542
4543以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4544
4545| 错误码ID | 错误信息 |
4546| ------- | -------------------------------------------- |
4547| 1300002 | This window state is abnormal.               |
4548| 1300003 | This window manager service works abnormally. |
4549
4550**示例:**
4551
4552```ts
4553import { BusinessError } from '@ohos.base';
4554
4555let isTouchable: boolean = true;
4556let windowClass: window.Window = window.findWindow("test");
4557try {
4558  let promise = windowClass.setWindowTouchable(isTouchable);
4559  promise.then(() => {
4560    console.info('Succeeded in setting the window to be touchable.');
4561  }).catch((err: BusinessError) => {
4562    console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
4563  });
4564} catch (exception) {
4565  console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
4566}
4567```
4568
4569### setForbidSplitMove<sup>9+</sup>
4570
4571setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback&lt;void&gt;): void
4572
4573设置窗口在分屏模式下是否被禁止移动,使用callback异步回调。
4574
4575**系统接口:** 此接口为系统接口。
4576
4577**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4578
4579**参数:**
4580
4581| 参数名      | 类型                      | 必填 | 说明                 |
4582| ----------- | ------------------------- | ---- | -------------------- |
4583| isForbidSplitMove | boolean                   | 是   | 窗口在分屏模式下是否被禁止移动。true表示禁止;false表示不禁止。 |
4584| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
4585
4586**错误码:**
4587
4588以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4589
4590| 错误码ID | 错误信息 |
4591| ------- | -------------------------------------------- |
4592| 1300002 | This window state is abnormal.               |
4593| 1300003 | This window manager service works abnormally. |
4594
4595**示例:**
4596
4597```ts
4598import { BusinessError } from '@ohos.base';
4599
4600let isForbidSplitMove: boolean = true;
4601let windowClass: window.Window = window.findWindow("test");
4602try {
4603  windowClass.setForbidSplitMove(isForbidSplitMove, (err: BusinessError) => {
4604    const errCode: number = err.code;
4605    if (errCode) {
4606      console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err));
4607      return;
4608    }
4609    console.info('Succeeded in forbidding window moving in split screen mode.');
4610  });
4611} catch (exception) {
4612  console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
4613}
4614```
4615
4616### setForbidSplitMove<sup>9+</sup>
4617
4618setForbidSplitMove(isForbidSplitMove: boolean): Promise&lt;void&gt;
4619
4620设置窗口在分屏模式下是否被禁止移动,使用Promise异步回调。
4621
4622**系统接口:** 此接口为系统接口。
4623
4624**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4625
4626**参数:**
4627
4628| 参数名      | 类型    | 必填 | 说明                 |
4629| ----------- | ------- | ---- | -------------------- |
4630| isForbidSplitMove | boolean | 是   | 窗口在分屏模式下是否被禁止移动。true表示禁止;false表示不禁止。 |
4631
4632**返回值:**
4633
4634| 类型                | 说明                      |
4635| ------------------- | ------------------------- |
4636| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
4637
4638**错误码:**
4639
4640以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4641
4642| 错误码ID | 错误信息 |
4643| ------- | -------------------------------------------- |
4644| 1300002 | This window state is abnormal.               |
4645| 1300003 | This window manager service works abnormally. |
4646
4647**示例:**
4648
4649```ts
4650import { BusinessError } from '@ohos.base';
4651
4652let isForbidSplitMove: boolean = true;
4653let windowClass: window.Window = window.findWindow("test");
4654try {
4655  let promise = windowClass.setForbidSplitMove(isForbidSplitMove);
4656  promise.then(() => {
4657    console.info('Succeeded in forbidding window moving in split screen mode.');
4658  }).catch((err: BusinessError) => {
4659    console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err));
4660  });
4661} catch (exception) {
4662  console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
4663}
4664```
4665
4666### snapshot<sup>9+</sup>
4667
4668snapshot(callback: AsyncCallback&lt;image.PixelMap&gt;): void
4669
4670获取窗口截图,使用callback异步回调。
4671
4672**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4673
4674**参数:**
4675
4676| 参数名      | 类型                      | 必填 | 说明                 |
4677| ----------- | ------------------------- | ---- | -------------------- |
4678| callback    | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | 是   | 回调函数。  |
4679
4680**错误码:**
4681
4682以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4683
4684| 错误码ID | 错误信息 |
4685| ------- | ------------------------------ |
4686| 1300002 | This window state is abnormal. |
4687
4688**示例:**
4689
4690```ts
4691import { BusinessError } from '@ohos.base';
4692import image from '@ohos.multimedia.image';
4693
4694let windowClass: window.Window = window.findWindow("test");
4695windowClass.snapshot((err: BusinessError, pixelMap: image.PixelMap) => {
4696  const errCode: number = err.code;
4697  if (errCode) {
4698    console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
4699    return;
4700  }
4701  console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
4702  pixelMap.release(); // PixelMap使用完后及时释放内存
4703});
4704```
4705
4706### snapshot<sup>9+</sup>
4707
4708snapshot(): Promise&lt;image.PixelMap&gt;
4709
4710获取窗口截图,使用Promise异步回调。
4711
4712**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4713
4714**返回值:**
4715
4716| 类型                | 说明                      |
4717| ------------------- | ------------------------- |
4718| Promise&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Promise对象。返回当前窗口截图。 |
4719
4720**错误码:**
4721
4722以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4723
4724| 错误码ID | 错误信息 |
4725| ------- | ------------------------------ |
4726| 1300002 | This window state is abnormal. |
4727
4728**示例:**
4729
4730```ts
4731import { BusinessError } from '@ohos.base';
4732import image from '@ohos.multimedia.image';
4733
4734let windowClass: window.Window = window.findWindow("test");
4735let promise = windowClass.snapshot();
4736promise.then((pixelMap: image.PixelMap) => {
4737  console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
4738  pixelMap.release(); // PixelMap使用完后及时释放内存
4739}).catch((err: BusinessError) => {
4740  console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
4741});
4742```
4743
4744### opacity<sup>9+</sup>
4745
4746opacity(opacity: number): void
4747
4748设置窗口不透明度。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。
4749
4750**系统接口:** 此接口为系统接口。
4751
4752**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4753
4754**参数:**
4755
4756| 参数名  | 类型   | 必填 | 说明                                                 |
4757| ------- | ------ | ---- |----------------------------------------------------|
4758| opacity | number | 是   | 不透明度。该参数为浮点数,取值范围为[0.0, 1.0]。0.0表示完全透明,1.0表示完全不透明。 |
4759
4760**错误码:**
4761
4762以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4763
4764| 错误码ID | 错误信息 |
4765| ------- | ------------------------------ |
4766| 1300002 | This window state is abnormal. |
4767| 1300004 | Unauthorized operation.  |
4768
4769**示例:**
4770
4771```ts
4772let windowClass: window.Window = window.findWindow("test");
4773try {
4774  windowClass.opacity(0.5);
4775} catch (exception) {
4776  console.error('Failed to opacity. Cause: ' + JSON.stringify(exception));
4777}
4778```
4779
4780### scale<sup>9+</sup>
4781
4782scale(scaleOptions: ScaleOptions): void
4783
4784设置窗口缩放参数。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。
4785
4786**系统接口:** 此接口为系统接口。
4787
4788**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4789
4790**参数:**
4791
4792| 参数名       | 类型                           | 必填 | 说明       |
4793| ------------ | ------------------------------ | ---- | ---------- |
4794| scaleOptions | [ScaleOptions](#scaleoptions9) | 是   | 缩放参数。 |
4795
4796**错误码:**
4797
4798以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4799
4800| 错误码ID | 错误信息 |
4801| ------- | ------------------------------ |
4802| 1300002 | This window state is abnormal. |
4803| 1300004 | Unauthorized operation.  |
4804
4805**示例:**
4806
4807```ts
4808let windowClass: window.Window = window.findWindow("test");
4809let obj: window.ScaleOptions = {
4810  x: 2.0,
4811  y: 1.0,
4812  pivotX: 0.5,
4813  pivotY: 0.5
4814};
4815try {
4816  windowClass.scale(obj);
4817} catch (exception) {
4818  console.error('Failed to scale. Cause: ' + JSON.stringify(exception));
4819}
4820```
4821
4822### rotate<sup>9+</sup>
4823
4824rotate(rotateOptions: RotateOptions): void
4825
4826设置窗口旋转参数。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。
4827
4828**系统接口:** 此接口为系统接口。
4829
4830**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4831
4832**参数:**
4833
4834| 参数名        | 类型                             | 必填 | 说明       |
4835| ------------- | -------------------------------- | ---- | ---------- |
4836| rotateOptions | [RotateOptions](#rotateoptions9) | 是   | 旋转参数。 |
4837
4838**错误码:**
4839
4840以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4841
4842| 错误码ID | 错误信息 |
4843| ------- | ------------------------------ |
4844| 1300002 | This window state is abnormal. |
4845| 1300004 | Unauthorized operation.  |
4846
4847**示例:**
4848
4849```ts
4850let windowClass: window.Window = window.findWindow("test");
4851let obj: window.RotateOptions = {
4852  x: 1.0,
4853  y: 1.0,
4854  z: 45.0,
4855  pivotX: 0.5,
4856  pivotY: 0.5
4857};
4858try {
4859  windowClass.rotate(obj);
4860} catch (exception) {
4861  console.error('Failed to rotate. Cause: ' + JSON.stringify(exception));
4862}
4863```
4864
4865### translate<sup>9+</sup>
4866
4867translate(translateOptions: TranslateOptions): void
4868
4869设置窗口平移参数。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。
4870
4871**系统接口:** 此接口为系统接口。
4872
4873**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4874
4875**参数:**
4876
4877| 参数名           | 类型                                   | 必填 | 说明                 |
4878| ---------------- | -------------------------------------- | ---- | -------------------- |
4879| translateOptions | [TranslateOptions](#translateoptions9) | 是   | 平移参数,单位为px。 |
4880
4881**错误码:**
4882
4883以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4884
4885| 错误码ID | 错误信息 |
4886| ------- | ------------------------------ |
4887| 1300002 | This window state is abnormal. |
4888| 1300004 | Unauthorized operation.  |
4889
4890**示例:**
4891
4892```ts
4893let windowClass: window.Window = window.findWindow("test");
4894let obj: window.TranslateOptions = {
4895  x: 100.0,
4896  y: 0.0,
4897  z: 0.0
4898};
4899try {
4900  windowClass.translate(obj);
4901} catch (exception) {
4902  console.error('Failed to translate. Cause: ' + JSON.stringify(exception));
4903}
4904```
4905
4906###  getTransitionController<sup>9+</sup>
4907
4908 getTransitionController(): TransitionController
4909
4910获取窗口属性转换控制器。
4911
4912**系统接口:** 此接口为系统接口。
4913
4914**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4915
4916**返回值:**
4917
4918| 类型                                           | 说明             |
4919| ---------------------------------------------- | ---------------- |
4920| [TransitionController](#transitioncontroller9) | 属性转换控制器。 |
4921
4922**错误码:**
4923
4924以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4925
4926| 错误码ID | 错误信息 |
4927| ------- | ------------------------------ |
4928| 1300002 | This window state is abnormal. |
4929| 1300004 | Unauthorized operation.  |
4930
4931**示例:**
4932
4933```ts
4934import { BusinessError } from '@ohos.base';
4935
4936let windowClass: window.Window = window.findWindow("test");
4937(context: window.TransitionContext) => {
4938  let toWindow = context.toWindow;
4939  animateTo({
4940    duration: 1000, // 动画时长
4941    tempo: 0.5, // 播放速率
4942    curve: Curve.EaseInOut, // 动画曲线
4943    delay: 0, // 动画延迟
4944    iterations: 1, // 播放次数
4945    playMode: PlayMode.Normal, // 动画模式
4946    onFinish: () => {
4947      context.completeTransition(true)
4948    }
4949  }, () => {
4950    let obj: window.TranslateOptions = {
4951      x: 100.0,
4952      y: 0.0,
4953      z: 0.0
4954    };
4955    toWindow.translate(obj); // 设置动画过程中的属性转换
4956    console.info('toWindow translate end');
4957  }
4958  );
4959  console.info('complete transition end');
4960};
4961windowClass.hideWithAnimation((err: BusinessError, data) => {
4962  const errCode: number = err.code;
4963  if (errCode) {
4964    console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
4965    return;
4966  }
4967  console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
4968});
4969```
4970
4971### setBlur<sup>9+</sup>
4972
4973setBlur(radius: number): void
4974
4975设置窗口模糊。
4976
4977**系统接口:** 此接口为系统接口。
4978
4979**系统能力:** SystemCapability.WindowManager.WindowManager.Core
4980
4981**参数:**
4982
4983| 参数名 | 类型   | 必填 | 说明                                               |
4984| ------ | ------ | ---- |--------------------------------------------------|
4985| radius | number | 是   | 表示窗口模糊的半径值。该参数为浮点数,取值范围为[0, +∞),取值为0.0时表示关闭窗口模糊。 |
4986
4987**错误码:**
4988
4989以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
4990
4991| 错误码ID | 错误信息 |
4992| ------- | ------------------------------ |
4993| 1300002 | This window state is abnormal. |
4994| 1300004 | Unauthorized operation.  |
4995
4996**示例:**
4997
4998```ts
4999let windowClass: window.Window = window.findWindow("test");
5000try {
5001  windowClass.setBlur(4.0);
5002} catch (exception) {
5003  console.error('Failed to set blur. Cause: ' + JSON.stringify(exception));
5004}
5005```
5006
5007### setBackdropBlur<sup>9+</sup>
5008
5009setBackdropBlur(radius: number): void
5010
5011设置窗口背景模糊。
5012
5013**系统接口:** 此接口为系统接口。
5014
5015**系统能力:** SystemCapability.WindowManager.WindowManager.Core
5016
5017**参数:**
5018
5019| 参数名 | 类型   | 必填 | 说明                                                    |
5020| ------ | ------ | ---- |-------------------------------------------------------|
5021| radius | number | 是   | 表示窗口背景模糊的半径值。该参数为浮点数,取值范围为[0.0, +∞),取值为0.0表示关闭窗口背景模糊。 |
5022
5023**错误码:**
5024
5025以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5026
5027| 错误码ID | 错误信息 |
5028| ------- | ------------------------------ |
5029| 1300002 | This window state is abnormal. |
5030| 1300004 | Unauthorized operation.  |
5031
5032**示例:**
5033
5034```ts
5035let windowClass: window.Window = window.findWindow("test");
5036try {
5037  windowClass.setBackdropBlur(4.0);
5038} catch (exception) {
5039  console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception));
5040}
5041```
5042
5043### setBackdropBlurStyle<sup>9+</sup>
5044
5045setBackdropBlurStyle(blurStyle: BlurStyle): void
5046
5047设置窗口背景模糊类型。
5048
5049**系统接口:** 此接口为系统接口。
5050
5051**系统能力:** SystemCapability.WindowManager.WindowManager.Core
5052
5053**参数:**
5054
5055| 参数名    | 类型      | 必填 | 说明                   |
5056| --------- | --------- | ---- | ---------------------- |
5057| blurStyle | [BlurStyle](#blurstyle9) | 是   | 表示窗口背景模糊类型。 |
5058
5059**错误码:**
5060
5061以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5062
5063| 错误码ID | 错误信息 |
5064| ------- | ------------------------------ |
5065| 1300002 | This window state is abnormal. |
5066| 1300004 | Unauthorized operation.  |
5067
5068**示例:**
5069
5070```ts
5071let windowClass: window.Window = window.findWindow("test");
5072try {
5073  windowClass.setBackdropBlurStyle(window.BlurStyle.THIN);
5074} catch (exception) {
5075  console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception));
5076}
5077```
5078
5079### setShadow<sup>9+</sup>
5080
5081setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void
5082
5083设置窗口边缘阴影。
5084
5085**系统接口:** 此接口为系统接口。
5086
5087**系统能力:** SystemCapability.WindowManager.WindowManager.Core
5088
5089**参数:**
5090
5091| 参数名  | 类型   | 必填 | 说明                                                          |
5092| ------- | ------ | ---- |-------------------------------------------------------------|
5093| radius  | number | 是   | 表示窗口边缘阴影的模糊半径。该参数为浮点数,取值范围为[0.0, +∞),取值为0.0时表示关闭窗口边缘阴影。     |
5094| color   | string | 否   | 表示窗口边缘阴影的颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 |
5095| offsetX | number | 否   | 表示窗口边缘阴影的X轴的偏移量。该参数为浮点数,单位为px。                              |
5096| offsetY | number | 否   | 表示窗口边缘阴影的Y轴的偏移量。该参数为浮点数,单位为px。                              |
5097
5098**错误码:**
5099
5100以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5101
5102| 错误码ID | 错误信息 |
5103| ------- | ------------------------------ |
5104| 1300002 | This window state is abnormal. |
5105| 1300004 | Unauthorized operation.  |
5106
5107**示例:**
5108
5109```ts
5110let windowClass: window.Window = window.findWindow("test");
5111try {
5112  windowClass.setShadow(4.0, '#FF00FF00', 2, 3);
5113} catch (exception) {
5114  console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception));
5115}
5116```
5117
5118### setCornerRadius<sup>9+</sup>
5119
5120setCornerRadius(cornerRadius: number): void
5121
5122设置窗口圆角半径。
5123
5124**系统接口:** 此接口为系统接口。
5125
5126**系统能力:** SystemCapability.WindowManager.WindowManager.Core
5127
5128**参数:**
5129
5130| 参数名      | 类型    | 必填 | 说明                                                 |
5131| ----------- | ------- | ---- |----------------------------------------------------|
5132| radius | number | 是   | 表示窗口圆角的半径值。该参数为浮点数,取值范围为[0.0, +∞),取值为0.0时表示没有窗口圆角。 |
5133
5134**错误码:**
5135
5136以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5137
5138| 错误码ID | 错误信息 |
5139| ------- | ------------------------------ |
5140| 1300002 | This window state is abnormal. |
5141| 1300004 | Unauthorized operation.  |
5142
5143**示例:**
5144
5145```ts
5146let windowClass: window.Window = window.findWindow("test");
5147try {
5148  windowClass.setCornerRadius(4.0);
5149} catch (exception) {
5150  console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception));
5151}
5152```
5153
5154### raiseToAppTop<sup>10+</sup>
5155
5156raiseToAppTop(callback: AsyncCallback&lt;void&gt;): void
5157
5158提升应用子窗口到应用顶层。使用callback异步回调。
5159
5160**系统接口:** 此接口为系统接口。
5161
5162**系统能力:** SystemCapability.WindowManager.WindowManager.Core
5163
5164**参数:**
5165
5166| 参数名   | 类型                      | 必填 | 说明       |
5167| -------- | ------------------------- | ---- | ---------- |
5168| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
5169
5170**错误码:**
5171
5172以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5173
5174| 错误码ID | 错误信息 |
5175| ------- | ------------------------------ |
5176| 1300002 | This window state is abnormal. |
5177| 1300003 | This window manager service works abnormally. |
5178| 1300004 | Unauthorized operation. |
5179| 1300009 | The parent window is invalid. |
5180
5181**示例:**
5182
5183```ts
5184import { BusinessError } from '@ohos.base';
5185
5186let windowClass: window.Window = window.findWindow("test");
5187windowClass.raiseToAppTop((err: BusinessError) => {
5188  const errCode: number = err.code;
5189  if (errCode) {
5190    console.error('Failed to raise the window to app top. Cause: ' + JSON.stringify(err));
5191    return;
5192  }
5193  console.info('Succeeded in raising the window to app top.');
5194});
5195```
5196
5197### raiseToAppTop<sup>10+</sup>
5198
5199raiseToAppTop(): Promise&lt;void&gt;
5200
5201提升应用子窗口到应用顶层。使用Promise异步回调。
5202
5203**系统接口:** 此接口为系统接口。
5204
5205**系统能力:** SystemCapability.WindowManager.WindowManager.Core
5206
5207**返回值:**
5208
5209| 类型                | 说明                      |
5210| ------------------- | ------------------------- |
5211| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
5212
5213**错误码:**
5214
5215以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5216
5217| 错误码ID | 错误信息 |
5218| ------- | ------------------------------ |
5219| 1300002 | This window state is abnormal. |
5220| 1300003 | This window manager service works abnormally. |
5221| 1300004 | Unauthorized operation. |
5222| 1300009 | The parent window is invalid. |
5223
5224**示例:**
5225
5226```ts
5227import { BusinessError } from '@ohos.base';
5228
5229let windowClass: window.Window = window.findWindow("test");
5230let promise = windowClass.raiseToAppTop();
5231promise.then(() => {
5232  console.info('Succeeded in raising the window to app top.');
5233}).catch((err: BusinessError) => {
5234  console.error('Failed to raise the window to app top. Cause: ' + JSON.stringify(err));
5235});
5236```
5237### setAspectRatio<sup>10+</sup>
5238
5239setAspectRatio(ratio: number): Promise&lt;void&gt;
5240
5241设置窗口内容布局的比例,使用Promise异步回调。
5242
5243仅应用主窗口支持此接口功能,比例参数将持久化保存,关闭应用或重启设备设置的比例仍然生效。
5244
5245**系统能力:** SystemCapability.WindowManager.WindowManager.Core
5246
5247**参数:**
5248
5249| 参数名             | 类型    | 必填 | 说明                                        |
5250| ------------------ | ------- | ---- |-------------------------------------------|
5251| ratio | number | 是   | 除边框装饰之外的窗口内容布局的宽高比。该参数为浮点数,取值范围为(0.0, +∞)。 |
5252
5253**返回值:**
5254
5255| 类型                | 说明                      |
5256| ------------------- | ------------------------- |
5257| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
5258
5259**错误码:**
5260
5261以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5262
5263| 错误码ID | 错误信息 |
5264| ------- | -------------------------------------------- |
5265| 1300002 | This window state is abnormal.               |
5266| 1300004 | Unauthorized operation.                      |
5267
5268**示例:**
5269
5270```ts
5271import { BusinessError } from '@ohos.base';
5272
5273let windowClass: window.Window = window.findWindow("test");
5274try {
5275  let ratio = 1.0;
5276  let promise = windowClass.setAspectRatio(ratio);
5277  promise.then(() => {
5278    console.info('Succeeded in setting aspect ratio of window.');
5279  }).catch((err: BusinessError) => {
5280    console.error('Failed to set the aspect ratio of window. Cause:' + JSON.stringify(err));
5281  });
5282} catch (exception) {
5283  console.error('Failed to set the aspect ratio of window. Cause: ' + JSON.stringify(exception));
5284}
5285```
5286
5287### setAspectRatio<sup>10+</sup>
5288
5289setAspectRatio(ratio: number, callback: AsyncCallback&lt;void&gt;): void
5290
5291设置窗口内容布局的比例,使用callback异步回调。
5292
5293仅应用主窗口支持此接口功能,比例参数将持久化保存,关闭应用或重启设备设置的比例仍然生效。
5294
5295**系统能力:** SystemCapability.WindowManager.WindowManager.Core
5296
5297**参数:**
5298
5299| 参数名             | 类型    | 必填 | 说明                                         |
5300| ------------------ | ------- | ---- |--------------------------------------------|
5301| ratio | number | 是   | 除边框装饰之外的窗口内容布局的宽高比。该参数为浮点数,取值范围为(0.0, +∞)。 |
5302| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                      |
5303
5304**错误码:**
5305
5306以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5307
5308| 错误码ID | 错误信息 |
5309| ------- | -------------------------------------------- |
5310| 1300002 | This window state is abnormal.               |
5311| 1300004 | Unauthorized operation.                      |
5312
5313**示例:**
5314
5315```ts
5316import { BusinessError } from '@ohos.base';
5317
5318let windowClass: window.Window = window.findWindow("test");
5319try {
5320  let ratio = 1.0;
5321  windowClass.setAspectRatio(ratio, (err: BusinessError) => {
5322    const errCode: number = err.code;
5323    if (errCode) {
5324      console.error('Failed to set the aspect ratio of window. Cause:' + JSON.stringify(err));
5325      return;
5326    }
5327    console.info('Succeeded in setting the aspect ratio of window.');
5328  });
5329} catch (exception) {
5330  console.error('Failed to set the aspect ratio of window. Cause: ' + JSON.stringify(exception));
5331}
5332```
5333
5334### resetAspectRatio<sup>10+</sup>
5335
5336resetAspectRatio(): Promise&lt;void&gt;
5337
5338取消设置窗口内容布局的比例,使用Promise异步回调。
5339
5340仅应用主窗口支持此接口功能,调用后将清除持久化储存的比例信息。
5341
5342**系统能力:** SystemCapability.WindowManager.WindowManager.Core
5343
5344**返回值:**
5345
5346| 类型                | 说明                      |
5347| ------------------- | ------------------------- |
5348| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
5349
5350**错误码:**
5351
5352以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5353
5354| 错误码ID | 错误信息 |
5355| ------- | -------------------------------------------- |
5356| 1300002 | This window state is abnormal.               |
5357| 1300004 | Unauthorized operation.                      |
5358
5359**示例:**
5360
5361```ts
5362import { BusinessError } from '@ohos.base';
5363
5364let windowClass: window.Window = window.findWindow("test");
5365try {
5366  let promise = windowClass.resetAspectRatio();
5367  promise.then(() => {
5368    console.info('Succeeded in resetting aspect ratio of window.');
5369  }).catch((err: BusinessError) => {
5370    console.error('Failed to reset the aspect ratio of window. Cause:' + JSON.stringify(err));
5371  });
5372} catch (exception) {
5373  console.error('Failed to reset the aspect ratio of window. Cause: ' + JSON.stringify(exception));
5374}
5375```
5376
5377### resetAspectRatio<sup>10+</sup>
5378
5379resetAspectRatio(callback: AsyncCallback&lt;void&gt;): void
5380
5381取消设置窗口内容布局的比例,使用callback异步回调。
5382
5383仅应用主窗口支持此接口功能,调用后将清除持久化储存的比例信息。
5384
5385**系统能力:** SystemCapability.WindowManager.WindowManager.Core
5386
5387**参数:**
5388
5389| 参数名             | 类型    | 必填 | 说明                                                         |
5390| ------------------ | ------- | ---- | ------------------------------------------------------------ |
5391| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
5392
5393**错误码:**
5394
5395以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5396
5397| 错误码ID | 错误信息 |
5398| ------- | -------------------------------------------- |
5399| 1300002 | This window state is abnormal.               |
5400| 1300004 | Unauthorized operation.                      |
5401
5402**示例:**
5403
5404```ts
5405import { BusinessError } from '@ohos.base';
5406
5407let windowClass: window.Window = window.findWindow("test");
5408try {
5409    windowClass.resetAspectRatio((err: BusinessError) => {
5410        const errCode: number = err.code;
5411        if (errCode) {
5412            console.error('Failed to reset the aspect ratio of window. Cause:' + JSON.stringify(err));
5413            return;
5414        }
5415        console.info('Succeeded in resetting aspect ratio of window.');
5416    });
5417} catch (exception) {
5418    console.error('Failed to reset the aspect ratio of window. Cause: ' + JSON.stringify(exception));
5419}
5420```
5421
5422### setWaterMarkFlag<sup>10+</sup>
5423
5424setWaterMarkFlag(enable: boolean): Promise&lt;void&gt;
5425
5426为当前窗口添加或删除安全水印标志,使用Promise异步回调。
5427
5428**系统接口:** 此接口为系统接口。
5429
5430**系统能力:** SystemCapability.WindowManager.WindowManager.Core
5431
5432**参数:**
5433
5434| 参数名 | 类型     | 必填 | 说明                                            |
5435| ------ | ------- | --- | ------------------------------------------------ |
5436| enable | boolean | 是   | 是否对窗口添加标志位。true表示添加,false表示删除。 |
5437
5438**返回值:**
5439
5440| 类型                | 说明                      |
5441| ------------------- | ------------------------- |
5442| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
5443
5444**错误码:**
5445
5446以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5447
5448| 错误码ID | 错误信息 |
5449| ------- | ---------------------------------------------- |
5450| 1300002 | This window state is abnormal.                 |
5451| 1300003 | This window manager service works abnormally.  |
5452| 1300008 | The operation is on invalid display.           |
5453
5454**示例:**
5455
5456```ts
5457import { BusinessError } from '@ohos.base';
5458
5459let windowClass: window.Window = window.findWindow("test");
5460try {
5461  let enable = true;
5462  let promise = windowClass.setWaterMarkFlag(enable);
5463  promise.then(() => {
5464    console.info('Succeeded in setting water mark flag of window.');
5465  }).catch((err: BusinessError) => {
5466    console.error('Failed to set water mark flag of window. Cause:' + JSON.stringify(err));
5467  });
5468} catch (exception) {
5469  console.error('Failed to set water mark flag of window. Cause: ' + JSON.stringify(exception));
5470}
5471```
5472
5473### setWaterMarkFlag<sup>10+</sup>
5474
5475setWaterMarkFlag(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
5476
5477为当前窗口添加或删除安全水印标志,使用callback异步回调。
5478
5479**系统接口:** 此接口为系统接口。
5480
5481**系统能力:** SystemCapability.WindowManager.WindowManager.Core
5482
5483**参数:**
5484
5485| 参数名   | 类型                       | 必填 | 说明                                              |
5486| -------- | ------------------------- | ---  | ----------------------------------------------- |
5487| enable   | boolean                   | 是   | 是否对窗口添加标志位。true表示添加,false表示删除。 |
5488| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
5489
5490**错误码:**
5491
5492以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5493
5494| 错误码ID | 错误信息 |
5495| ------- | ---------------------------------------------- |
5496| 1300002 | This window state is abnormal.                 |
5497| 1300003 | This window manager service works abnormally.  |
5498| 1300008 | The operation is on invalid display.           |
5499
5500**示例:**
5501
5502```ts
5503import { BusinessError } from '@ohos.base';
5504
5505let windowClass: window.Window = window.findWindow("test");
5506try {
5507  let enable: boolean = true;
5508  windowClass.setWaterMarkFlag(enable, (err: BusinessError) => {
5509    const errCode: number = err.code;
5510    if (errCode) {
5511      console.error('Failed to set water mark flag of window. Cause:' + JSON.stringify(err));
5512      return;
5513    }
5514    console.info('Succeeded in setting water mark flag of window.');
5515  });
5516} catch (exception) {
5517  console.error('Failed to set water mark flag of window. Cause: ' + JSON.stringify(exception));
5518}
5519```
5520### raiseAboveTarget<sup>10+</sup>
5521
5522raiseAboveTarget(windowId: number, callback: AsyncCallback&lt;void&gt;): void
5523
5524将同一个主窗口下的子窗口提升到目标子窗口之上。使用callback异步回调。
5525
5526**系统接口:** 此接口为系统接口。
5527
5528**系统能力:** SystemCapability.Window.SessionManager
5529
5530**参数:**
5531
5532| 参数名   | 类型                      | 必填 | 说明       |
5533| -------- | ------------------------- | ---- | ---------- |
5534| windowId | number                    | 是   | 目标子窗口的id,通过[getWindowProperties](#getwindowproperties9)接口获取到[properties](#windowproperties)后,再通过properties.id获取 |
5535| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
5536
5537**错误码:**
5538
5539以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5540
5541| 错误码ID | 错误信息 |
5542| ------- | ---------------------------------------------- |
5543| 1300002 | This window state is abnormal. |
5544| 1300003 | This window manager service works abnormally. |
5545| 1300004 | Unauthorized operation. |
5546| 1300009 | The parent window is invalid. |
5547
5548**示例:**
5549
5550```ts
5551// 将windowClass调整到targetWindow之上
5552let properties = targetWindow.getWindowProperties();
5553let targetId = properties.id;
5554let windowClass: window.Window = window.findWindow("test");
5555windowClass.raiseAboveTarget(targetId, (err) => {
5556    if (err.code) {
5557        console.error('Failed to raise the subWindow to target subWindow top. Cause: ' + JSON.stringify(err));
5558        return;
5559    }
5560    console.info('Succeeded in raising the subWindow to target subWindow top.');
5561});
5562```
5563
5564### raiseAboveTarget<sup>10+</sup>
5565
5566raiseAboveTarget(windowId: number): Promise&lt;void&gt;
5567
5568将同一个主窗下的子窗口提升到目标子窗口之上。使用Promise异步回调。
5569
5570**系统接口:** 此接口为系统接口。
5571
5572**系统能力:** SystemCapability.Window.SessionManager
5573
5574**参数:**
5575
5576| 参数名   | 类型                      | 必填 | 说明       |
5577| -------- | ------------------------- | ---- | ---------- |
5578| windowId | number                    | 是   | 目标子窗口的id,通过[getWindowProperties](#getwindowproperties9)接口获取到[properties](#windowproperties)后,再通过properties.id获取 |
5579
5580**返回值:**
5581
5582| 类型                | 说明                      |
5583| ------------------- | ------------------------- |
5584| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
5585
5586**错误码:**
5587
5588以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5589
5590| 错误码ID | 错误信息 |
5591| ------- | ------------------------------ |
5592| 1300002 | This window state is abnormal. |
5593| 1300003 | This window manager service works abnormally. |
5594| 1300004 | Unauthorized operation. |
5595| 1300009 | The parent window is invalid. |
5596
5597**示例:**
5598
5599```ts
5600// 将windowClass调整到targetWindow之上
5601let properties = targetWindow.getWindowProperties();
5602let targetId = properties.id;
5603let promise = windowClass.raiseAboveTarget(targetId);
5604promise.then(()=> {
5605    console.info('Succeeded in raising the subWindow to target subWindow top.');
5606}).catch((err)=>{
5607    console.error('Failed to raise the subWindow to target subWindow top. Cause: ' + JSON.stringify(err));
5608});
5609```
5610### setRaiseByClickEnabled<sup>10+</sup>
5611
5612setRaiseByClickEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
5613
5614禁止/使能子窗口点击抬升功能。使用callback异步回调。
5615
5616通常来说,点击一个子窗口,会将该子窗口显示到最上方,如果设置为false,那么点击子窗口的时候,不会将该子窗口显示到最上方,而是保持不变。
5617
5618**系统接口:** 此接口为系统接口。
5619
5620**系统能力:** SystemCapability.Window.SessionManager
5621
5622**参数:**
5623
5624| 参数名   | 类型                      | 必填 | 说明       |
5625| -------- | ------------------------- | ---- | ---------- |
5626| enable   | boolean                   | 是   | 设置子窗口点击抬升功能是否使能,true表示使能,false表示禁止。 |
5627| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
5628
5629**错误码:**
5630
5631以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5632
5633| 错误码ID | 错误信息 |
5634| ------- | ------------------------------ |
5635| 1300002 | This window state is abnormal. |
5636| 1300003 | This window manager service works abnormally. |
5637| 1300004 | Unauthorized operation. |
5638| 1300009 | The parent window is invalid. |
5639
5640**示例:**
5641
5642```ts
5643let enabled = false;
5644let windowClass: window.Window = window.findWindow("test");
5645windowClass.setRaiseByClickEnabled(enabled, (err) => {
5646    if (err.code) {
5647        console.error('Failed to disable the raise-by-click function. Cause: ' + JSON.stringify(err));
5648        return;
5649    }
5650    console.info('Succeeded in disabling the raise-by-click function.');
5651});
5652```
5653
5654### setRaiseByClickEnabled<sup>10+</sup>
5655
5656setRaiseByClickEnabled(enable: boolean): Promise&lt;void&gt;
5657
5658禁止/使能子窗点击抬升功能。使用Promise异步回调。
5659
5660通常来说,点击一个子窗口,会将该子窗口显示到最上方,如果设置为false,那么点击子窗口的时候,不会将该子窗口显示到最上方,而是保持不变。
5661
5662**系统接口:** 此接口为系统接口。
5663
5664**系统能力:** SystemCapability.Window.SessionManager
5665
5666**参数:**
5667
5668| 参数名   | 类型                      | 必填 | 说明       |
5669| -------- | ------------------------- | ---- | ---------- |
5670| enable   | boolean                   | 是   | 设置子窗口点击抬升功能是否使能,true表示使能,false表示禁止。 |
5671
5672**返回值:**
5673
5674| 类型                | 说明                      |
5675| ------------------- | ------------------------- |
5676| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
5677
5678**错误码:**
5679
5680以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5681
5682| 错误码ID | 错误信息 |
5683| ------- | ------------------------------ |
5684| 1300002 | This window state is abnormal. |
5685| 1300003 | This window manager service works abnormally. |
5686| 1300004 | Unauthorized operation. |
5687| 1300009 | The parent window is invalid. |
5688
5689**示例:**
5690
5691```ts
5692let enabled = false;
5693let windowClass: window.Window = window.findWindow("test");
5694let promise = windowClass.setRaiseByClickEnabled(enabled);
5695promise.then(()=> {
5696    console.info('Succeeded in disabling the raise-by-click function.');
5697}).catch((err)=>{
5698    console.error('Failed to disable the raise-by-click function. Cause: ' + JSON.stringify(err));
5699});
5700```
5701### minimize<sup>10+</sup>
5702
5703minimize(callback: AsyncCallback&lt;void&gt;): void
5704
5705最小化主窗口。使用callback异步回调。
5706
5707**系统接口:** 此接口为系统接口。
5708
5709**系统能力:** SystemCapability.Window.SessionManager
5710
5711**参数:**
5712
5713| 参数名   | 类型                      | 必填 | 说明       |
5714| -------- | ------------------------- | ---- | ---------- |
5715| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
5716
5717**错误码:**
5718
5719以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5720
5721| 错误码ID | 错误信息 |
5722| ------- | ------------------------------ |
5723| 1300002 | This window state is abnormal. |
5724| 1300003 | This window manager service works abnormally. |
5725
5726**示例:**
5727
5728```ts
5729import UIAbility from '@ohos.app.ability.UIAbility';
5730
5731export default class EntryAbility extends UIAbility {
5732    onWindowStageCreate(windowStage) {
5733        // 为主窗口加载对应的目标页面。
5734        windowStage.loadContent("pages/page2", (err) => {
5735            if (err.code) {
5736                console.error('Failed to load the content. Cause:' + JSON.stringify(err));
5737                return;
5738            }
5739            console.info('Succeeded in loading the content.');
5740        });
5741        // 获取应用主窗口。
5742        let mainWindow = null;
5743
5744        windowStage.getMainWindow((err, data) => {
5745            if (err.code) {
5746                console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
5747                return;
5748            }
5749            mainWindow = data;
5750            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
5751            // 调用minimize接口。
5752            mainWindow.minimize((err) => {
5753                if (err.code) {
5754                    console.error('Failed to minimize the app main window. Cause: ' + JSON.stringify(err));
5755                    return;
5756                }
5757                console.info('Successfully minimized app main window.');
5758            });
5759        })
5760    }
5761};
5762```
5763
5764### minimize<sup>10+</sup>
5765
5766minimize(): Promise&lt;void&gt;
5767
5768最小化主窗口。使用Promise异步回调。
5769
5770**系统接口:** 此接口为系统接口。
5771
5772**系统能力:** SystemCapability.Window.SessionManager
5773
5774**返回值:**
5775
5776| 类型                | 说明                      |
5777| ------------------- | ------------------------- |
5778| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
5779
5780**错误码:**
5781
5782以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5783
5784| 错误码ID | 错误信息 |
5785| ------- | ------------------------------ |
5786| 1300002 | This window state is abnormal. |
5787| 1300003 | This window manager service works abnormally. |
5788
5789**示例:**
5790
5791```ts
5792import UIAbility from '@ohos.app.ability.UIAbility';
5793
5794export default class EntryAbility extends UIAbility {
5795    onWindowStageCreate(windowStage) {
5796        // 为主窗口加载对应的目标页面。
5797        windowStage.loadContent("pages/page2", (err) => {
5798            if (err.code) {
5799                console.error('Failed to load the content. Cause:' + JSON.stringify(err));
5800                return;
5801            }
5802            console.info('Succeeded in loading the content.');
5803        });
5804        // 获取应用主窗口。
5805        let mainWindow = null;
5806
5807        windowStage.getMainWindow((err, data) => {
5808            if (err.code) {
5809                console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
5810                return;
5811            }
5812            mainWindow = data;
5813            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
5814            // 获取minimize接口的promise对象。
5815            let promise = mainWindow.minimize();
5816            promise.then(()=> {
5817                console.info('Successfully minimized app main window.');
5818            }).catch((err)=>{
5819                console.error('Failed to minimize the app main window. Cause: ' + JSON.stringify(err));
5820            });
5821        })
5822    }
5823};
5824```
5825
5826### setResizeByDragEnabled<sup>10+</sup>
5827
5828setResizeByDragEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
5829
5830禁止/使能通过拖拽方式缩放主窗口的功能。使用callback异步回调。
5831
5832**系统接口:** 此接口为系统接口。
5833
5834**系统能力:** SystemCapability.Window.SessionManager
5835
5836**参数:**
5837
5838| 参数名   | 类型                      | 必填 | 说明       |
5839| -------- | ------------------------- | ---- | ---------- |
5840| enable   | boolean                   | 是   | 设置窗口是否使能通过拖拽进行缩放,true表示使能,false表示禁止。 |
5841| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
5842
5843**错误码:**
5844
5845以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5846
5847| 错误码ID | 错误信息 |
5848| ------- | ------------------------------ |
5849| 1300002 | This window state is abnormal. |
5850| 1300003 | This window manager service works abnormally. |
5851| 1300004 | Unauthorized operation. |
5852
5853**示例:**
5854
5855```ts
5856import UIAbility from '@ohos.app.ability.UIAbility';
5857
5858export default class EntryAbility extends UIAbility {
5859    onWindowStageCreate(windowStage) {
5860        // 为主窗口加载对应的目标页面。
5861        windowStage.loadContent("pages/page2", (err) => {
5862            if (err.code) {
5863                console.error('Failed to load the content. Cause:' + JSON.stringify(err));
5864                return;
5865            }
5866            console.info('Succeeded in loading the content.');
5867        });
5868        // 获取应用主窗口。
5869        let mainWindow = null;
5870
5871        windowStage.getMainWindow((err, data) => {
5872            if (err.code) {
5873                console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
5874                return;
5875            }
5876            mainWindow = data;
5877            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
5878
5879            let enabled = false;
5880            // 调用setResizeByDragEnabled接口。
5881            mainWindow.setResizeByDragEnabled(enabled, (err) => {
5882                if (err.code) {
5883                    console.error('Failed to set the function of disabling the resize by dragg window. Cause: ' + JSON.stringify(err));
5884                    return;
5885                }
5886                console.info('Succeeded in setting the function of disabling the resize by dragg window.');
5887            });
5888        })
5889    }
5890};
5891```
5892
5893### setResizeByDragEnabled<sup>10+</sup>
5894
5895setResizeByDragEnabled(enable: boolean): Promise&lt;void&gt;
5896
5897禁止/使能通过拖拽方式缩放主窗口的功能。使用Promise异步回调。
5898
5899**系统接口:** 此接口为系统接口。
5900
5901**系统能力:** SystemCapability.Window.SessionManager
5902
5903**参数:**
5904
5905| 参数名   | 类型                      | 必填 | 说明       |
5906| -------- | ------------------------- | ---- | ---------- |
5907| enable   | boolean                   | 是   | 设置窗口是否使能通过拖拽进行缩放,true表示使能,false表示禁止。 |
5908
5909**返回值:**
5910
5911| 类型                | 说明                      |
5912| ------------------- | ------------------------- |
5913| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
5914
5915**错误码:**
5916
5917以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
5918
5919| 错误码ID | 错误信息 |
5920| ------- | ------------------------------ |
5921| 1300002 | This window state is abnormal. |
5922| 1300003 | This window manager service works abnormally. |
5923
5924**示例:**
5925
5926```ts
5927import UIAbility from '@ohos.app.ability.UIAbility';
5928
5929export default class EntryAbility extends UIAbility {
5930    onWindowStageCreate(windowStage) {
5931        // 为主窗口加载对应的目标页面。
5932        windowStage.loadContent("pages/page2", (err) => {
5933            if (err.code) {
5934                console.error('Failed to load the content. Cause:' + JSON.stringify(err));
5935                return;
5936            }
5937            console.info('Succeeded in loading the content.');
5938        });
5939        // 获取应用主窗口。
5940        let mainWindow = null;
5941
5942        windowStage.getMainWindow((err, data) => {
5943            if (err.code) {
5944                console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
5945                return;
5946            }
5947            mainWindow = data;
5948            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
5949
5950            let enabled = false;
5951            // 获取setResizeByDragEnabled接口的promise对象
5952            let promise = mainWindow.setResizeByDragEnabled(enabled);
5953            promise.then(()=> {
5954                console.info('Succeeded in setting the function of disabling the resize by dragg window.');
5955            }).catch((err)=>{
5956                console.error('Failed to set the function of disabling the resize by dragg window. Cause: ' + JSON.stringify(err));
5957            });
5958        })
5959    }
5960};
5961```
5962
5963### show<sup>(deprecated)</sup>
5964
5965show(callback: AsyncCallback&lt;void&gt;): void
5966
5967显示当前窗口,使用callback异步回调。
5968
5969> **说明:**
5970>
5971> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[showWindow()](#showwindow9)。
5972
5973**系统能力:** SystemCapability.WindowManager.WindowManager.Core
5974
5975**参数:**
5976
5977| 参数名   | 类型                      | 必填 | 说明       |
5978| -------- | ------------------------- | ---- | ---------- |
5979| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
5980
5981**示例:**
5982
5983```ts
5984import { BusinessError } from '@ohos.base';
5985
5986let windowClass: window.Window = window.findWindow("test");
5987windowClass.show((err: BusinessError) => {
5988  const errCode: number = err.code;
5989  if (errCode) {
5990    console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
5991    return;
5992  }
5993  console.info('Succeeded in showing the window.');
5994});
5995```
5996
5997### show<sup>(deprecated)</sup>
5998
5999show(): Promise&lt;void&gt;
6000
6001显示当前窗口,使用Promise异步回调。
6002
6003> **说明:**
6004>
6005> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[showWindow()](#showwindow9-1)。
6006
6007**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6008
6009**返回值:**
6010
6011| 类型                | 说明                      |
6012| ------------------- | ------------------------- |
6013| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
6014
6015**示例:**
6016
6017```ts
6018import { BusinessError } from '@ohos.base';
6019
6020let windowClass: window.Window = window.findWindow("test");
6021let promise = windowClass.show();
6022promise.then(() => {
6023  console.info('Succeeded in showing the window.');
6024}).catch((err: BusinessError) => {
6025  console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
6026});
6027```
6028
6029### destroy<sup>(deprecated)</sup>
6030
6031destroy(callback: AsyncCallback&lt;void&gt;): void
6032
6033销毁当前窗口,使用callback异步回调。
6034
6035> **说明:**
6036>
6037> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[destroyWindow()](#destroywindow9)。
6038
6039**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6040
6041**参数:**
6042
6043| 参数名   | 类型                      | 必填 | 说明       |
6044| -------- | ------------------------- | ---- | ---------- |
6045| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
6046
6047**示例:**
6048
6049```ts
6050import { BusinessError } from '@ohos.base';
6051
6052let windowClass: window.Window = window.findWindow("test");
6053windowClass.destroy((err: BusinessError) => {
6054  const errCode: number = err.code;
6055  if (err.code) {
6056    console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
6057    return;
6058  }
6059  console.info('Succeeded in destroying the window.');
6060});
6061```
6062
6063### destroy<sup>(deprecated)</sup>
6064
6065destroy(): Promise&lt;void&gt;
6066
6067销毁当前窗口,使用Promise异步回调。
6068
6069> **说明:**
6070>
6071> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[destroyWindow()](#destroywindow9-1)。
6072
6073**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6074
6075**返回值:**
6076
6077| 类型                | 说明                      |
6078| ------------------- | ------------------------- |
6079| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
6080
6081**示例:**
6082
6083```ts
6084import { BusinessError } from '@ohos.base';
6085
6086let windowClass: window.Window = window.findWindow("test");
6087let promise = windowClass.destroy();
6088promise.then(() => {
6089  console.info('Succeeded in destroying the window.');
6090}).catch((err: BusinessError) => {
6091  console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
6092});
6093```
6094
6095### moveTo<sup>(deprecated)</sup>
6096
6097moveTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void
6098
6099移动窗口位置,使用callback异步回调。
6100
6101全屏模式窗口不支持该操作。
6102
6103> **说明:**
6104>
6105> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[moveWindowTo()](#movewindowto9)。
6106
6107**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6108
6109**参数:**
6110
6111| 参数名   | 类型                      | 必填 | 说明                                              |
6112| -------- | ------------------------- | ---- | ------------------------------------------------- |
6113| x        | number                    | 是   | 窗口在x轴方向移动的值,值为正表示右移,单位为px,该参数仅支持整数输入。 |
6114| y        | number                    | 是   | 窗口在y轴方向移动的值,值为正表示下移,单位为px,该参数仅支持整数输入。 |
6115| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                        |
6116
6117**示例:**
6118
6119```ts
6120import { BusinessError } from '@ohos.base';
6121
6122let windowClass: window.Window = window.findWindow("test");
6123windowClass.moveTo(300, 300, (err: BusinessError) => {
6124  const errCode: number = err.code;
6125  if (errCode) {
6126    console.error('Failed to move the window. Cause:' + JSON.stringify(err));
6127    return;
6128  }
6129  console.info('Succeeded in moving the window.');
6130});
6131```
6132
6133### moveTo<sup>(deprecated)</sup>
6134
6135moveTo(x: number, y: number): Promise&lt;void&gt;
6136
6137移动窗口位置,使用Promise异步回调。
6138
6139全屏模式窗口不支持该操作。
6140
6141> **说明:**
6142>
6143> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[moveWindowTo()](#movewindowto9-1)。
6144
6145**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6146
6147**参数:**
6148
6149| 参数名 | 类型   | 必填 | 说明                                              |
6150| ------ | ------ | ---- | ------------------------------------------------- |
6151| x      | number | 是   | 窗口在x轴方向移动的值,值为正表示右移,单位为px,该参数仅支持整数输入。 |
6152| y      | number | 是   | 窗口在y轴方向移动的值,值为正表示下移,单位为px,该参数仅支持整数输入。 |
6153
6154**返回值:**
6155
6156| 类型                | 说明                      |
6157| ------------------- | ------------------------- |
6158| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
6159
6160**示例:**
6161
6162```ts
6163import { BusinessError } from '@ohos.base';
6164
6165let windowClass: window.Window = window.findWindow("test");
6166let promise = windowClass.moveTo(300, 300);
6167promise.then(() => {
6168  console.info('Succeeded in moving the window.');
6169}).catch((err: BusinessError) => {
6170  console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
6171});
6172```
6173
6174### resetSize<sup>(deprecated)</sup>
6175
6176resetSize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void
6177
6178改变当前窗口大小,使用callback异步回调。
6179
6180应用主窗口与子窗口存在大小限制,宽度范围:[320, 2560],高度范围:[240, 2560],单位为vp。
6181
6182系统窗口存在大小限制,宽度范围:[0, 2560],高度范围:[0, 2560],单位为vp。
6183
6184设置的宽度与高度受到此约束限制。
6185
6186全屏模式窗口不支持该操作。
6187
6188> **说明:**
6189>
6190> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9)。
6191
6192**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6193
6194**参数:**
6195
6196| 参数名   | 类型                      | 必填 | 说明                       |
6197| -------- | ------------------------- | ---- | -------------------------- |
6198| width    | number                    | 是   | 目标窗口的宽度,单位为px,该参数仅支持整数输入。 |
6199| height   | number                    | 是   | 目标窗口的高度,单位为px,该参数仅支持整数输入。 |
6200| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。                 |
6201
6202**示例:**
6203
6204```ts
6205import { BusinessError } from '@ohos.base';
6206
6207let windowClass: window.Window = window.findWindow("test");
6208windowClass.resetSize(500, 1000, (err: BusinessError) => {
6209  const errCode: number = err.code;
6210  if (errCode) {
6211    console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
6212    return;
6213  }
6214  console.info('Succeeded in changing the window size.');
6215});
6216```
6217
6218### resetSize<sup>(deprecated)</sup>
6219
6220resetSize(width: number, height: number): Promise&lt;void&gt;
6221
6222改变当前窗口大小,使用Promise异步回调。
6223
6224应用主窗口与子窗口存在大小限制,宽度范围:[320, 2560],高度范围:[240, 2560],单位为vp。
6225
6226系统窗口存在大小限制,宽度范围:[0, 2560],高度范围:[0, 2560],单位为vp。
6227
6228设置的宽度与高度受到此约束限制。
6229
6230全屏模式窗口不支持该操作。
6231
6232> **说明:**
6233>
6234> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9-1)。
6235
6236**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6237
6238**参数:**
6239
6240| 参数名 | 类型   | 必填 | 说明                       |
6241| ------ | ------ | ---- | -------------------------- |
6242| width  | number | 是   | 目标窗口的宽度,单位为px,该参数仅支持整数输入。 |
6243| height | number | 是   | 目标窗口的高度,单位为px,该参数仅支持整数输入。 |
6244
6245**返回值:**
6246
6247| 类型                | 说明                      |
6248| ------------------- | ------------------------- |
6249| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
6250
6251**示例:**
6252
6253```ts
6254import { BusinessError } from '@ohos.base';
6255
6256let windowClass: window.Window = window.findWindow("test");
6257let promise = windowClass.resetSize(500, 1000);
6258promise.then(() => {
6259  console.info('Succeeded in changing the window size.');
6260}).catch((err: BusinessError) => {
6261  console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
6262});
6263```
6264
6265### setWindowType<sup>(deprecated)</sup>
6266
6267setWindowType(type: WindowType, callback: AsyncCallback&lt;void&gt;): void
6268
6269设置窗口类型,使用callback异步回调。
6270
6271**系统接口:** 此接口为系统接口。
6272
6273> **说明:**
6274>
6275> 从 API version 7开始支持,从API version 9开始废弃。
6276
6277**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6278
6279**参数:**
6280
6281| 参数名   | 类型                      | 必填 | 说明       |
6282| -------- | ------------------------- | ---- | ---------- |
6283| type     | [WindowType](#windowtype7) | 是   | 窗口类型。 |
6284| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
6285
6286**示例:**
6287
6288```ts
6289import { BusinessError } from '@ohos.base';
6290
6291let windowClass: window.Window = window.findWindow("test");
6292let type = window.WindowType.TYPE_APP;
6293windowClass.setWindowType(type, (err: BusinessError) => {
6294  const errCode: number = err.code;
6295  if (errCode) {
6296    console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
6297    return;
6298  }
6299  console.info('Succeeded in setting the window type.');
6300});
6301```
6302
6303### setWindowType<sup>(deprecated)</sup>
6304
6305setWindowType(type: WindowType): Promise&lt;void&gt;
6306
6307设置窗口类型,使用Promise异步回调。
6308
6309**系统接口:** 此接口为系统接口。
6310
6311> **说明:**
6312>
6313> 从 API version 7开始支持,从API version 9开始废弃。
6314
6315**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6316
6317**参数:**
6318
6319| 参数名 | 类型                      | 必填 | 说明       |
6320| ------ | ------------------------- | ---- | ---------- |
6321| type   | [WindowType](#windowtype7) | 是   | 窗口类型。 |
6322
6323**返回值:**
6324
6325| 类型                | 说明                      |
6326| ------------------- | ------------------------- |
6327| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
6328
6329**示例:**
6330
6331```ts
6332import { BusinessError } from '@ohos.base';
6333
6334let windowClass: window.Window = window.findWindow("test");
6335let type = window.WindowType.TYPE_APP;
6336let promise = windowClass.setWindowType(type);
6337promise.then(() => {
6338  console.info('Succeeded in setting the window type.');
6339}).catch((err: BusinessError) => {
6340  console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
6341});
6342```
6343
6344### getProperties<sup>(deprecated)</sup>
6345
6346getProperties(callback: AsyncCallback&lt;WindowProperties&gt;): void
6347
6348获取当前窗口的属性,使用callback异步回调,返回WindowProperties。
6349
6350> **说明:**
6351>
6352> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowproperties9)。
6353
6354**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6355
6356**参数:**
6357
6358| 参数名   | 类型                                                       | 必填 | 说明                         |
6359| -------- | ---------------------------------------------------------- | ---- | ---------------------------- |
6360| callback | AsyncCallback&lt;[WindowProperties](#windowproperties)&gt; | 是   | 回调函数。返回当前窗口属性。 |
6361
6362**示例:**
6363
6364```ts
6365import { BusinessError } from '@ohos.base';
6366
6367let windowClass: window.Window = window.findWindow("test");
6368windowClass.getProperties((err: BusinessError, data) => {
6369  const errCode: number = err.code;
6370  if (errCode) {
6371    console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
6372    return;
6373  }
6374  console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
6375});
6376```
6377
6378### getProperties<sup>(deprecated)</sup>
6379
6380getProperties(): Promise&lt;WindowProperties&gt;
6381
6382获取当前窗口的属性,使用Promise异步回调,返回WindowProperties。
6383
6384> **说明:**
6385>
6386> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowproperties9)。
6387
6388**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6389
6390**返回值:**
6391
6392| 类型                                                 | 说明                            |
6393| ---------------------------------------------------- | ------------------------------- |
6394| Promise&lt;[WindowProperties](#windowproperties)&gt; | Promise对象。返回当前窗口属性。 |
6395
6396**示例:**
6397
6398```ts
6399import { BusinessError } from '@ohos.base';
6400
6401let windowClass: window.Window = window.findWindow("test");
6402let promise = windowClass.getProperties();
6403promise.then((data) => {
6404  console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
6405}).catch((err: BusinessError) => {
6406  console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
6407});
6408```
6409
6410### getAvoidArea<sup>(deprecated)</sup>
6411
6412getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt;): void
6413
6414获取窗口内容规避的区域;如系统栏区域、刘海屏区域、手势区域、软键盘区域等与窗口内容重叠时,需要窗口内容避让的区域。
6415
6416> **说明:**
6417>
6418> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowAvoidArea()](#getwindowavoidarea9)。
6419
6420**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6421
6422**参数:**
6423
6424| 参数名   | 类型                                            | 必填 | 说明                                                         |
6425| -------- |-----------------------------------------------| ---- | ------------------------------------------------------------ |
6426| type     | [AvoidAreaType](#avoidareatype7)              | 是   | 表示规避区类型。|
6427| callback | AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt; | 是   | 回调函数。返回窗口内容规避区域。                             |
6428
6429**示例:**
6430
6431```ts
6432import { BusinessError } from '@ohos.base';
6433
6434let windowClass: window.Window = window.findWindow("test");
6435let type = window.AvoidAreaType.TYPE_SYSTEM;
6436windowClass.getAvoidArea(type, (err: BusinessError, data) => {
6437  const errCode: number = err.code;
6438  if (errCode) {
6439    console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
6440    return;
6441  }
6442  console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
6443});
6444```
6445
6446### getAvoidArea<sup>(deprecated)</sup>
6447
6448getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise&lt;[AvoidArea](#avoidarea7)&gt;
6449
6450获取窗口内容规避的区域;如系统栏区域、刘海屏区域、手势区域、软键盘区域等与窗口内容重叠时,需要窗口内容避让的区域。
6451
6452> **说明:**
6453>
6454> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowAvoidArea()](#getwindowavoidarea9)。
6455
6456**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6457
6458**参数:**
6459
6460| 参数名 | 类型                               | 必填 | 说明                                                         |
6461| ------ |----------------------------------| ---- | ------------------------------------------------------------ |
6462| type   | [AvoidAreaType](#avoidareatype7) | 是   | 表示规避区类型。 |
6463
6464**返回值:**
6465
6466| 类型                                      | 说明                                |
6467|-----------------------------------------| ----------------------------------- |
6468| Promise&lt;[AvoidArea](#avoidarea7)&gt; | Promise对象。返回窗口内容规避区域。 |
6469
6470**示例:**
6471
6472```ts
6473import { BusinessError } from '@ohos.base';
6474
6475let windowClass: window.Window = window.findWindow("test");
6476let type = window.AvoidAreaType.TYPE_SYSTEM;
6477let promise = windowClass.getAvoidArea(type);
6478promise.then((data) => {
6479  console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
6480}).catch((err: BusinessError) => {
6481  console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
6482});
6483```
6484
6485### setFullScreen<sup>(deprecated)</sup>
6486
6487setFullScreen(isFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void
6488
6489设置窗口的布局是否为全屏布局,使用callback异步回调。
6490全屏布局是指窗口大小为全屏幕,状态栏与导航栏不显示。
6491非全屏布局是指状态栏与导航栏显示,窗口大小避让状态栏与导航栏位置。
6492
6493> **说明:**
6494>
6495> 从 API version 6开始支持,从API version 9开始废弃,推荐联合使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)和[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9)实现全屏。
6496
6497**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6498
6499**参数:**
6500
6501| 参数名       | 类型                      | 必填 | 说明                                           |
6502| ------------ | ------------------------- | ---- | ---------------------------------------------- |
6503| isFullScreen | boolean                   | 是   | 是否设为全屏布局(该全屏布局影响状态栏导航栏显示)。true表示全屏;false表示非全屏。 |
6504| callback     | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                     |
6505
6506**示例:**
6507
6508```ts
6509import { BusinessError } from '@ohos.base';
6510
6511let windowClass: window.Window = window.findWindow("test");
6512let isFullScreen: boolean = true;
6513windowClass.setFullScreen(isFullScreen, (err: BusinessError) => {
6514  const errCode: number = err.code;
6515  if (errCode) {
6516    console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
6517    return;
6518  }
6519  console.info('Succeeded in enabling the full-screen mode.');
6520});
6521```
6522
6523### setFullScreen<sup>(deprecated)</sup>
6524
6525setFullScreen(isFullScreen: boolean): Promise&lt;void&gt;
6526
6527设置窗口的布局是否为全屏布局,使用Promise异步回调。
6528全屏布局是指窗口大小为全屏幕,状态栏与导航栏不显示。
6529非全屏布局是指状态栏与导航栏显示,窗口大小避让状态栏与导航栏位置。
6530
6531> **说明:**
6532>
6533> 从 API version 6开始支持,从API version 9开始废弃,推荐联合使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)和[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9-1)实现全屏。
6534
6535**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6536
6537**参数:**
6538
6539| 参数名       | 类型    | 必填 | 说明                                           |
6540| ------------ | ------- | ---- | ---------------------------------------------- |
6541| isFullScreen | boolean | 是   | 是否设为全屏布局(该全屏布局影响状态栏导航栏显示)。true表示全屏;false表示非全屏。 |
6542
6543**返回值:**
6544
6545| 类型                | 说明                      |
6546| ------------------- | ------------------------- |
6547| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
6548
6549**示例:**
6550
6551```ts
6552import { BusinessError } from '@ohos.base';
6553
6554let windowClass: window.Window = window.findWindow("test");
6555let isFullScreen: boolean = true;
6556let promise = windowClass.setFullScreen(isFullScreen);
6557promise.then(() => {
6558  console.info('Succeeded in enabling the full-screen mode.');
6559}).catch((err: BusinessError) => {
6560  console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
6561});
6562```
6563
6564### setLayoutFullScreen<sup>(deprecated)</sup>
6565
6566setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void
6567
6568设置窗口的布局是否为沉浸式布局,使用callback异步回调。
6569沉浸式布局是指布局不避让状态栏与导航栏,组件可能产生与其重叠的情况。
6570非沉浸式布局是指布局避让状态栏与导航栏,组件不会与其重叠。
6571
6572> **说明:**
6573>
6574> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9)。
6575
6576**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6577
6578**参数:**
6579
6580| 参数名             | 类型                      | 必填 | 说明                                                         |
6581| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ |
6582| isLayoutFullScreen | boolean                   | 是   | 窗口的布局是否为沉浸式布局(该沉浸式布局不影响状态栏、导航栏显示)。true表示沉浸式布局;false表示非沉浸式布局。 |
6583| callback           | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                                   |
6584
6585**示例:**
6586
6587```ts
6588import { BusinessError } from '@ohos.base';
6589
6590let windowClass: window.Window = window.findWindow("test");
6591let isLayoutFullScreen: boolean = true;
6592windowClass.setLayoutFullScreen(isLayoutFullScreen, (err: BusinessError) => {
6593  const errCode: number = err.code;
6594  if (errCode) {
6595    console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
6596    return;
6597  }
6598  console.info('Succeeded in setting the window layout to full-screen mode.');
6599});
6600```
6601
6602### setLayoutFullScreen<sup>(deprecated)</sup>
6603
6604setLayoutFullScreen(isLayoutFullScreen: boolean): Promise&lt;void&gt;
6605
6606设置窗口的布局是否为沉浸式布局,使用Promise异步回调。
6607沉浸式布局是指布局不避让状态栏与导航栏,组件可能产生与其重叠的情况。
6608非沉浸式布局是指布局避让状态栏与导航栏,组件不会与其重叠。
6609
6610> **说明:**
6611>
6612> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9-1)。
6613
6614**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6615
6616**参数:**
6617
6618| 参数名             | 类型    | 必填 | 说明                                                         |
6619| ------------------ | ------- | ---- | ------------------------------------------------------------ |
6620| isLayoutFullScreen | boolean | 是   | 窗口的布局是否为沉浸式布局(该沉浸式布局不影响状态栏、导航栏显示)。true表示沉浸式布局;false表示非沉浸式布局。 |
6621
6622**返回值:**
6623
6624| 类型                | 说明                      |
6625| ------------------- | ------------------------- |
6626| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
6627
6628**示例:**
6629
6630```ts
6631import { BusinessError } from '@ohos.base';
6632
6633let windowClass: window.Window = window.findWindow("test");
6634let isLayoutFullScreen: boolean = true;
6635let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen);
6636promise.then(() => {
6637  console.info('Succeeded in setting the window layout to full-screen mode.');
6638}).catch((err: BusinessError) => {
6639  console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
6640});
6641```
6642
6643### setSystemBarEnable<sup>(deprecated)</sup>
6644
6645setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback&lt;void&gt;): void
6646
6647设置窗口全屏模式时导航栏、状态栏的可见模式,使用callback异步回调。
6648
6649> **说明:**
6650>
6651> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)。
6652
6653**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6654
6655**参数:**
6656
6657| 参数名   | 类型                      | 必填 | 说明                                                         |
6658| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
6659| names    | Array<'status'\|'navigation'> | 是   | 设置窗口全屏模式时状态栏和导航栏是否显示。<br>例如,需全部显示,该参数设置为['status',&nbsp;'navigation'];不设置,则默认不显示。 |
6660| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                                   |
6661
6662**示例:**
6663
6664```ts
6665// 此处以不显示导航栏、状态栏为例
6666import { BusinessError } from '@ohos.base';
6667
6668let windowClass: window.Window = window.findWindow("test");
6669let names: Array<'status' | 'navigation'> = [];
6670windowClass.setSystemBarEnable(names, (err: BusinessError) => {
6671  const errCode: number = err.code;
6672  if (errCode) {
6673    console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
6674    return;
6675  }
6676  console.info('Succeeded in setting the system bar to be invisible.');
6677});
6678```
6679
6680### setSystemBarEnable<sup>(deprecated)</sup>
6681
6682setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt;
6683
6684设置窗口全屏模式时导航栏、状态栏的可见模式,使用Promise异步回调。
6685
6686> **说明:**
6687>
6688> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)。
6689
6690**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6691
6692**参数:**
6693
6694| 参数名 | 类型  | 必填 | 说明                                                         |
6695| ------ | ---------------------------- | ---- | ------------------------ |
6696| names  | Array<'status'\|'navigation'> | 是   | 设置窗口全屏模式时状态栏和导航栏是否显示。<br>例如,需全部显示,该参数设置为['status',&nbsp;'navigation'];不设置,则默认不显示。 |
6697
6698**返回值:**
6699
6700| 类型                | 说明                      |
6701| ------------------- | ------------------------- |
6702| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
6703
6704**示例:**
6705
6706```ts
6707// 此处以不显示导航栏、状态栏为例
6708import { BusinessError } from '@ohos.base';
6709
6710let windowClass: window.Window = window.findWindow("test");
6711let names: Array<'status' | 'navigation'> = [];
6712let promise = windowClass.setSystemBarEnable(names);
6713promise.then(() => {
6714  console.info('Succeeded in setting the system bar to be invisible.');
6715}).catch((err: BusinessError) => {
6716  console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
6717});
6718```
6719
6720### setSystemBarProperties<sup>(deprecated)</sup>
6721
6722setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback&lt;void&gt;): void
6723
6724设置窗口全屏模式时窗口内导航栏、状态栏的属性,使用callback异步回调。
6725
6726> **说明:**
6727>
6728> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9)。
6729
6730**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6731
6732**参数:**
6733
6734| 参数名              | 类型                                        | 必填 | 说明                   |
6735| ------------------- | ------------------------------------------- | ---- | ---------------------- |
6736| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是   | 导航栏、状态栏的属性。 |
6737| callback            | AsyncCallback&lt;void&gt;                   | 是   | 回调函数。             |
6738
6739**示例:**
6740
6741```ts
6742import { BusinessError } from '@ohos.base';
6743
6744let SystemBarProperties: window.SystemBarProperties = {
6745  statusBarColor: '#ff00ff',
6746  navigationBarColor: '#00ff00',
6747  //以下两个属性从API Version8开始支持
6748  statusBarContentColor: '#ffffff',
6749  navigationBarContentColor: '#00ffff'
6750};
6751let windowClass: window.Window = window.findWindow("test");
6752windowClass.setSystemBarProperties(SystemBarProperties, (err) => {
6753  const errCode: number = err.code;
6754  if (errCode) {
6755    console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
6756    return;
6757  }
6758  console.info('Succeeded in setting the system bar properties.');
6759});
6760```
6761
6762### setSystemBarProperties<sup>(deprecated)</sup>
6763
6764setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise&lt;void&gt;
6765
6766设置窗口全屏模式时窗口内导航栏、状态栏的属性,使用Promise异步回调。
6767
6768> **说明:**
6769>
6770> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9-1)。
6771
6772**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6773
6774**参数:**
6775
6776| 参数名              | 类型                                        | 必填 | 说明                   |
6777| ------------------- | ------------------------------------------- | ---- | ---------------------- |
6778| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是   | 导航栏、状态栏的属性。 |
6779
6780**返回值:**
6781
6782| 类型                | 说明                      |
6783| ------------------- | ------------------------- |
6784| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
6785
6786**示例:**
6787
6788```ts
6789import { BusinessError } from '@ohos.base';
6790
6791let SystemBarProperties: window.SystemBarProperties = {
6792  statusBarColor: '#ff00ff',
6793  navigationBarColor: '#00ff00',
6794  //以下两个属性从API Version8开始支持
6795  statusBarContentColor: '#ffffff',
6796  navigationBarContentColor: '#00ffff'
6797};
6798let windowClass: window.Window = window.findWindow("test");
6799let promise = windowClass.setSystemBarProperties(SystemBarProperties);
6800promise.then(() => {
6801  console.info('Succeeded in setting the system bar properties.');
6802}).catch((err: BusinessError) => {
6803  console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
6804});
6805```
6806
6807### loadContent<sup>(deprecated)</sup>
6808
6809loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void
6810
6811为当前窗口加载具体页面内容,使用callback异步回调。
6812
6813> **说明:**
6814>
6815> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setUIContent()](#setuicontent9)。
6816
6817**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6818
6819**参数:**
6820
6821| 参数名   | 类型                      | 必填 | 说明                 |
6822| -------- | ------------------------- | ---- | -------------------- |
6823| path     | string                    | 是   | 设置加载页面的路径。 |
6824| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
6825
6826**示例:**
6827
6828```ts
6829import { BusinessError } from '@ohos.base';
6830
6831let windowClass: window.Window = window.findWindow("test");
6832windowClass.loadContent('pages/page2/page2', (err: BusinessError) => {
6833  const errCode: number = err.code;
6834  if (errCode) {
6835    console.error('Failed to load the content. Cause:' + JSON.stringify(err));
6836    return;
6837  }
6838  console.info('Succeeded in loading the content.');
6839});
6840```
6841
6842### loadContent<sup>(deprecated)</sup>
6843
6844loadContent(path: string): Promise&lt;void&gt;
6845
6846为当前窗口加载具体页面内容,使用Promise异步回调。
6847
6848> **说明:**
6849>
6850> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setUIContent()](#setuicontent9-1)。
6851
6852**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6853
6854**参数:**
6855
6856| 参数名 | 类型   | 必填 | 说明                 |
6857| ------ | ------ | ---- | -------------------- |
6858| path   | string | 是   | 设置加载页面的路径。 |
6859
6860**返回值:**
6861
6862| 类型                | 说明                      |
6863| ------------------- | ------------------------- |
6864| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
6865
6866**示例:**
6867
6868```ts
6869import { BusinessError } from '@ohos.base';
6870
6871let windowClass: window.Window = window.findWindow("test");
6872let promise = windowClass.loadContent('pages/page2/page2');
6873promise.then(() => {
6874  console.info('Succeeded in loading the content.');
6875}).catch((err: BusinessError) => {
6876  console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
6877});
6878```
6879
6880### isShowing<sup>(deprecated)</sup>
6881
6882isShowing(callback: AsyncCallback&lt;boolean&gt;): void
6883
6884判断当前窗口是否已显示,使用callback异步回调。
6885
6886> **说明:**
6887>
6888> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[isWindowShowing()](#iswindowshowing9)。
6889
6890**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6891
6892**参数:**
6893
6894| 参数名   | 类型                         | 必填 | 说明                                                         |
6895| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
6896| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示当前窗口已显示,返回false表示当前窗口未显示。 |
6897
6898**示例:**
6899
6900```ts
6901import { BusinessError } from '@ohos.base';
6902
6903let windowClass: window.Window = window.findWindow("test");
6904windowClass.isShowing((err: BusinessError, data) => {
6905  const errCode: number = err.code;
6906  if (errCode) {
6907    console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err));
6908    return;
6909  }
6910  console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
6911});
6912```
6913
6914### isShowing<sup>(deprecated)</sup>
6915
6916isShowing(): Promise&lt;boolean&gt;
6917
6918判断当前窗口是否已显示,使用Promise异步回调。
6919
6920> **说明:**
6921>
6922> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[isWindowShowing()](#iswindowshowing9)。
6923
6924**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6925
6926**返回值:**
6927
6928| 类型                   | 说明                                                         |
6929| ---------------------- | ------------------------------------------------------------ |
6930| Promise&lt;boolean&gt; | Promise对象。返回true表示当前窗口已显示,返回false表示当前窗口未显示。 |
6931
6932**示例:**
6933
6934```ts
6935import { BusinessError } from '@ohos.base';
6936
6937let windowClass: window.Window = window.findWindow("test");
6938let promise = windowClass.isShowing();
6939promise.then((data) => {
6940  console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
6941}).catch((err: BusinessError) => {
6942  console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err));
6943});
6944```
6945
6946### on('systemAvoidAreaChange')<sup>(deprecated)</sup>
6947
6948on(type: 'systemAvoidAreaChange', callback: Callback&lt;AvoidArea&gt;): void
6949
6950开启系统规避区变化的监听。
6951
6952> **说明:**
6953>
6954> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[on('avoidAreaChange')](#onavoidareachange9)。
6955
6956**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6957
6958**参数:**
6959
6960| 参数名   | 类型                                       | 必填 | 说明                                                    |
6961| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
6962| type     | string                                   | 是   | 监听事件,固定为'systemAvoidAreaChange',即系统规避区变化事件。 |
6963| callback | Callback&lt;[AvoidArea](#avoidarea7)&gt; | 是   | 回调函数。返回当前规避区。                             |
6964
6965**示例:**
6966
6967```ts
6968let windowClass: window.Window = window.findWindow("test");
6969windowClass.on('systemAvoidAreaChange', (data) => {
6970  console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
6971});
6972```
6973
6974### off('systemAvoidAreaChange')<sup>(deprecated)</sup>
6975
6976off(type: 'systemAvoidAreaChange', callback?: Callback&lt;AvoidArea&gt;): void
6977
6978关闭系统规避区变化的监听。
6979
6980> **说明:**
6981>
6982> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[off('avoidAreaChange')](#offavoidareachange9)。
6983
6984**系统能力:** SystemCapability.WindowManager.WindowManager.Core
6985
6986**参数:**
6987
6988| 参数名   | 类型                                       | 必填 | 说明                                                    |
6989| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
6990| type     | string                                   | 是   | 监听事件,固定为'systemAvoidAreaChange',即系统规避区变化事件。 |
6991| callback | Callback&lt;[AvoidArea](#avoidarea7)&gt; | 否   | 回调函数。返回当前规避区。若传入参数,则关闭该监听。若未传入参数,则关闭所有系统规避区变化的监听。           |
6992
6993**示例:**
6994
6995```ts
6996let windowClass: window.Window = window.findWindow("test");
6997windowClass.off('systemAvoidAreaChange');
6998```
6999
7000### isSupportWideGamut<sup>(deprecated)</sup>
7001
7002isSupportWideGamut(callback: AsyncCallback&lt;boolean&gt;): void
7003
7004判断当前窗口是否支持广色域模式,使用callback异步回调。
7005
7006> **说明:**
7007>
7008> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[isWindowSupportWideGamut()](#iswindowsupportwidegamut9)。
7009
7010**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7011
7012**参数:**
7013
7014| 参数名   | 类型                         | 必填 | 说明                                                         |
7015| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
7016| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示当前窗口支持广色域模式,返回false表示当前窗口不支持广色域模式。 |
7017
7018**示例:**
7019
7020```ts
7021import { BusinessError } from '@ohos.base';
7022
7023let windowClass: window.Window = window.findWindow("test");
7024windowClass.isSupportWideGamut((err: BusinessError, data) => {
7025  const errCode: number = err.code;
7026  if (errCode) {
7027    console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err));
7028    return;
7029  }
7030  console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
7031});
7032```
7033
7034### isSupportWideGamut<sup>(deprecated)</sup>
7035
7036isSupportWideGamut(): Promise&lt;boolean&gt;
7037
7038判断当前窗口是否支持广色域模式,使用Promise异步回调。
7039
7040> **说明:**
7041>
7042> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[isWindowSupportWideGamut()](#iswindowsupportwidegamut9-1)。
7043
7044**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7045
7046**返回值:**
7047
7048| 类型                   | 说明                                                         |
7049| ---------------------- | ------------------------------------------------------------ |
7050| Promise&lt;boolean&gt; | Promise对象。返回true表示当前窗口支持广色域模式,返回false表示当前窗口不支持广色域模式。 |
7051
7052**示例:**
7053
7054```ts
7055import { BusinessError } from '@ohos.base';
7056
7057let windowClass: window.Window = window.findWindow("test");
7058let promise = windowClass.isSupportWideGamut();
7059promise.then((data) => {
7060  console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
7061}).catch((err: BusinessError) => {
7062  console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
7063});
7064```
7065
7066### setColorSpace<sup>(deprecated)</sup>
7067
7068setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback&lt;void&gt;): void
7069
7070设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。
7071
7072> **说明:**
7073>
7074> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[setWindowColorSpace()](#setwindowcolorspace9)。
7075
7076**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7077
7078**参数:**
7079
7080| 参数名     | 类型                      | 必填 | 说明         |
7081| ---------- | ------------------------- | ---- | ------------ |
7082| colorSpace | [ColorSpace](#colorspace8) | 是   | 设置色域模式。 |
7083| callback   | AsyncCallback&lt;void&gt; | 是   | 回调函数。   |
7084
7085**示例:**
7086
7087```ts
7088import { BusinessError } from '@ohos.base';
7089
7090let windowClass: window.Window = window.findWindow("test");
7091windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err: BusinessError) => {
7092  const errCode: number = err.code;
7093  if (errCode) {
7094    console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err));
7095    return;
7096  }
7097  console.info('Succeeded in setting window colorspace.');
7098});
7099```
7100
7101### setColorSpace<sup>(deprecated)</sup>
7102
7103setColorSpace(colorSpace:ColorSpace): Promise&lt;void&gt;
7104
7105设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。
7106
7107> **说明:**
7108>
7109> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[setWindowColorSpace()](#setwindowcolorspace9-1)。
7110
7111**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7112
7113**参数:**
7114
7115| 参数名     | 类型                      | 必填 | 说明           |
7116| ---------- | ------------------------- | ---- | -------------- |
7117| colorSpace | [ColorSpace](#colorspace8) | 是   | 设置色域模式。 |
7118
7119**返回值:**
7120
7121| 类型                | 说明                      |
7122| ------------------- | ------------------------- |
7123| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
7124
7125**示例:**
7126
7127```ts
7128import { BusinessError } from '@ohos.base';
7129
7130let windowClass: window.Window = window.findWindow("test");
7131let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT);
7132promise.then(() => {
7133  console.info('Succeeded in setting window colorspace.');
7134}).catch((err: BusinessError) => {
7135  console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
7136});
7137```
7138
7139### getColorSpace<sup>(deprecated)</sup>
7140
7141getColorSpace(callback: AsyncCallback&lt;ColorSpace&gt;): void
7142
7143获取当前窗口色域模式,使用callback异步回调。
7144
7145> **说明:**
7146>
7147> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getWindowColorSpace()](#getwindowcolorspace9)。
7148
7149**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7150
7151**参数:**
7152
7153| 参数名   | 类型                                           | 必填 | 说明                                                       |
7154| -------- | ---------------------------------------------- | ---- | ---------------------------------------------------------- |
7155| callback | AsyncCallback&lt;[ColorSpace](#colorspace8)&gt; | 是   | 回调函数。当获取成功,err为undefined,data为当前色域模式。 |
7156
7157**示例:**
7158
7159```ts
7160import { BusinessError } from '@ohos.base';
7161
7162let windowClass: window.Window = window.findWindow("test");
7163windowClass.getColorSpace((err: BusinessError, data) => {
7164  const errCode: number = err.code;
7165  if (errCode) {
7166    console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err));
7167    return;
7168  }
7169  console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data));
7170});
7171```
7172
7173### getColorSpace<sup>(deprecated)</sup>
7174
7175getColorSpace(): Promise&lt;ColorSpace&gt;
7176
7177获取当前窗口色域模式,使用Promise异步回调。
7178
7179> **说明:**
7180>
7181> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getWindowColorSpace()](#getwindowcolorspace9)。
7182
7183**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7184
7185**返回值:**
7186
7187| 类型                                     | 说明                            |
7188| ---------------------------------------- | ------------------------------- |
7189| Promise&lt;[ColorSpace](#colorspace8)&gt; | Promise对象。返回当前色域模式。 |
7190
7191**示例:**
7192
7193```ts
7194import { BusinessError } from '@ohos.base';
7195
7196let windowClass: window.Window = window.findWindow("test");
7197let promise = windowClass.getColorSpace();
7198promise.then((data) => {
7199  console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data));
7200}).catch((err: BusinessError) => {
7201  console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err));
7202});
7203```
7204
7205### setBackgroundColor<sup>(deprecated)</sup>
7206
7207setBackgroundColor(color: string, callback: AsyncCallback&lt;void&gt;): void
7208
7209设置窗口的背景色,使用callback异步回调。Stage模型下,该接口需要在[loadContent()](#loadcontent9)或[setUIContent()](#setuicontent9)调用生效后使用。
7210
7211> **说明:**
7212>
7213> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBackgroundColor()](#setwindowbackgroundcolor9)。
7214
7215**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7216
7217**参数:**
7218
7219| 参数名   | 类型                      | 必填 | 说明                                                         |
7220| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
7221| color    | string                    | 是   | 需要设置的背景色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 |
7222| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                                   |
7223
7224**示例:**
7225
7226```ts
7227import { BusinessError } from '@ohos.base';
7228
7229let windowClass: window.Window = window.findWindow("test");
7230let color: string = '#00ff33';
7231windowClass.setBackgroundColor(color, (err: BusinessError) => {
7232  const errCode: number = err.code;
7233  if (errCode) {
7234    console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
7235    return;
7236  }
7237  console.info('Succeeded in setting the background color.');
7238});
7239```
7240
7241### setBackgroundColor<sup>(deprecated)</sup>
7242
7243setBackgroundColor(color: string): Promise&lt;void&gt;
7244
7245设置窗口的背景色,使用Promise异步回调。Stage模型下,该接口需要在[loadContent()](#loadcontent9)或[setUIContent()](#setuicontent9)调用生效后使用。
7246
7247> **说明:**
7248>
7249> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBackgroundColor()](#setwindowbackgroundcolor9)。
7250
7251**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7252
7253**参数:**
7254
7255| 参数名 | 类型   | 必填 | 说明                                                         |
7256| ------ | ------ | ---- | ------------------------------------------------------------ |
7257| color  | string | 是   | 需要设置的背景色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 |
7258
7259**返回值:**
7260
7261| 类型                | 说明                      |
7262| ------------------- | ------------------------- |
7263| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
7264
7265**示例:**
7266
7267```ts
7268import { BusinessError } from '@ohos.base';
7269
7270let windowClass: window.Window = window.findWindow("test");
7271let color: string = '#00ff33';
7272let promise = windowClass.setBackgroundColor(color);
7273promise.then(() => {
7274  console.info('Succeeded in setting the background color.');
7275}).catch((err: BusinessError) => {
7276  console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
7277});
7278```
7279
7280### setBrightness<sup>(deprecated)</sup>
7281
7282setBrightness(brightness: number, callback: AsyncCallback&lt;void&gt;): void
7283
7284设置屏幕亮度值,使用callback异步回调。
7285
7286当前屏幕亮度规格:窗口设置屏幕亮度生效时,控制中心不可以调整系统屏幕亮度,窗口恢复默认系统亮度之后,控制中心可以调整系统屏幕亮度。
7287
7288> **说明:**
7289>
7290> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBrightness()](#setwindowbrightness9)。
7291
7292**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7293
7294**参数:**
7295
7296| 参数名     | 类型                      | 必填 | 说明                                    |
7297| ---------- | ------------------------- | ---- |---------------------------------------|
7298| brightness | number                    | 是   | 屏幕亮度值。该参数为浮点数,取值范围为[0.0, 1.0]或-1.0。1.0表示最亮,-1.0表示默认亮度。 |
7299| callback   | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                 |
7300
7301**示例:**
7302
7303```ts
7304import { BusinessError } from '@ohos.base';
7305
7306let windowClass: window.Window = window.findWindow("test");
7307let brightness: number = 1;
7308windowClass.setBrightness(brightness, (err: BusinessError) => {
7309  const errCode: number = err.code;
7310  if (errCode) {
7311    console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
7312    return;
7313  }
7314  console.info('Succeeded in setting the brightness.');
7315});
7316```
7317
7318### setBrightness<sup>(deprecated)</sup>
7319
7320setBrightness(brightness: number): Promise&lt;void&gt;
7321
7322设置屏幕亮度值,使用Promise异步回调。
7323
7324当前屏幕亮度规格:窗口设置屏幕亮度生效时,控制中心不可以调整系统屏幕亮度,窗口恢复默认系统亮度之后,控制中心可以调整系统屏幕亮度。
7325
7326> **说明:**
7327>
7328> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBrightness()](#setwindowbrightness9-1)。
7329
7330**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7331
7332**参数:**
7333
7334| 参数名     | 类型   | 必填 | 说明                                       |
7335| ---------- | ------ | ---- |------------------------------------------|
7336| brightness | number | 是   | 屏幕亮度值。该参数为浮点数,取值范围为[0.0, 1.0]或-1.0。1.0表示最亮,-1.0表示默认亮度。 |
7337
7338**返回值:**
7339
7340| 类型                | 说明                      |
7341| ------------------- | ------------------------- |
7342| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
7343
7344**示例:**
7345
7346```ts
7347import { BusinessError } from '@ohos.base';
7348
7349let windowClass: window.Window = window.findWindow("test");
7350let brightness: number = 1;
7351let promise = windowClass.setBrightness(brightness);
7352promise.then(() => {
7353  console.info('Succeeded in setting the brightness.');
7354}).catch((err: BusinessError) => {
7355  console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
7356});
7357```
7358
7359### setDimBehind<sup>(deprecated)</sup>
7360
7361setDimBehind(dimBehindValue: number, callback: AsyncCallback&lt;void&gt;): void
7362
7363窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用callback异步回调。
7364
7365> **说明:**
7366>
7367> 该接口不支持使用。从 API version 7开始支持,从API version 9开始废弃。
7368
7369**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7370
7371**参数:**
7372
7373| 参数名         | 类型                      | 必填 | 说明                                     |
7374| -------------- | ------------------------- | ---- |----------------------------------------|
7375| dimBehindValue | number                    | 是   | 表示靠后的窗口的暗度值,取值范围为[0.0, 1.0],取1.0时表示最暗。 |
7376| callback       | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                  |
7377
7378**示例:**
7379
7380```ts
7381import { BusinessError } from '@ohos.base';
7382
7383let windowClass: window.Window = window.findWindow("test");
7384windowClass.setDimBehind(0.5, (err: BusinessError) => {
7385  const errCode: number = err.code;
7386  if (errCode) {
7387    console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
7388    return;
7389  }
7390  console.info('Succeeded in setting the dimness.');
7391});
7392```
7393
7394### setDimBehind<sup>(deprecated)</sup>
7395
7396setDimBehind(dimBehindValue: number): Promise&lt;void&gt;
7397
7398窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用Promise异步回调。
7399
7400> **说明:**
7401>
7402> 该接口不支持使用。从 API version 7开始支持,从API version 9开始废弃。
7403
7404**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7405
7406**参数:**
7407
7408| 参数名         | 类型   | 必填 | 说明                                               |
7409| -------------- | ------ | ---- | -------------------------------------------------- |
7410| dimBehindValue | number | 是   | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 |
7411
7412**返回值:**
7413
7414| 类型                | 说明                      |
7415| ------------------- | ------------------------- |
7416| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
7417
7418**示例:**
7419
7420```ts
7421import { BusinessError } from '@ohos.base';
7422
7423let windowClass: window.Window = window.findWindow("test");
7424let promise = windowClass.setDimBehind(0.5);
7425promise.then(() => {
7426  console.info('Succeeded in setting the dimness.');
7427}).catch((err: BusinessError) => {
7428  console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
7429});
7430```
7431
7432### setFocusable<sup>(deprecated)</sup>
7433
7434setFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): void
7435
7436设置点击时是否支持切换焦点窗口,使用callback异步回调。
7437
7438> **说明:**
7439>
7440> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowFocusable()](#setwindowfocusable9)。
7441
7442**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7443
7444**参数:**
7445
7446| 参数名      | 类型                      | 必填 | 说明                         |
7447| ----------- | ------------------------- | ---- | ---------------------------- |
7448| isFocusable | boolean                   | 是   | 点击时是否支持切换焦点窗口。true表示支持;false表示不支持。 |
7449| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。                   |
7450
7451**示例:**
7452
7453```ts
7454import { BusinessError } from '@ohos.base';
7455
7456let windowClass: window.Window = window.findWindow("test");
7457let isFocusable: boolean = true;
7458windowClass.setFocusable(isFocusable, (err: BusinessError) => {
7459  const errCode: number = err.code;
7460  if (errCode) {
7461    console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err));
7462    return;
7463  }
7464  console.info('Succeeded in setting the window to be focusable.');
7465});
7466```
7467
7468### setFocusable<sup>(deprecated)</sup>
7469
7470setFocusable(isFocusable: boolean): Promise&lt;void&gt;
7471
7472设置点击时是否支持切换焦点窗口,使用Promise异步回调。
7473
7474> **说明:**
7475>
7476> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowFocusable()](#setwindowfocusable9-1)。
7477
7478**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7479
7480**参数:**
7481
7482| 参数名      | 类型    | 必填 | 说明                         |
7483| ----------- | ------- | ---- | ---------------------------- |
7484| isFocusable | boolean | 是   | 点击时是否支持切换焦点窗口。true表示支持;false表示不支持。 |
7485
7486**返回值:**
7487
7488| 类型                | 说明                      |
7489| ------------------- | ------------------------- |
7490| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
7491
7492**示例:**
7493
7494```ts
7495import { BusinessError } from '@ohos.base';
7496
7497let windowClass: window.Window = window.findWindow("test");
7498let isFocusable: boolean = true;
7499let promise = windowClass.setFocusable(isFocusable);
7500promise.then(() => {
7501  console.info('Succeeded in setting the window to be focusable.');
7502}).catch((err: BusinessError) => {
7503  console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
7504});
7505```
7506
7507### setKeepScreenOn<sup>(deprecated)</sup>
7508
7509setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback&lt;void&gt;): void
7510
7511设置屏幕是否为常亮状态,使用callback异步回调。
7512
7513> **说明:**
7514>
7515> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowKeepScreenOn()](#setwindowkeepscreenon9)。
7516
7517**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7518
7519**参数:**
7520
7521| 参数名         | 类型                      | 必填 | 说明                     |
7522| -------------- | ------------------------- | ---- | ------------------------ |
7523| isKeepScreenOn | boolean                   | 是   | 设置屏幕是否为常亮状态。true表示常亮;false表示不常亮。 |
7524| callback       | AsyncCallback&lt;void&gt; | 是   | 回调函数。               |
7525
7526**示例:**
7527
7528```ts
7529import { BusinessError } from '@ohos.base';
7530
7531let windowClass: window.Window = window.findWindow("test");
7532let isKeepScreenOn: boolean = true;
7533windowClass.setKeepScreenOn(isKeepScreenOn, (err: BusinessError) => {
7534  const errCode: number = err.code;
7535  if (errCode) {
7536    console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
7537    return;
7538  }
7539  console.info('Succeeded in setting the screen to be always on.');
7540});
7541```
7542
7543### setKeepScreenOn<sup>(deprecated)</sup>
7544
7545setKeepScreenOn(isKeepScreenOn: boolean): Promise&lt;void&gt;
7546
7547设置屏幕是否为常亮状态,使用Promise异步回调。
7548
7549> **说明:**
7550>
7551> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowKeepScreenOn()](#setwindowkeepscreenon9-1)。
7552
7553**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7554
7555**参数:**
7556
7557| 参数名         | 类型    | 必填 | 说明                     |
7558| -------------- | ------- | ---- | ------------------------ |
7559| isKeepScreenOn | boolean | 是   | 设置屏幕是否为常亮状态。true表示常亮;false表示不常亮。 |
7560
7561**返回值:**
7562
7563| 类型                | 说明                      |
7564| ------------------- | ------------------------- |
7565| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
7566
7567**示例:**
7568
7569```ts
7570import { BusinessError } from '@ohos.base';
7571
7572let windowClass: window.Window = window.findWindow("test");
7573let isKeepScreenOn: boolean = true;
7574let promise = windowClass.setKeepScreenOn(isKeepScreenOn);
7575promise.then(() => {
7576  console.info('Succeeded in setting the screen to be always on.');
7577}).catch((err: BusinessError) => {
7578  console.info('Failed to set the screen to be always on. Cause:  ' + JSON.stringify(err));
7579});
7580```
7581
7582### setOutsideTouchable<sup>(deprecated)</sup>
7583
7584setOutsideTouchable(touchable: boolean, callback: AsyncCallback&lt;void&gt;): void
7585
7586设置是否允许可点击子窗口之外的区域,使用callback异步回调。
7587
7588> **说明:**
7589>
7590> 从 API version 7开始支持,从API version 9开始废弃。
7591>
7592> 从 API version 9开始,系统默认允许点击子窗口之外的区域,此接口不再支持使用,也不再提供替代接口。
7593
7594**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7595
7596**参数:**
7597
7598| 参数名    | 类型                      | 必填 | 说明             |
7599| --------- | ------------------------- | ---- | ---------------- |
7600| touchable | boolean                   | 是   | 设置是否可点击。true表示可点击;false表示不可点击。 |
7601| callback  | AsyncCallback&lt;void&gt; | 是   | 回调函数。       |
7602
7603**示例:**
7604
7605```ts
7606import { BusinessError } from '@ohos.base';
7607
7608if (!windowClass) {
7609  console.info('Failed to load the content. Cause: windowClass is null');
7610}
7611else {
7612  (windowClass as window.Window).setOutsideTouchable(true, (err: BusinessError) => {
7613    const errCode: number = err.code;
7614    if (errCode) {
7615      console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
7616      return;
7617    }
7618    console.info('Succeeded in setting the area to be touchable.');
7619  });
7620}
7621```
7622
7623### setOutsideTouchable<sup>(deprecated)</sup>
7624
7625setOutsideTouchable(touchable: boolean): Promise&lt;void&gt;
7626
7627设置是否允许可点击子窗口之外的区域,使用Promise异步回调。。
7628
7629> **说明:**
7630>
7631> 从 API version 7开始支持,从API version 9开始废弃。
7632>
7633> 从 API version 9开始,系统默认允许点击子窗口之外的区域,此接口不再支持使用,也不再提供替代接口。
7634
7635**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7636
7637**参数:**
7638
7639| 参数名    | 类型    | 必填 | 说明             |
7640| --------- | ------- | ---- | ---------------- |
7641| touchable | boolean | 是   | 设置是否可点击。true表示可点击;false表示不可点击。 |
7642
7643**返回值:**
7644
7645| 类型                | 说明                      |
7646| ------------------- | ------------------------- |
7647| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
7648
7649**示例:**
7650
7651```ts
7652import { BusinessError } from '@ohos.base';
7653
7654if (!windowClass) {
7655  console.info('Failed to load the content. Cause: windowClass is null');
7656}
7657else {
7658let promise = (windowClass as window.Window).setOutsideTouchable(true);
7659promise.then(() => {
7660  console.info('Succeeded in setting the area to be touchable.');
7661}).catch((err: BusinessError) => {
7662  console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
7663});
7664}
7665```
7666
7667### setPrivacyMode<sup>(deprecated)</sup>
7668
7669setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback&lt;void&gt;): void
7670
7671设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。此接口可用于禁止截屏/录屏的场景。
7672
7673> **说明:**
7674>
7675> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowPrivacyMode()](#setwindowprivacymode9)。
7676
7677**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7678
7679**参数:**
7680
7681| 参数名        | 类型                      | 必填 | 说明                 |
7682| ------------- | ------------------------- | ---- | -------------------- |
7683| isPrivacyMode | boolean                   | 是   | 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 |
7684| callback      | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
7685
7686**示例:**
7687
7688```ts
7689import { BusinessError } from '@ohos.base';
7690
7691let windowClass: window.Window = window.findWindow("test");
7692let isPrivacyMode: boolean = true;
7693windowClass.setPrivacyMode(isPrivacyMode, (err: BusinessError) => {
7694  const errCode: number = err.code;
7695  if (errCode) {
7696    console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
7697    return;
7698  }
7699  console.info('Succeeded in setting the window to privacy mode.');
7700});
7701```
7702
7703### setPrivacyMode<sup>(deprecated)</sup>
7704
7705setPrivacyMode(isPrivacyMode: boolean): Promise&lt;void&gt;
7706
7707设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。此接口可用于禁止截屏/录屏的场景。
7708
7709> **说明:**
7710>
7711> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowPrivacyMode()](#setwindowprivacymode9-1)。
7712
7713**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7714
7715**参数:**
7716
7717| 参数名        | 类型    | 必填 | 说明                 |
7718| ------------- | ------- | ---- | -------------------- |
7719| isPrivacyMode | boolean | 是   | 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 |
7720
7721**返回值:**
7722
7723| 类型                | 说明                      |
7724| ------------------- | ------------------------- |
7725| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
7726
7727**示例:**
7728
7729```ts
7730import { BusinessError } from '@ohos.base';
7731
7732let windowClass: window.Window = window.findWindow("test");
7733let isPrivacyMode: boolean = true;
7734let promise = windowClass.setPrivacyMode(isPrivacyMode);
7735promise.then(() => {
7736  console.info('Succeeded in setting the window to privacy mode.');
7737}).catch((err: BusinessError) => {
7738  console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
7739});
7740```
7741
7742### setTouchable<sup>(deprecated)</sup>
7743
7744setTouchable(isTouchable: boolean, callback: AsyncCallback&lt;void&gt;): void
7745
7746设置窗口是否为可触状态,使用callback异步回调。
7747
7748> **说明:**
7749>
7750> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowTouchable()](#setwindowtouchable9)。
7751
7752**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7753
7754**参数:**
7755
7756| 参数名      | 类型                      | 必填 | 说明                 |
7757| ----------- | ------------------------- | ---- | -------------------- |
7758| isTouchable | boolean                   | 是   | 窗口是否为可触状态。true表示可触;false表示不可触。 |
7759| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
7760
7761**示例:**
7762
7763```ts
7764import { BusinessError } from '@ohos.base';
7765
7766let isTouchable = true;
7767if (!windowClass) {
7768  console.info('Failed to load the content. Cause: windowClass is null');
7769}
7770else {
7771  (windowClass as window.Window).setTouchable(isTouchable, (err: BusinessError) => {
7772    const errCode: number = err.code;
7773    if (errCode) {
7774      console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
7775      return;
7776    }
7777    console.info('Succeeded in setting the window to be touchable.');
7778  });
7779}
7780```
7781
7782### setTouchable<sup>(deprecated)</sup>
7783
7784setTouchable(isTouchable: boolean): Promise&lt;void&gt;
7785
7786设置窗口是否为可触状态,使用Promise异步回调。
7787
7788> **说明:**
7789>
7790> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowTouchable()](#setwindowtouchable9-1)。
7791
7792**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7793
7794**参数:**
7795
7796| 参数名      | 类型    | 必填 | 说明                 |
7797| ----------- | ------- | ---- | -------------------- |
7798| isTouchable | boolean | 是   | 窗口是否为可触状态。true表示可触;false表示不可触。 |
7799
7800**返回值:**
7801
7802| 类型                | 说明                      |
7803| ------------------- | ------------------------- |
7804| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
7805
7806**示例:**
7807
7808```ts
7809import { BusinessError } from '@ohos.base';
7810
7811let isTouchable = true;
7812let windowClass: window.Window = window.findWindow("test");
7813let promise = windowClass.setTouchable(isTouchable);
7814promise.then(() => {
7815  console.info('Succeeded in setting the window to be touchable.');
7816}).catch((err: BusinessError) => {
7817  console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
7818});
7819```
7820
7821## WindowStageEventType<sup>9+</sup>
7822
7823WindowStage生命周期。
7824
7825**模型约束:** 此接口仅可在Stage模型下使用。
7826
7827**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7828
7829| 名称       | 值 | 说明       |
7830| ---------- | ------ | ---------- |
7831| SHOWN      | 1      | 切到前台。 |
7832| ACTIVE     | 2      | 获焦状态。 |
7833| INACTIVE   | 3      | 失焦状态。 |
7834| HIDDEN     | 4      | 切到后台。 |
7835
7836## WindowStage<sup>9+</sup>
7837
7838窗口管理器。管理各个基本窗口单元,即[Window](#window)实例。
7839
7840下列API示例中都需在[onWindowStageCreate()](js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate)函数中使用WindowStage的实例调用对应方法。
7841
7842### getMainWindow<sup>9+</sup>
7843
7844getMainWindow(callback: AsyncCallback&lt;Window&gt;): void
7845
7846获取该WindowStage实例下的主窗口,使用callback异步回调。
7847
7848**模型约束:** 此接口仅可在Stage模型下使用。
7849
7850**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7851
7852**参数:**
7853
7854| 参数名   | 类型                                   | 必填 | 说明                                          |
7855| -------- | -------------------------------------- | ---- | --------------------------------------------- |
7856| callback | AsyncCallback&lt;[Window](#window)&gt; | 是   | 回调函数。返回当前WindowStage下的主窗口对象。 |
7857
7858**错误码:**
7859
7860以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
7861
7862| 错误码ID | 错误信息 |
7863| ------- | ------------------------------ |
7864| 1300002 | This window state is abnormal. |
7865| 1300005 | This window stage is abnormal. |
7866
7867**示例:**
7868
7869```ts
7870import UIAbility from '@ohos.app.ability.UIAbility';
7871import window from '@ohos.window';
7872import { BusinessError } from '@ohos.base';
7873
7874export default class EntryAbility extends UIAbility {
7875  // ...
7876
7877  onWindowStageCreate(windowStage: window.WindowStage) {
7878    console.log('onWindowStageCreate');
7879    let windowClass: window.Window = window.findWindow("test");
7880    windowStage.getMainWindow((err: BusinessError, data) => {
7881      const errCode: number = err.code;
7882      if (errCode) {
7883        console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
7884        return;
7885      }
7886      windowClass = data;
7887      console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
7888    });
7889  }
7890};
7891```
7892
7893### getMainWindow<sup>9+</sup>
7894
7895getMainWindow(): Promise&lt;Window&gt;
7896
7897获取该WindowStage实例下的主窗口,使用Promise异步回调。
7898
7899**模型约束:** 此接口仅可在Stage模型下使用。
7900
7901**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7902
7903**返回值:**
7904
7905| 类型                             | 说明                                             |
7906| -------------------------------- | ------------------------------------------------ |
7907| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前WindowStage下的主窗口对象。 |
7908
7909**错误码:**
7910
7911以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
7912
7913| 错误码ID | 错误信息 |
7914| ------- | ------------------------------ |
7915| 1300002 | This window state is abnormal. |
7916| 1300005 | This window stage is abnormal. |
7917
7918**示例:**
7919
7920```ts
7921import UIAbility from '@ohos.app.ability.UIAbility';
7922import window from '@ohos.window';
7923import { BusinessError } from '@ohos.base';
7924
7925export default class EntryAbility extends UIAbility {
7926  // ...
7927
7928  onWindowStageCreate(windowStage: window.WindowStage) {
7929    console.log('onWindowStageCreate');
7930    let windowClass: window.Window = window.findWindow("test");
7931    let promise = windowStage.getMainWindow();
7932    promise.then((data) => {
7933      windowClass = data;
7934      console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
7935    }).catch((err: BusinessError) => {
7936      console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
7937    });
7938  }
7939};
7940```
7941
7942### getMainWindowSync<sup>9+</sup>
7943
7944getMainWindowSync(): Window
7945
7946获取该WindowStage实例下的主窗口。
7947
7948**模型约束:** 此接口仅可在Stage模型下使用。
7949
7950**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7951
7952**返回值:**
7953
7954| 类型 | 说明 |
7955| ----------------- | --------------------------------- |
7956| [Window](#window) | 返回当前WindowStage下的主窗口对象。 |
7957
7958**错误码:**
7959
7960以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
7961
7962| 错误码ID | 错误信息 |
7963| ------- | ------------------------------ |
7964| 1300002 | This window state is abnormal. |
7965| 1300005 | This window stage is abnormal. |
7966
7967**示例:**
7968
7969```ts
7970import UIAbility from '@ohos.app.ability.UIAbility';
7971import window from '@ohos.window';
7972
7973export default class EntryAbility extends UIAbility {
7974  // ...
7975
7976  onWindowStageCreate(windowStage: window.WindowStage) {
7977    console.log('onWindowStageCreate');
7978    try {
7979      let windowClass = windowStage.getMainWindowSync();
7980    } catch (exception) {
7981      console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception));
7982    }
7983  }
7984};
7985```
7986
7987### createSubWindow<sup>9+</sup>
7988
7989createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void
7990
7991创建该WindowStage实例下的子窗口,使用callback异步回调。
7992
7993**模型约束:** 此接口仅可在Stage模型下使用。
7994
7995**系统能力:** SystemCapability.WindowManager.WindowManager.Core
7996
7997**参数:**
7998
7999| 参数名   | 类型                                   | 必填 | 说明                                          |
8000| -------- | -------------------------------------- | ---- | --------------------------------------------- |
8001| name     | string                                 | 是   | 子窗口的名字。                                |
8002| callback | AsyncCallback&lt;[Window](#window)&gt; | 是   | 回调函数。返回当前WindowStage下的子窗口对象。 |
8003
8004**错误码:**
8005
8006以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
8007
8008| 错误码ID | 错误信息 |
8009| ------- | ------------------------------ |
8010| 1300002 | This window state is abnormal. |
8011| 1300005 | This window stage is abnormal. |
8012
8013**示例:**
8014
8015```ts
8016import UIAbility from '@ohos.app.ability.UIAbility';
8017import window from '@ohos.window';
8018import { BusinessError } from '@ohos.base';
8019
8020export default class EntryAbility extends UIAbility {
8021  // ...
8022
8023  onWindowStageCreate(windowStage: window.WindowStage) {
8024    console.log('onWindowStageCreate');
8025    let windowClass: window.Window = window.findWindow("test");
8026    try {
8027      windowStage.createSubWindow('mySubWindow', (err: BusinessError, data) => {
8028        const errCode: number = err.code;
8029        if (errCode) {
8030          console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
8031          return;
8032        }
8033        windowClass = data;
8034        console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
8035        if (!windowClass) {
8036          console.info('Failed to load the content. Cause: windowClass is null');
8037        }
8038        else {
8039          (windowClass as window.Window).resetSize(500, 1000);
8040        }
8041      });
8042
8043    } catch (exception) {
8044      console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
8045    }
8046  }
8047};
8048```
8049### createSubWindow<sup>9+</sup>
8050
8051createSubWindow(name: string): Promise&lt;Window&gt;
8052
8053创建该WindowStage实例下的子窗口,使用Promise异步回调。
8054
8055**模型约束:** 此接口仅可在Stage模型下使用。
8056
8057**系统能力:** SystemCapability.WindowManager.WindowManager.Core
8058
8059**参数:**
8060
8061| 参数名 | 类型   | 必填 | 说明           |
8062| ------ | ------ | ---- | -------------- |
8063| name   | string | 是   | 子窗口的名字。 |
8064
8065**返回值:**
8066
8067| 类型                             | 说明                                             |
8068| -------------------------------- | ------------------------------------------------ |
8069| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前WindowStage下的子窗口对象。 |
8070
8071**错误码:**
8072
8073以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
8074
8075| 错误码ID | 错误信息 |
8076| ------- | ------------------------------ |
8077| 1300002 | This window state is abnormal. |
8078| 1300005 | This window stage is abnormal. |
8079
8080**示例:**
8081
8082```ts
8083import UIAbility from '@ohos.app.ability.UIAbility';
8084import window from '@ohos.window';
8085import { BusinessError } from '@ohos.base';
8086
8087export default class EntryAbility extends UIAbility {
8088  // ...
8089
8090  onWindowStageCreate(windowStage: window.WindowStage) {
8091    console.log('onWindowStageCreate');
8092    let windowClass: window.Window = window.findWindow("test");
8093    try {
8094      let promise = windowStage.createSubWindow('mySubWindow');
8095      promise.then((data) => {
8096        windowClass = data;
8097        console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
8098      }).catch((err: BusinessError) => {
8099        console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
8100      });
8101    } catch (exception) {
8102      console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
8103    }
8104  }
8105};
8106```
8107
8108### getSubWindow<sup>9+</sup>
8109
8110getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void
8111
8112获取该WindowStage实例下的所有子窗口,使用callback异步回调。
8113
8114**模型约束:** 此接口仅可在Stage模型下使用。
8115
8116**系统能力:** SystemCapability.WindowManager.WindowManager.Core
8117
8118**参数:**
8119
8120| 参数名   | 类型                                                | 必填 | 说明                                              |
8121| -------- | --------------------------------------------------- | ---- | ------------------------------------------------- |
8122| callback | AsyncCallback&lt;Array&lt;[Window](#window)&gt;&gt; | 是   | 回调函数。返回当前WindowStage下的所有子窗口对象。 |
8123
8124**错误码:**
8125
8126以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
8127
8128| 错误码ID | 错误信息 |
8129| ------- | ------------------------------ |
8130| 1300005 | This window stage is abnormal. |
8131
8132**示例:**
8133
8134```ts
8135import UIAbility from '@ohos.app.ability.UIAbility';
8136import window from '@ohos.window';
8137import { BusinessError } from '@ohos.base';
8138
8139export default class EntryAbility extends UIAbility {
8140  // ...
8141
8142  onWindowStageCreate(windowStage: window.WindowStage) {
8143    console.log('onWindowStageCreate');
8144    let windowClass: window.Window[] = [];
8145    windowStage.getSubWindow((err: BusinessError, data) => {
8146      const errCode: number = err.code;
8147      if (errCode) {
8148        console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
8149        return;
8150      }
8151      windowClass = data;
8152      console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
8153    });
8154  }
8155};
8156```
8157### getSubWindow<sup>9+</sup>
8158
8159getSubWindow(): Promise&lt;Array&lt;Window&gt;&gt;
8160
8161获取该WindowStage实例下的所有子窗口,使用Promise异步回调。
8162
8163**模型约束:** 此接口仅可在Stage模型下使用。
8164
8165**系统能力:** SystemCapability.WindowManager.WindowManager.Core
8166
8167**返回值:**
8168
8169| 类型                                          | 说明                                                 |
8170| --------------------------------------------- | ---------------------------------------------------- |
8171| Promise&lt;Array&lt;[Window](#window)&gt;&gt; | Promise对象。返回当前WindowStage下的所有子窗口对象。 |
8172
8173**错误码:**
8174
8175以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
8176
8177| 错误码ID | 错误信息 |
8178| ------- | ------------------------------ |
8179| 1300005 | This window stage is abnormal. |
8180
8181**示例:**
8182
8183```ts
8184import UIAbility from '@ohos.app.ability.UIAbility';
8185import window from '@ohos.window';
8186import { BusinessError } from '@ohos.base';
8187
8188export default class EntryAbility extends UIAbility {
8189  // ...
8190
8191  onWindowStageCreate(windowStage: window.WindowStage) {
8192    console.log('onWindowStageCreate');
8193    let windowClass: window.Window[] = [];
8194    let promise = windowStage.getSubWindow();
8195    promise.then((data) => {
8196      windowClass = data;
8197      console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
8198    }).catch((err: BusinessError) => {
8199      console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
8200    })
8201  }
8202};
8203```
8204### loadContent<sup>9+</sup>
8205
8206loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void&gt;): void
8207
8208为当前WindowStage的主窗口加载与LocalStorage相关联的具体页面内容,使用callback异步回调。
8209
8210**模型约束:** 此接口仅可在Stage模型下使用。
8211
8212**系统能力:** SystemCapability.WindowManager.WindowManager.Core
8213
8214**参数:**
8215
8216| 参数名   | 类型                                            | 必填 | 说明                                                         |
8217| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
8218| path     | string                                          | 是   | 设置加载页面的路径。                                         |
8219| storage  | [LocalStorage](../../quick-start/arkts-localstorage.md) | 是   | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 |
8220| callback | AsyncCallback&lt;void&gt;                       | 是   | 回调函数。                                                   |
8221
8222**错误码:**
8223
8224以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
8225
8226| 错误码ID | 错误信息 |
8227| ------- | ------------------------------ |
8228| 1300002 | This window state is abnormal. |
8229| 1300005 | This window stage is abnormal. |
8230
8231**示例:**
8232
8233```ts
8234import UIAbility from '@ohos.app.ability.UIAbility';
8235import window from '@ohos.window';
8236import { BusinessError } from '@ohos.base';
8237
8238export default class EntryAbility extends UIAbility {
8239  // ...
8240
8241  storage: LocalStorage = new LocalStorage();
8242
8243  onWindowStageCreate(windowStage: window.WindowStage) {
8244    this.storage.setOrCreate('storageSimpleProp', 121);
8245    console.log('onWindowStageCreate');
8246    try {
8247      windowStage.loadContent('pages/page2', this.storage, (err: BusinessError) => {
8248        const errCode: number = err.code;
8249        if (errCode) {
8250          console.error('Failed to load the content. Cause:' + JSON.stringify(err));
8251          return;
8252        }
8253        console.info('Succeeded in loading the content.');
8254      });
8255    } catch (exception) {
8256      console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
8257    }
8258  }
8259};
8260```
8261
8262### loadContent<sup>9+</sup>
8263
8264loadContent(path: string, storage?: LocalStorage): Promise&lt;void&gt;
8265
8266为当前WindowStage的主窗口加载与LocalStorage相关联的具体页面内容,使用Promise异步回调。
8267
8268**模型约束:** 此接口仅可在Stage模型下使用。
8269
8270**系统能力:** SystemCapability.WindowManager.WindowManager.Core
8271
8272**参数:**
8273
8274| 参数名  | 类型                                            | 必填 | 说明                                                         |
8275| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
8276| path    | string                                          | 是   | 设置加载页面的路径。                                         |
8277| storage | [LocalStorage](../../quick-start/arkts-localstorage.md) | 否   | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 |
8278
8279**返回值:**
8280
8281| 类型                | 说明                      |
8282| ------------------- | ------------------------- |
8283| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
8284
8285**错误码:**
8286
8287以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
8288
8289| 错误码ID | 错误信息 |
8290| ------- | ------------------------------ |
8291| 1300002 | This window state is abnormal. |
8292| 1300005 | This window stage is abnormal. |
8293
8294**示例:**
8295
8296```ts
8297import UIAbility from '@ohos.app.ability.UIAbility';
8298import window from '@ohos.window';
8299import { BusinessError } from '@ohos.base';
8300
8301export default class EntryAbility extends UIAbility {
8302  // ...
8303
8304  storage: LocalStorage = new LocalStorage();
8305
8306  onWindowStageCreate(windowStage: window.WindowStage) {
8307    this.storage.setOrCreate('storageSimpleProp', 121);
8308    console.log('onWindowStageCreate');
8309    try {
8310      let promise = windowStage.loadContent('pages/page2', this.storage);
8311      promise.then(() => {
8312        console.info('Succeeded in loading the content.');
8313      }).catch((err: BusinessError) => {
8314        console.error('Failed to load the content. Cause:' + JSON.stringify(err));
8315      });
8316    } catch (exception) {
8317      console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
8318    }
8319    ;
8320  }
8321};
8322```
8323
8324### loadContent<sup>9+</sup>
8325
8326loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void
8327
8328为当前WindowStage的主窗口加载具体页面内容,使用callback异步回调。
8329
8330**模型约束:** 此接口仅可在Stage模型下使用。
8331
8332**系统能力:** SystemCapability.WindowManager.WindowManager.Core
8333
8334**参数:**
8335
8336| 参数名   | 类型                      | 必填 | 说明                 |
8337| -------- | ------------------------- | ---- | -------------------- |
8338| path     | string                    | 是   | 设置加载页面的路径。 |
8339| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
8340
8341**错误码:**
8342
8343以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
8344
8345| 错误码ID | 错误信息 |
8346| ------- | ------------------------------ |
8347| 1300002 | This window state is abnormal. |
8348| 1300005 | This window stage is abnormal. |
8349
8350**示例:**
8351
8352```ts
8353import UIAbility from '@ohos.app.ability.UIAbility';
8354import window from '@ohos.window';
8355import { BusinessError } from '@ohos.base';
8356
8357export default class EntryAbility extends UIAbility {
8358  // ...
8359
8360  onWindowStageCreate(windowStage: window.WindowStage) {
8361    console.log('onWindowStageCreate');
8362    try {
8363      windowStage.loadContent('pages/page2', (err: BusinessError) => {
8364        const errCode: number = err.code;
8365        if (errCode) {
8366          console.error('Failed to load the content. Cause:' + JSON.stringify(err));
8367          return;
8368        }
8369        console.info('Succeeded in loading the content.');
8370      });
8371    } catch (exception) {
8372      console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
8373    }
8374  }
8375};
8376```
8377
8378### on('windowStageEvent')<sup>9+</sup>
8379
8380on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void
8381
8382开启WindowStage生命周期变化的监听。
8383
8384**模型约束:** 此接口仅可在Stage模型下使用。
8385
8386**系统能力:** SystemCapability.WindowManager.WindowManager.Core
8387
8388**参数:**
8389
8390| 参数名   | 类型                                                         | 必填 | 说明                                                         |
8391| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
8392| type     | string                                                       | 是   | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 |
8393| callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | 是   | 回调函数。返回当前的WindowStage生命周期状态。                |
8394
8395**错误码:**
8396
8397以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
8398
8399| 错误码ID | 错误信息 |
8400| ------- | ------------------------------ |
8401| 1300002 | This window state is abnormal. |
8402| 1300005 | This window stage is abnormal. |
8403
8404**示例:**
8405
8406```ts
8407import UIAbility from '@ohos.app.ability.UIAbility';
8408import window from '@ohos.window';
8409
8410export default class EntryAbility extends UIAbility {
8411  // ...
8412
8413  onWindowStageCreate(windowStage: window.WindowStage) {
8414    console.log('onWindowStageCreate');
8415    try {
8416      windowStage.on('windowStageEvent', (data) => {
8417        console.info('Succeeded in enabling the listener for window stage event changes. Data: ' +
8418        JSON.stringify(data));
8419      });
8420    } catch (exception) {
8421      console.error('Failed to enable the listener for window stage event changes. Cause:' +
8422      JSON.stringify(exception));
8423    }
8424  }
8425};
8426```
8427
8428### off('windowStageEvent')<sup>9+</sup>
8429
8430off(eventType: 'windowStageEvent', callback?: Callback&lt;WindowStageEventType&gt;): void
8431
8432关闭WindowStage生命周期变化的监听。
8433
8434**模型约束:** 此接口仅可在Stage模型下使用。
8435
8436**系统能力:** SystemCapability.WindowManager.WindowManager.Core
8437
8438**参数:**
8439
8440| 参数名   | 类型                                                         | 必填 | 说明                                                         |
8441| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
8442| type     | string                                                       | 是   | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 |
8443| callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | 否   | 回调函数。返回当前的WindowStage生命周期状态。若传入参数,则关闭该监听。若未传入参数,则关闭所有WindowStage生命周期变化的监听。                |
8444
8445**错误码:**
8446
8447以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
8448
8449| 错误码ID | 错误信息 |
8450| ------- | ------------------------------ |
8451| 1300002 | This window state is abnormal. |
8452| 1300005 | This window stage is abnormal. |
8453
8454**示例:**
8455
8456```ts
8457import UIAbility from '@ohos.app.ability.UIAbility';
8458import window from '@ohos.window';
8459
8460export default class EntryAbility extends UIAbility {
8461  // ...
8462
8463  onWindowStageCreate(windowStage: window.WindowStage) {
8464    console.log('onWindowStageCreate');
8465    try {
8466      windowStage.off('windowStageEvent');
8467    } catch (exception) {
8468      console.error('Failed to disable the listener for window stage event changes. Cause:' +
8469      JSON.stringify(exception));
8470    }
8471  }
8472};
8473```
8474
8475### disableWindowDecor()<sup>9+</sup>
8476
8477disableWindowDecor(): void
8478
8479禁止窗口装饰。
8480
8481**模型约束:** 此接口仅可在Stage模型下使用。
8482
8483**系统接口:** 此接口为系统接口。
8484
8485**系统能力:** SystemCapability.WindowManager.WindowManager.Core
8486
8487**错误码:**
8488
8489以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
8490
8491| 错误码ID | 错误信息 |
8492| ------- | ------------------------------ |
8493| 1300002 | This window state is abnormal. |
8494| 1300005 | This window stage is abnormal. |
8495
8496**示例:**
8497
8498```ts
8499import UIAbility from '@ohos.app.ability.UIAbility';
8500import window from '@ohos.window';
8501
8502export default class EntryAbility extends UIAbility {
8503  // ...
8504
8505  onWindowStageCreate(windowStage: window.WindowStage) {
8506    console.log('disableWindowDecor');
8507    windowStage.disableWindowDecor();
8508  }
8509};
8510```
8511
8512### setShowOnLockScreen()<sup>9+</sup>
8513
8514setShowOnLockScreen(showOnLockScreen: boolean): void
8515
8516设置应用显示在锁屏之上。
8517
8518**系统接口:** 此接口为系统接口。
8519
8520**模型约束:** 此接口仅可在Stage模型下使用。
8521
8522**系统能力:** SystemCapability.WindowManager.WindowManager.Core
8523
8524**参数:**
8525
8526| 参数名           | 类型    | 必填 | 说明                         |
8527| ---------------- | ------- | ---- | ---------------------------- |
8528| showOnLockScreen | boolean | 是   | 是否设置应用显示在锁屏之上。true表示显示在锁屏之上;false表示不显示在锁屏之上。 |
8529
8530**错误码:**
8531
8532以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。
8533
8534| 错误码ID | 错误信息 |
8535| ------- | ------------------------------ |
8536| 1300002 | This window state is abnormal. |
8537| 1300005 | This window stage is abnormal. |
8538
8539**示例:**
8540
8541```ts
8542import UIAbility from '@ohos.app.ability.UIAbility';
8543import window from '@ohos.window';
8544
8545export default class EntryAbility extends UIAbility {
8546  // ...
8547
8548  onWindowStageCreate(windowStage: window.WindowStage) {
8549    console.log('onWindowStageCreate');
8550    try {
8551      windowStage.setShowOnLockScreen(true);
8552    } catch (exception) {
8553      console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception));
8554    }
8555  }
8556};
8557```
8558## TransitionContext<sup>9+</sup>
8559
8560属性转换的上下文信息。
8561
8562### 属性
8563
8564**系统接口:** 此接口为系统接口。
8565
8566**系统能力**:SystemCapability.WindowManager.WindowManager.Core
8567
8568| 名称                  | 类型          | 可读 | 可写 | 说明             |
8569| --------------------- | ----------------- | ---- | ---- | ---------------- |
8570| toWindow<sup>9+</sup> | [Window](#window) | 是   | 是   | 动画的目标窗口。 |
8571
8572### completeTransition<sup>9+</sup>
8573
8574completeTransition(isCompleted: boolean): void
8575
8576设置属性转换的最终完成状态。该函数需要在动画函数[animateTo()](../arkui-ts/ts-explicit-animation.md)执行后设置。
8577
8578**系统接口:** 此接口为系统接口。
8579
8580**系统能力**:SystemCapability.WindowManager.WindowManager.Core
8581
8582**参数:**
8583
8584| 参数名      | 类型    | 必填 | 说明                                                         |
8585| ----------- | ------- | ---- | ------------------------------------------------------------ |
8586| isCompleted | boolean | 是   | 窗口属性转换是否完成。true表示完成本次转换;false表示撤销本次转换。 |
8587
8588**示例:**
8589
8590```ts
8591let windowClass: window.Window = window.findWindow("test");
8592(context: window.TransitionContext) => {
8593  let toWindow: window.Window = context.toWindow;
8594  animateTo({
8595    duration: 1000, // 动画时长
8596    tempo: 0.5, // 播放速率
8597    curve: Curve.EaseInOut, // 动画曲线
8598    delay: 0, // 动画延迟
8599    iterations: 1, // 播放次数
8600    playMode: PlayMode.Normal, // 动画模式
8601  }, () => {
8602    let obj: window.TranslateOptions = {
8603      x: 100.0,
8604      y: 0.0,
8605      z: 0.0
8606    };
8607    toWindow.translate(obj);
8608    console.info('toWindow translate end');
8609  }
8610  );
8611  try {
8612    context.completeTransition(true)
8613  } catch (exception) {
8614    console.info('toWindow translate fail. Cause: ' + JSON.stringify(exception));
8615  }
8616  console.info('complete transition end');
8617};
8618```
8619
8620## TransitionController<sup>9+</sup>
8621
8622属性转换控制器。
8623
8624### animationForShown<sup>9+</sup>
8625
8626animationForShown(context: TransitionContext): void
8627
8628窗口显示时的自定义动画配置。
8629
8630**系统接口:** 此接口为系统接口。
8631
8632**系统能力:** SystemCapability.WindowManager.WindowManager.Core
8633
8634**参数:**
8635
8636| 参数名  | 类型                                     | 必填 | 说明                 |
8637| ------- | ---------------------------------------- | ---- | -------------------- |
8638| context | [TransitionContext](#transitioncontext9) | 是   | 属性转换时的上下文。 |
8639
8640**示例:**
8641
8642```ts
8643let windowClass: window.Window = window.findWindow("test");
8644(context : window.TransitionContext) => {
8645  let toWindow: window.Window = context.toWindow;
8646  animateTo({
8647    duration: 1000, // 动画时长
8648    tempo: 0.5, // 播放速率
8649    curve: Curve.EaseInOut, // 动画曲线
8650    delay: 0, // 动画延迟
8651    iterations: 1, // 播放次数
8652    playMode: PlayMode.Normal, // 动画模式
8653    onFinish: ()=> {
8654      context.completeTransition(true)
8655    }
8656  }, () => {
8657    let obj : window.TranslateOptions = {
8658      x : 100.0,
8659      y : 0.0,
8660      z : 0.0
8661    };
8662    toWindow.translate(obj);
8663    console.info('toWindow translate end');
8664  }
8665  );
8666  console.info('complete transition end');
8667};
8668```
8669
8670### animationForHidden<sup>9+</sup>
8671
8672animationForHidden(context: TransitionContext): void
8673
8674窗口隐藏时的自定义动画配置。
8675
8676**系统接口:** 此接口为系统接口。
8677
8678**系统能力:** SystemCapability.WindowManager.WindowManager.Core
8679
8680**参数:**
8681
8682| 参数名  | 类型                                     | 必填 | 说明                 |
8683| ------- | ---------------------------------------- | ---- | -------------------- |
8684| context | [TransitionContext](#transitioncontext9) | 是   | 属性转换时的上下文。 |
8685
8686**示例:**
8687
8688```ts
8689let windowClass: window.Window = window.findWindow("test");
8690(context: window.TransitionContext) => {
8691  let toWindow: window.Window = context.toWindow;
8692  animateTo({
8693    duration: 1000, // 动画时长
8694    tempo: 0.5, // 播放速率
8695    curve: Curve.EaseInOut, // 动画曲线
8696    delay: 0, // 动画延迟
8697    iterations: 1, // 播放次数
8698    playMode: PlayMode.Normal, // 动画模式
8699    onFinish: () => {
8700      context.completeTransition(true)
8701    }
8702  }, () => {
8703    let obj: window.TranslateOptions = {
8704      x: 100.0,
8705      y: 0.0,
8706      z: 0.0
8707    };
8708    toWindow.translate(obj);
8709    console.info('toWindow translate end');
8710  }
8711  )
8712  console.info('complete transition end');
8713};
8714```
8715