js-apis-window.md 123.1 KB
Newer Older
Z
zengyawen 已提交
1 2
# 窗口

G
ge-yafang 已提交
3 4 5 6 7 8
窗口提供管理窗口的一些基础能力,包括对当前窗口的创建、销毁、各属性设置,以及对各窗口间的管理调度。

该模块提供以下窗口相关的常用功能:

- [Window](#window):当前窗口实例,窗口管理器管理的基本单元。
- [WindowStage](#windowstage9):窗口管理器。管理各个基本窗口单元。
G
ge-yafang 已提交
9

G
ge-yafang 已提交
10
> **说明:**
G
ge-yafang 已提交
11
>
12
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
Z
zengyawen 已提交
13 14 15

## 导入模块

G
ge-yafang 已提交
16
```js
Z
zengyawen 已提交
17 18 19
import window from '@ohos.window';
```

G
ge-yafang 已提交
20
## WindowType<sup>7+</sup>
C
chyyy0213 已提交
21

G
ge-yafang 已提交
22
窗口类型枚举。
C
chyyy0213 已提交
23

G
ge-yafang 已提交
24
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
25

G
ge-yafang 已提交
26
| 名称              | 值 | 说明               |
C
chyyy0213 已提交
27
| ----------------- | ------ | ------------------ |
G
ge-yafang 已提交
28
| TYPE_APP          | 0      | 表示应用子窗口。此接口仅可在FA模型下使用。 |
Z
zhirong 已提交
29
| TYPE_SYSTEM_ALERT | 1      | 表示系统告警窗口。 |
30 31 32 33 34 35
| TYPE_INPUT_METHOD<sup>9+</sup> | 2      | 表示输入法窗口。此接口仅可在Stage模型下使用。<br>此接口为系统接口。 |
| TYPE_STATUS_BAR<sup>9+</sup>   | 3      | 表示状态栏窗口。此接口仅可在Stage模型下使用。<br/>此接口为系统接口。 |
| TYPE_PANEL<sup>9+</sup>        | 4      | 表示通知栏。此接口仅可在Stage模型下使用。<br/>此接口为系统接口。 |
| TYPE_KEYGUARD<sup>9+</sup>     | 5      | 表示锁屏。此接口仅可在Stage模型下使用。<br/>此接口为系统接口。 |
| TYPE_VOLUME_OVERLAY<sup>9+</sup> | 6      | 表示音量条。此接口仅可在Stage模型下使用。<br/>此接口为系统接口。 |
| TYPE_NAVIGATION_BAR<sup>9+</sup> | 7      | 表示导航栏窗口。此接口仅可在Stage模型下使用。<br/>此接口为系统接口。 |
G
ge-yafang 已提交
36
| TYPE_FLOAT<sup>9+</sup> | 8      | 表示悬浮窗。此接口仅可在Stage模型下使用。<br>**需要权限:** ohos.permission.SYSTEM_FLOAT_WINDOW |
37 38 39 40 41 42
| TYPE_WALLPAPER<sup>9+</sup> | 9      | 表示壁纸。此接口仅可在Stage模型下使用。<br/>此接口为系统接口。 |
| TYPE_DESKTOP<sup>9+</sup> | 10      | 表示桌面。此接口仅可在Stage模型下使用。<br/>此接口为系统接口。 |
| TYPE_LAUNCHER_RECENT<sup>9+</sup> | 11      | 表示多任务中心。此接口仅可在Stage模型下使用。<br/>此接口为系统接口。 |
| TYPE_LAUNCHER_DOCK<sup>9+</sup> | 12      | 表示桌面Dock栏。此接口仅可在Stage模型下使用。<br/>此接口为系统接口。 |
| TYPE_VOICE_INTERACTION<sup>9+</sup> | 13      | 表示智慧语音。此接口仅可在Stage模型下使用。<br/>此接口为系统接口。 |
| TYPE_POINTER<sup>9+</sup> | 14      | 表示鼠标。此接口仅可在Stage模型下使用。<br/>此接口为系统接口。 |
Q
qianlf 已提交
43
| TYPE_FLOAT_CAMERA<sup>9+</sup> | 15      | 表示相机类型悬浮窗。此接口仅可在Stage模型下使用。<br>**需要权限:** ohos.permission.SYSTEM_FLOAT_WINDOW |
44
| TYPE_DIALOG<sup>9+</sup>  | 16      | 表示模态窗口。此接口仅可在Stage模型下使用。<br/>此接口为系统接口。 |
Z
zengyawen 已提交
45

G
ge-yafang 已提交
46
## AvoidAreaType<sup>7+</sup>
陈海莹 已提交
47

G
ge-yafang 已提交
48
窗口内容需要规避区域的类型枚举。
陈海莹 已提交
49

G
ge-yafang 已提交
50
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
51

52 53 54 55 56 57
| 名称                               | 值  | 说明              |
|----------------------------------|-----| ----------------- |
| TYPE_SYSTEM                      | 0   | 表示系统默认区域。|
| TYPE_CUTOUT                      | 1   | 表示刘海屏区域。  |
| TYPE_SYSTEM_GESTURE<sup>9+</sup> | 2   | 表示手势区域。    |
| TYPE_KEYBOARD<sup>9+</sup>       | 3   | 表示软键盘区域。  |
陈海莹 已提交
58

G
ge-yafang 已提交
59
## WindowMode<sup>7+</sup>
Z
zengyawen 已提交
60

G
ge-yafang 已提交
61
窗口模式枚举。
Z
zengyawen 已提交
62

63
此接口为系统接口。
C
chyyy0213 已提交
64

G
ge-yafang 已提交
65
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
66

G
ge-yafang 已提交
67 68 69 70 71 72 73
| 名称       | 值   | 说明                          |
| ---------- | ---- | ----------------------------- |
| UNDEFINED  | 1    | 表示APP未定义窗口模式。       |
| FULLSCREEN | 2    | 表示APP全屏模式。             |
| PRIMARY    | 3    | 表示APP分屏多窗口主要模式。   |
| SECONDARY  | 4    | 表示APP分屏多窗口次要模式。   |
| FLOATING   | 5    | 表示APP自由悬浮形式窗口模式。 |
Z
zengyawen 已提交
74

L
leafly2021 已提交
75 76 77 78
## WindowLayoutMode<sup>9+</sup>

窗口布局模式枚举。

79
此接口为系统接口。
L
leafly2021 已提交
80 81 82 83 84 85 86 87

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

| 名称       | 值   | 说明                          |
| ---------- | ---- | ----------------------------- |
| WINDOW_LAYOUT_MODE_CASCADE  | 0    | 表示使用层叠布局模式。       |
| WINDOW_LAYOUT_MODE_TILE | 1    | 表示使用平铺布局模式。             |

G
ge-yafang 已提交
88
## SystemBarProperties
Z
zengyawen 已提交
89

G
ge-yafang 已提交
90
状态栏、导航栏的属性。
Z
zengyawen 已提交
91

G
ge-yafang 已提交
92
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
93

C
chyyy0213 已提交
94 95
| 名称                                   | 参数类型 | 可读 | 可写 | 说明                                                         |
| -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ |
G
ge-yafang 已提交
96
| statusBarColor                         | string   | 是   | 是   | 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00``#FF00FF00`。 |
C
chyyy0213 已提交
97 98
| isStatusBarLightIcon<sup>7+</sup>      | boolean  | 否   | 是   | 状态栏图标是否为高亮状态。                                   |
| statusBarContentColor<sup>8+</sup>     | string   | 否   | 是   | 状态栏文字颜色。                                             |
G
ge-yafang 已提交
99
| navigationBarColor                     | string   | 是   | 是   | 导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00``#FF00FF00`。 |
C
chyyy0213 已提交
100 101
| isNavigationBarLightIcon<sup>7+</sup>  | boolean  | 否   | 否   | 导航栏图标是否为高亮状态。                                   |
| navigationBarContentColor<sup>8+</sup> | string   | 否   | 是   | 导航栏文字颜色。                                             |
C
chyyy0213 已提交
102

X
xpeng 已提交
103
## Orientation<sup>9+</sup>
X
xpeng 已提交
104

X
xpeng 已提交
105
窗口显示方向类型枚举。
X
xpeng 已提交
106 107 108 109 110 111 112 113

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

| 名称                                  | 值   | 说明                          |
| ------------------------------------- | ---- | ----------------------------- |
| UNSPECIFIED                           | 0    | 表示未定义方向模式,由系统判定。 |
| PORTRAIT                              | 1    | 表示竖屏显示模式。             |
| LANDSCAPE                             | 2    | 表示横屏显示模式。   |
X
xpeng 已提交
114
| PORTRAIT_INVERTED                     | 3    | 表示反向竖屏显示模式。   |
X
xpeng 已提交
115 116
| LANDSCAPE_INVERTED                    | 4    | 表示反向横屏显示模式。 |
| AUTO_ROTATION                         | 5    | 表示传感器自动旋转模式。 |
X
xpeng 已提交
117 118
| AUTO_ROTATION_PORTRAIT                | 6    | 表示传感器自动竖向旋转模式。 |
| AUTO_ROTATION_LANDSCAPE               | 7    | 表示传感器自动横向旋转模式。 |
X
xpeng 已提交
119
| AUTO_ROTATION_RESTRICTED              | 8    | 表示受开关控制的自动旋转模式。 |
X
xpeng 已提交
120 121
| AUTO_ROTATION_PORTRAIT_RESTRICTED     | 9    | 表示受开关控制的自动竖向旋转模式。 |
| AUTO_ROTATION_LANDSCAPE_RESTRICTED    | 10   | 表述受开关控制的自动横向旋转模式。 |
X
xpeng 已提交
122 123
| LOCKED                                | 11   | 表示锁定模式。 |

G
ge-yafang 已提交
124
## SystemBarRegionTint<sup>8+</sup>
C
chyyy0213 已提交
125 126 127

单个导航栏或状态栏回调信息。

128
此接口为系统接口。
C
chyyy0213 已提交
129

G
ge-yafang 已提交
130
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
131

C
chyyy0213 已提交
132 133
| 名称            | 参数类型                  | 可读 | 可写 | 说明                                                         |
| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
C
chyyy0213 已提交
134 135 136
| type            | [WindowType](#windowtype) | 是   | 是   | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 |
| isEnable        | boolean                   | 是   | 是   | 当前系统栏是否显示。                                         |
| region          | [Rect](#rect)             | 是   | 是   | 当前系统栏的位置及大小。                                     |
G
ge-yafang 已提交
137
| backgroundColor | string                    | 是   | 是   | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00``#FF00FF00`。 |
C
chyyy0213 已提交
138
| contentColor    | string                    | 是   | 是   | 系统栏文字颜色。                                             |
Z
zengyawen 已提交
139

G
ge-yafang 已提交
140
## SystemBarTintState<sup>8+</sup>
C
chyyy0213 已提交
141 142 143

当前系统栏回调信息集合。

144
此接口为系统接口。
C
chyyy0213 已提交
145

G
ge-yafang 已提交
146
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
147

G
ge-yafang 已提交
148 149 150 151
| 名称       | 参数类型                                            | 可读 | 可写 | 说明                         |
| ---------- | --------------------------------------------------- | ---- | ---- | ---------------------------- |
| displayId  | number                                              | 是   | 否   | 当前物理屏幕id。             |
| regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | 是   | 是   | 当前已改变的所有系统栏信息。 |
Z
zengyawen 已提交
152

G
ge-yafang 已提交
153
## Rect<sup>7+</sup>
Z
zengyawen 已提交
154

G
ge-yafang 已提交
155
窗口矩形区域。
Z
zengyawen 已提交
156

G
ge-yafang 已提交
157
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
158 159 160 161 162 163 164

| 名称   | 参数类型 | 可读 | 可写 | 说明               |
| ------ | -------- | ---- | ---- | ------------------ |
| left   | number   | 是   | 是   | 矩形区域的左边界。 |
| top    | number   | 是   | 是   | 矩形区域的上边界。 |
| width  | number   | 是   | 是   | 矩形区域的宽度。   |
| height | number   | 是   | 是   | 矩形区域的高度。   |
Z
zengyawen 已提交
165

G
ge-yafang 已提交
166
## AvoidArea<sup>7+</sup>
Z
zengyawen 已提交
167

G
ge-yafang 已提交
168
窗口内容规避区域。
Z
zengyawen 已提交
169

G
ge-yafang 已提交
170
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
171 172 173

| 名称       | 参数类型      | 可读 | 可写 | 说明               |
| ---------- | ------------- | ---- | ---- | ------------------ |
174
| visible<sup>9+</sup>    | boolean       | 是   | 是   | 规避区域是否可见。 |
C
chyyy0213 已提交
175 176 177 178
| leftRect   | [Rect](#rect) | 是   | 是   | 屏幕左侧的矩形区。 |
| topRect    | [Rect](#rect) | 是   | 是   | 屏幕顶部的矩形区。 |
| rightRect  | [Rect](#rect) | 是   | 是   | 屏幕右侧的矩形区。 |
| bottomRect | [Rect](#rect) | 是   | 是   | 屏幕底部的矩形区。 |
Z
zengyawen 已提交
179

G
ge-yafang 已提交
180
## Size<sup>7+</sup>
Z
zengyawen 已提交
181 182 183

窗口大小。

G
ge-yafang 已提交
184
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
185 186 187 188 189

| 名称   | 参数类型 | 可读 | 可写 | 说明       |
| ------ | -------- | ---- | ---- | ---------- |
| width  | number   | 是   | 是   | 窗口宽度。 |
| height | number   | 是   | 是   | 窗口高度。 |
Z
zengyawen 已提交
190

G
ge-yafang 已提交
191
## WindowProperties
Z
zengyawen 已提交
192 193 194

窗口属性。

G
ge-yafang 已提交
195
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
196

G
ge-yafang 已提交
197 198 199 200 201 202 203 204 205
| 名称                            | 参数类型                  | 可读 | 可写 | 说明                                         |
| ------------------------------- | ------------------------- | ---- | ---- | -------------------------------------------- |
| windowRect<sup>7+</sup>         | [Rect](#rect)             | 是   | 是   | 窗口尺寸。                                   |
| type<sup>7+</sup>               | [WindowType](#windowtype) | 是   | 是   | 窗口类型。                                   |
| isFullScreen                    | boolean                   | 是   | 是   | 是否全屏,默认为false。                      |
| isLayoutFullScreen<sup>7+</sup> | boolean                   | 是   | 是   | 窗口是否为沉浸式,默认为false。              |
| focusable<sup>7+</sup>          | boolean                   | 是   | 否   | 窗口是否可聚焦,默认为true。                 |
| touchable<sup>7+</sup>          | boolean                   | 是   | 否   | 窗口是否可触摸,默认为true。                 |
| brightness                      | number                    | 是   | 是   | 屏幕亮度, 取值范围为0~1,1表示最大亮度值。  |
Z
xxx  
zhirong 已提交
206
| dimBehindValue<sup>(deprecated)</sup>     | number                    | 是   | 是   | 靠后窗口的暗度值,取值范围为0~1,1表示最暗。<br>- **说明:** 从API version 9开始废弃。<br>- 从 API version 7开始支持|
G
ge-yafang 已提交
207 208 209 210
| isKeepScreenOn                  | boolean                   | 是   | 是   | 屏幕是否常亮,默认为false。                  |
| isPrivacyMode<sup>7+</sup>      | boolean                   | 是   | 是   | 隐私模式,默认为false。                      |
| isRoundCorner<sup>7+</sup>      | boolean                   | 是   | 是   | 窗口是否为圆角。默认为false。                |
| isTransparent<sup>7+</sup>      | boolean                   | 是   | 是   | 窗口是否透明。默认为false。                  |
Z
zengyawen 已提交
211

G
ge-yafang 已提交
212
## ColorSpace<sup>8+</sup>
Z
zengyawen 已提交
213

C
chyyy0213 已提交
214
色域模式。
Z
zengyawen 已提交
215

G
ge-yafang 已提交
216
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
217 218 219 220 221

| 名称       | 默认值 | 说明           |
| ---------- | ------ | -------------- |
| DEFAULT    | 0      | 默认色域模式。 |
| WIDE_GAMUT | 1      | 广色域模式。   |
Z
zengyawen 已提交
222

Z
zengyawen 已提交
223
## window.create<sup>7+</sup>
Z
zengyawen 已提交
224

C
chyyy0213 已提交
225
create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
Z
zengyawen 已提交
226

G
ge-yafang 已提交
227
创建子窗口,使用callback异步回调。
Z
zengyawen 已提交
228

G
ge-yafang 已提交
229
此接口仅可在FA模型下使用。
Z
zengyawen 已提交
230

G
ge-yafang 已提交
231
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
232

G
ge-yafang 已提交
233
**参数:** 
C
chyyy0213 已提交
234

G
ge-yafang 已提交
235 236 237 238 239
| 参数名   | 类型                                   | 必填 | 说明                                 |
| -------- | -------------------------------------- | ---- | ------------------------------------ |
| id       | string                                 | 是   | 窗口id。                             |
| type     | [WindowType](#windowtype)              | 是   | 窗口类型。                           |
| callback | AsyncCallback&lt;[Window](#window)&gt; | 是   | 回调函数。返回当前创建的子窗口对象。 |
Z
zengyawen 已提交
240

G
ge-yafang 已提交
241
**示例:** 
Z
zengyawen 已提交
242

G
ge-yafang 已提交
243 244 245 246 247 248 249 250 251 252
```js
var windowClass = null;
 let promise = window.create("first", window.WindowType.TYPE_APP);
 promise.then((data)=> {
 	windowClass = data;
    console.info('SubWindow created. Data: ' + JSON.stringify(data));
 }).catch((err)=>{
    console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
 });
```
C
chyyy0213 已提交
253

Z
zengyawen 已提交
254
## window.create<sup>7+</sup>
C
chyyy0213 已提交
255 256 257

create(id: string, type: WindowType): Promise&lt;Window&gt;

G
ge-yafang 已提交
258
创建子窗口,使用Promise异步回调。
C
chyyy0213 已提交
259

G
ge-yafang 已提交
260
此接口仅可在FA模型下使用。
Z
zengyawen 已提交
261

G
ge-yafang 已提交
262
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
263

G
ge-yafang 已提交
264
**参数:** 
C
chyyy0213 已提交
265

G
ge-yafang 已提交
266 267 268 269
| 参数名 | 类型                      | 必填 | 说明       |
| ------ | ------------------------- | ---- | ---------- |
| id     | string                    | 是   | 窗口id。   |
| type   | [WindowType](#windowtype) | 是   | 窗口类型。 |
C
chyyy0213 已提交
270

G
ge-yafang 已提交
271
**返回值:** 
C
chyyy0213 已提交
272

G
ge-yafang 已提交
273 274 275
| 类型                             | 说明                                    |
| -------------------------------- | --------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前创建的子窗口对象。 |
C
chyyy0213 已提交
276

G
ge-yafang 已提交
277
**示例:** 
C
chyyy0213 已提交
278

G
ge-yafang 已提交
279 280 281 282 283 284 285 286 287 288
```js
var windowClass = null;
let promise = window.create("first", window.WindowType.TYPE_APP);
promise.then((data)=> {
    windowClass = data;
    console.info('SubWindow created. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
289

C
chyyy0213 已提交
290
## window.create<sup>8+</sup>
Z
zengyawen 已提交
291

C
chyyy0213 已提交
292
create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
Z
zengyawen 已提交
293

G
ge-yafang 已提交
294
创建子窗口,使用callback异步回调,其中Context详见[Context](js-apis-Context.md)
G
ge-yafang 已提交
295

G
ge-yafang 已提交
296
从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用callback异步回调。
Z
zengyawen 已提交
297

G
ge-yafang 已提交
298
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
299

G
ge-yafang 已提交
300
**参数:** 
Z
zengyawen 已提交
301

G
ge-yafang 已提交
302 303 304 305 306
| 参数名   | 类型                                   | 必填 | 说明                                                         |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| ctx      | Context                                | 是   | 当前应用上下文信息。<br>API version 8的Context定义见[Context](js-apis-Context.md)<br>API version 9的Context定义见[Context](js-apis-service-extension-context.md)。 |
| id       | string                                 | 是   | 窗口id。                                                     |
| type     | [WindowType](#windowtype)              | 是   | 窗口类型。                                                   |
G
ge-yafang 已提交
307
| callback | AsyncCallback&lt;[Window](#window)&gt; | 是   | 回调函数。返回当前创建的子窗口对象。                         |
Z
zengyawen 已提交
308

G
ge-yafang 已提交
309
**示例:** 
Z
zengyawen 已提交
310

G
ge-yafang 已提交
311 312 313 314 315 316 317 318 319 320 321 322
```js
var windowClass = null;
 window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
    if (err.code) {
        console.error('Failed to create the Window. Cause: ' + JSON.stringify(err));
        return;
    }
    windowClass = data;
    console.info('Window created. Data: ' + JSON.stringify(data));
    windowClass.resetSize(500, 1000);
});
```
C
chyyy0213 已提交
323 324 325

## window.create<sup>8+</sup>

C
chyyy0213 已提交
326
create(ctx: Context, id: string, type: WindowType): Promise&lt;Window&gt;
C
chyyy0213 已提交
327

G
ge-yafang 已提交
328
创建子窗口,使用Promise异步回调,其中Context详见[Context](js-apis-Context.md)
G
ge-yafang 已提交
329

G
ge-yafang 已提交
330
从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用Promise异步回调。
C
chyyy0213 已提交
331

G
ge-yafang 已提交
332
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
333

G
ge-yafang 已提交
334
**参数:** 
C
chyyy0213 已提交
335

G
ge-yafang 已提交
336 337 338 339 340
| 参数名 | 类型                      | 必填 | 说明                                                         |
| ------ | ------------------------- | ---- | ------------------------------------------------------------ |
| ctx    | Context                   | 是   | 当前应用上下文信息。<br/>API version 8的Context定义见[Context](js-apis-Context.md)<br/>API version 9的Context定义见[Context](js-apis-service-extension-context.md)。 |
| id     | string                    | 是   | 窗口id。                                                     |
| type   | [WindowType](#windowtype) | 是   | 窗口类型。                                                   |
C
chyyy0213 已提交
341

G
ge-yafang 已提交
342
**返回值:** 
C
chyyy0213 已提交
343

G
ge-yafang 已提交
344 345 346
| 类型                             | 说明                                    |
| -------------------------------- | --------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前创建的子窗口对象。 |
C
chyyy0213 已提交
347

G
ge-yafang 已提交
348
**示例:** 
C
chyyy0213 已提交
349

G
ge-yafang 已提交
350 351 352 353 354 355 356 357 358 359
```js
var windowClass = null;
let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT);
promise.then((data)=> {
 	windowClass = data;
    console.info('Window created. Data:' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
});
```
Z
zengyawen 已提交
360

G
ge-yafang 已提交
361
## window.find<sup>7+</sup>
Z
zengyawen 已提交
362 363 364

find(id: string, callback: AsyncCallback&lt;Window&gt;): void

G
ge-yafang 已提交
365
查找id所对应的窗口,使用callback异步回调。
C
chyyy0213 已提交
366

G
ge-yafang 已提交
367
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
368

G
ge-yafang 已提交
369
**参数:** 
C
chyyy0213 已提交
370

G
ge-yafang 已提交
371 372 373 374
| 参数名   | 类型                                   | 必填 | 说明                                 |
| -------- | -------------------------------------- | ---- | ------------------------------------ |
| id       | string                                 | 是   | 窗口id。                             |
| callback | AsyncCallback&lt;[Window](#window)&gt; | 是   | 回调函数。返回当前查找到的窗口对象。 |
Z
zengyawen 已提交
375

G
ge-yafang 已提交
376
**示例:** 
C
chyyy0213 已提交
377

G
ge-yafang 已提交
378 379 380 381 382 383 384 385 386 387 388
```js
var windowClass = null;
 window.find("alertWindow", (err, data) => {
   if (err.code) {
       console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
       return;
   }
   windowClass = data;
   console.info('window found. Data: ' + JSON.stringify(data));
});
```
C
chyyy0213 已提交
389 390 391 392 393

## window.find<sup>7+</sup>

find(id: string): Promise&lt;Window&gt;

G
ge-yafang 已提交
394
查找id所对应的窗口,使用Promise异步回调。
C
chyyy0213 已提交
395

G
ge-yafang 已提交
396
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
397

G
ge-yafang 已提交
398
**参数:** 
C
chyyy0213 已提交
399

G
ge-yafang 已提交
400 401 402
| 参数名 | 类型   | 必填 | 说明     |
| ------ | ------ | ---- | -------- |
| id     | string | 是   | 窗口id。 |
C
chyyy0213 已提交
403

G
ge-yafang 已提交
404
**返回值:** 
C
chyyy0213 已提交
405

G
ge-yafang 已提交
406 407 408
| 类型                             | 说明                                  |
| -------------------------------- | ------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前查找的窗口对象。 |
C
chyyy0213 已提交
409

G
ge-yafang 已提交
410
**示例:** 
C
chyyy0213 已提交
411

G
ge-yafang 已提交
412 413 414 415 416 417 418 419 420 421
```js
var windowClass = null;
let promise = window.find("alertWindow");
promise.then((data)=> {
 	windowClass = data;
    console.info('window found. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
});
```
Z
zengyawen 已提交
422

G
ge-yafang 已提交
423
## window.getTopWindow
Z
zengyawen 已提交
424

C
chyyy0213 已提交
425
getTopWindow(callback: AsyncCallback&lt;Window&gt;): void
Z
zengyawen 已提交
426

G
ge-yafang 已提交
427
获取当前应用内最后显示的窗口,使用callback异步回调。
Z
zengyawen 已提交
428

G
ge-yafang 已提交
429
此接口仅可在FA模型下使用。
G
ge-yafang 已提交
430

G
ge-yafang 已提交
431
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
432

G
ge-yafang 已提交
433
**参数:** 
C
chyyy0213 已提交
434

G
ge-yafang 已提交
435 436 437
| 参数名   | 类型                                   | 必填 | 说明                                         |
| -------- | -------------------------------------- | ---- | -------------------------------------------- |
| callback | AsyncCallback&lt;[Window](#window)&gt; | 是   | 回调函数。返回当前应用内最后显示的窗口对象。 |
Z
zengyawen 已提交
438

G
ge-yafang 已提交
439
**示例:** 
C
chyyy0213 已提交
440

G
ge-yafang 已提交
441 442 443 444 445 446 447 448 449 450 451
```js
var windowClass = null;
window.getTopWindow((err, data) => {
    if (err.code) {
        console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
        return;
    }
    windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
});
```
Z
zengyawen 已提交
452

C
chyyy0213 已提交
453 454 455 456
## window.getTopWindow

getTopWindow(): Promise&lt;Window&gt;

G
ge-yafang 已提交
457
获取当前应用内最后显示的窗口,使用Promise异步回调。
C
chyyy0213 已提交
458

G
ge-yafang 已提交
459
此接口仅可在FA模型下使用。
G
ge-yafang 已提交
460

G
ge-yafang 已提交
461
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
462

G
ge-yafang 已提交
463
**返回值:** 
C
chyyy0213 已提交
464

G
ge-yafang 已提交
465 466 467
| 类型                             | 说明                                            |
| -------------------------------- | ----------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前应用内最后显示的窗口对象。 |
C
chyyy0213 已提交
468

G
ge-yafang 已提交
469
**示例:** 
C
chyyy0213 已提交
470

G
ge-yafang 已提交
471 472 473 474 475 476 477 478 479 480
```js
var windowClass = null;
let promise = window.getTopWindow();
promise.then((data)=> {
 	windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
})
```
C
chyyy0213 已提交
481 482

## window.getTopWindow<sup>8+</sup>
Z
zengyawen 已提交
483

C
chyyy0213 已提交
484
getTopWindow(ctx: Context, callback: AsyncCallback&lt;Window&gt;): void
Z
zengyawen 已提交
485

G
ge-yafang 已提交
486
获取当前应用内最后显示的窗口,使用callback异步回调。
Z
zengyawen 已提交
487

G
ge-yafang 已提交
488
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
489

G
ge-yafang 已提交
490
**参数:** 
C
chyyy0213 已提交
491

G
ge-yafang 已提交
492 493 494
| 参数名   | 类型                                   | 必填 | 说明                                                         |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| ctx      | Context                                | 是   | 当前应用上下文信息。<br>API version 8的Context定义见[Context](js-apis-Context.md)<br>API version 9的Context定义见[Context](js-apis-ability-context.md)。 |
G
ge-yafang 已提交
495
| callback | AsyncCallback&lt;[Window](#window)&gt; | 是   | 回调函数。返回当前应用内最后显示的窗口对象。                 |
Z
zengyawen 已提交
496

G
ge-yafang 已提交
497
**示例:** 
C
chyyy0213 已提交
498

G
ge-yafang 已提交
499 500 501 502 503 504 505 506 507 508 509
```js
var windowClass = null;
window.getTopWindow(this.context, (err, data) => {
    if (err.code) {
        console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
        return;
    }
    windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
});
```
Z
zengyawen 已提交
510

C
chyyy0213 已提交
511 512 513 514
## window.getTopWindow<sup>8+</sup>

getTopWindow(ctx: Context): Promise&lt;Window&gt;

G
ge-yafang 已提交
515
获取当前应用内最后显示的窗口,使用Promise异步回调。
C
chyyy0213 已提交
516

G
ge-yafang 已提交
517
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
518

G
ge-yafang 已提交
519
**参数:** 
C
chyyy0213 已提交
520

G
ge-yafang 已提交
521 522 523
| 参数名 | 类型    | 必填 | 说明                                                         |
| ------ | ------- | ---- | ------------------------------------------------------------ |
| ctx    | Context | 是   | 当前应用上下文信息。<br/>API version 8的Context定义见[Context](js-apis-Context.md)<br/>API version 9的Context定义见[Context](js-apis-ability-context.md)。 |
C
chyyy0213 已提交
524

G
ge-yafang 已提交
525
**返回值:** 
C
chyyy0213 已提交
526

G
ge-yafang 已提交
527 528 529
| 类型                             | 说明                                            |
| -------------------------------- | ----------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前应用内最后显示的窗口对象。 |
C
chyyy0213 已提交
530

G
ge-yafang 已提交
531
**示例:** 
C
chyyy0213 已提交
532

G
ge-yafang 已提交
533 534 535 536 537 538 539 540 541 542
```js
var windowClass = null;
let promise = window.getTopWindow(this.context);
promise.then((data)=> {
 	windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
})
```
C
chyyy0213 已提交
543

L
leafly2021 已提交
544 545 546 547 548
## window.minimizeAll<sup>9+</sup>
minimizeAll(id: number, callback: AsyncCallback&lt;void&gt;): void

最小化某显示设备下的所有窗口。

549
此接口为系统接口。
L
leafly2021 已提交
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名   | 类型                      | 必填 | 说明           |
| -------- | ------------------------- | ---- | -------------- |
| id       | number                    | 是   | 显示设备[Display](js-apis-display.md#display)的ID号 |
| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。     |

**示例:**

```js
import display from '@ohos.display'
import window from '@ohos.window'

var displayClass = null;
display.getDefaultDisplay((err, data) => {
    if(err.code) {
        return;
    }
    displayClass = data;
    window.minimizeAll(displayClass.id, (err, data) => {
        if(err.code) {
574
            console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
L
leafly2021 已提交
575 576
            return;
        }
577
        console.info('Succeeded in minimizing all windows.');
L
leafly2021 已提交
578 579 580 581 582 583 584 585 586
    });
});
```

## window.minimizeAll<sup>9+</sup>
minimizeAll(id: number): Promise&lt;void&gt;

最小化某显示设备下的所有窗口。

587
此接口为系统接口。
L
leafly2021 已提交
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名   | 类型                      | 必填 | 说明           |
| -------- | ------------------------- | ---- | -------------- |
| id       | number                    | 是   | 显示设备[Display](js-apis-display.md#display)的ID号 |

**返回值:** 

| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |

**示例:**

```js
import display from '@ohos.display'
import window from '@ohos.window'

var displayClass = null;
display.getDefaultDisplay((err, data) => {
    if(err.code) {
        return;
    }
    displayClass = data;
    let promise = window.minimizeAll(displayClass.id);
    promise.then((data)=> {
617
        console.info('Succeeded in minimizing all windows.');
L
leafly2021 已提交
618
    }).catch((err)=>{
619
        console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
L
leafly2021 已提交
620 621 622 623 624 625 626 627 628
    })
});
```

## window.toggleShownStateForAllAppWindows<sup>9+</sup>
toggleShownStateForAllAppWindows(callback: AsyncCallback&lt;void&gt;): void

多窗口快速切换时隐藏或者恢复应用窗口。

629
此接口为系统接口。
L
leafly2021 已提交
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名   | 类型                      | 必填 | 说明           |
| -------- | ------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。     |

**示例:**

```js
window.toggleShownStateForAllAppWindows((err, data) => {
    if (err.code) {
        console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in toggling shown state for all app windows.');
})
```

## window.toggleShownStateForAllAppWindows<sup>9+</sup>
toggleShownStateForAllAppWindows(): Promise&lt;void&gt;

多窗口快速切换时隐藏或者恢复应用窗口。

656
此接口为系统接口。
L
leafly2021 已提交
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**返回值:** 

| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |

**示例:**

```js
let promise = window.toggleShownStateForAllAppWindows();
promise.then((data)=> {
    console.info('Succeeded in toggling shown state for all app windows. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
})
```

## window.setWindowLayoutMode<sup>9+</sup>
setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback&lt;void&gt;): void

设置窗口布局模式。

682
此接口为系统接口。
L
leafly2021 已提交
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名   | 类型                      | 必填 | 说明           |
| -------- | ------------------------- | ---- | -------------- |
| mode       | [WindowLayoutMode](#windowlayoutmode9)                  | 是   | 设置的窗口布局模式 |
| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。     |

**示例:**

```js
window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (data) => {
    console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data));
});
```

## window.setWindowLayoutMode<sup>9+</sup>
setWindowLayoutMode(mode: WindowLayoutMode): Promise&lt;void&gt;

设置窗口布局模式。

706
此接口为系统接口。
L
leafly2021 已提交
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名   | 类型                      | 必填 | 说明           |
| -------- | ------------------------- | ---- | -------------- |
| mode       | [WindowLayoutMode](#windowlayoutmode9)                    | 是   | 设置的窗口布局模式 |

**返回值:** 

| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |

**示例:**

```js
let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE);
promise.then((data)=> {
    console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
})
```

C
chyyy0213 已提交
733
## on('systemBarTintChange')<sup>8+</sup>
Z
zengyawen 已提交
734

C
chyyy0213 已提交
735
on(type: 'systemBarTintChange', callback: Callback&lt;SystemBarTintState&gt;): void
Z
zengyawen 已提交
736

G
ge-yafang 已提交
737
开启状态栏、导航栏属性变化的监听。
Z
zengyawen 已提交
738

739
此接口为系统接口。
C
chyyy0213 已提交
740

G
ge-yafang 已提交
741
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
742

G
ge-yafang 已提交
743
**参数:** 
C
chyyy0213 已提交
744

G
ge-yafang 已提交
745 746 747
| 参数名   | 类型                                                      | 必填 | 说明                                                         |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | string                                                    | 是   | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
G
ge-yafang 已提交
748
| callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | 是   | 回调函数。返回当前的状态栏、导航栏信息集合。                 |
Z
zengyawen 已提交
749

G
ge-yafang 已提交
750
**示例:** 
C
chyyy0213 已提交
751

G
ge-yafang 已提交
752 753 754 755 756
```js
window.on('systemBarTintChange', (data) => {
    console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
});
```
Z
zengyawen 已提交
757

C
chyyy0213 已提交
758
## off('systemBarTintChange')<sup>8+</sup>
Z
zengyawen 已提交
759

C
chyyy0213 已提交
760
off(type: 'systemBarTintChange', callback?: Callback&lt;SystemBarTintState &gt;): void
Z
zengyawen 已提交
761

G
ge-yafang 已提交
762
关闭状态栏、导航栏属性变化的监听。
Z
zengyawen 已提交
763

764
此接口为系统接口。
C
chyyy0213 已提交
765

G
ge-yafang 已提交
766
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
767

G
ge-yafang 已提交
768
**参数:** 
C
chyyy0213 已提交
769

G
ge-yafang 已提交
770 771 772
| 参数名   | 类型                                                      | 必填 | 说明                                                         |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | string                                                    | 是   | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
G
ge-yafang 已提交
773
| callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | 否   | 回调函数。返回当前的状态栏、导航栏信息集合。                 |
Z
zengyawen 已提交
774

G
ge-yafang 已提交
775
**示例:** 
C
chyyy0213 已提交
776

G
ge-yafang 已提交
777 778 779
```js
window.off('systemBarTintChange');
```
Z
zengyawen 已提交
780 781 782

## Window

G
ge-yafang 已提交
783 784
当前窗口实例,窗口管理器管理的基本单元。

G
ge-yafang 已提交
785
下列API示例中都需先使用[getTopWindow()](#windowgettopwindow)[create()](#windowcreate7)[find()](#windowfind7)中的任一方法获取到Window实例,再通过此实例调用对应方法。
Z
zengyawen 已提交
786

C
chyyy0213 已提交
787
### hide<sup>7+</sup>
Z
zengyawen 已提交
788

C
chyyy0213 已提交
789
hide (callback: AsyncCallback&lt;void&gt;): void
Z
zengyawen 已提交
790

G
ge-yafang 已提交
791
隐藏当前窗口,使用callback异步回调。
Z
zengyawen 已提交
792

793
此接口为系统接口。
C
chyyy0213 已提交
794

G
ge-yafang 已提交
795
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
796

G
ge-yafang 已提交
797
**参数:** 
C
chyyy0213 已提交
798

G
ge-yafang 已提交
799 800 801
| 参数名   | 类型                      | 必填 | 说明       |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
Z
zengyawen 已提交
802

G
ge-yafang 已提交
803
**示例:** 
C
chyyy0213 已提交
804

G
ge-yafang 已提交
805 806 807 808 809 810 811 812 813
```js
windowClass.hide((err, data) => {
    if (err.code) {
        console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('window hidden. data: ' + JSON.stringify(data));
})
```
Z
zengyawen 已提交
814

C
chyyy0213 已提交
815 816
### hide<sup>7+</sup>

C
chyyy0213 已提交
817
hide(): Promise&lt;void&gt;
C
chyyy0213 已提交
818

G
ge-yafang 已提交
819
隐藏当前窗口,使用Promise异步回调。
C
chyyy0213 已提交
820

821
此接口为系统接口。
C
chyyy0213 已提交
822

G
ge-yafang 已提交
823
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
824

G
ge-yafang 已提交
825
**返回值:** 
C
chyyy0213 已提交
826

G
ge-yafang 已提交
827 828 829
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
830

G
ge-yafang 已提交
831
**示例:** 
C
chyyy0213 已提交
832

G
ge-yafang 已提交
833 834 835 836 837 838 839 840
```js
let promise = windowClass.hide();
promise.then((data)=> {
    console.info('window hidden. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
})
```
C
chyyy0213 已提交
841

C
chyyy0213 已提交
842
### show<sup>7+</sup>
Z
zengyawen 已提交
843

C
chyyy0213 已提交
844
show(callback: AsyncCallback&lt;void&gt;): void
Z
zengyawen 已提交
845

G
ge-yafang 已提交
846
显示当前窗口,使用callback异步回调。
Z
zengyawen 已提交
847

G
ge-yafang 已提交
848
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
849

G
ge-yafang 已提交
850
**参数:** 
C
chyyy0213 已提交
851

G
ge-yafang 已提交
852 853 854
| 参数名   | 类型                      | 必填 | 说明       |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
Z
zengyawen 已提交
855

G
ge-yafang 已提交
856
**示例:** 
C
chyyy0213 已提交
857

G
ge-yafang 已提交
858 859 860 861 862 863 864 865 866
```js
windowClass.show((err, data) => {
    if (err.code) {
        console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
})
```
Z
zengyawen 已提交
867

C
chyyy0213 已提交
868 869 870 871
### show<sup>7+</sup>

show(): Promise&lt;void&gt;

G
ge-yafang 已提交
872
显示当前窗口,使用Promise异步回调。
C
chyyy0213 已提交
873

G
ge-yafang 已提交
874
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
875

G
ge-yafang 已提交
876
**返回值:** 
C
chyyy0213 已提交
877

G
ge-yafang 已提交
878 879 880
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
881

G
ge-yafang 已提交
882
**示例:** 
C
chyyy0213 已提交
883

G
ge-yafang 已提交
884 885 886 887 888 889 890 891
```js
let promise = windowClass.show();
promise.then((data)=> {
    console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
})
```
C
chyyy0213 已提交
892

C
chyyy0213 已提交
893 894 895
### destroy<sup>7+</sup>

destroy(callback: AsyncCallback&lt;void&gt;): void
Z
zengyawen 已提交
896

G
ge-yafang 已提交
897
销毁当前窗口,使用callback异步回调。
Z
zengyawen 已提交
898

G
ge-yafang 已提交
899
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
900

G
ge-yafang 已提交
901
**参数:** 
C
chyyy0213 已提交
902

G
ge-yafang 已提交
903 904 905
| 参数名   | 类型                      | 必填 | 说明       |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
Z
zengyawen 已提交
906

G
ge-yafang 已提交
907
**示例:** 
C
chyyy0213 已提交
908

G
ge-yafang 已提交
909 910 911 912 913 914 915 916 917
```js
windowClass.destroy((err, data) => {
    if (err.code) {
        console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data));
})
```
Z
zengyawen 已提交
918

C
chyyy0213 已提交
919 920 921 922
### destroy<sup>7+</sup>

destroy(): Promise&lt;void&gt;

G
ge-yafang 已提交
923
销毁当前窗口,使用Promise异步回调。
C
chyyy0213 已提交
924

G
ge-yafang 已提交
925
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
926

G
ge-yafang 已提交
927
**返回值:** 
C
chyyy0213 已提交
928

G
ge-yafang 已提交
929 930 931
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
932

G
ge-yafang 已提交
933
**示例:** 
C
chyyy0213 已提交
934

G
ge-yafang 已提交
935 936 937 938 939 940 941 942
```js
let promise = windowClass.destroy();
promise.then((data)=> {
    console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
})
```
C
chyyy0213 已提交
943

C
chyyy0213 已提交
944
### moveTo<sup>7+</sup>
Z
zengyawen 已提交
945

C
chyyy0213 已提交
946
moveTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void
Z
zengyawen 已提交
947

G
ge-yafang 已提交
948
移动窗口位置,使用callback异步回调。
C
chyyy0213 已提交
949

G
ge-yafang 已提交
950
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
951

G
ge-yafang 已提交
952
**参数:** 
C
chyyy0213 已提交
953

G
ge-yafang 已提交
954 955 956 957 958
| 参数名   | 类型                      | 必填 | 说明                                              |
| -------- | ------------------------- | ---- | ------------------------------------------------- |
| x        | number                    | 是   | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 |
| y        | number                    | 是   | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 |
| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                        |
Z
zengyawen 已提交
959

G
ge-yafang 已提交
960
**示例:** 
C
chyyy0213 已提交
961

G
ge-yafang 已提交
962 963 964 965 966 967 968 969 970 971
```js
windowClass.moveTo(300, 300, (err, data)=>{
    if (err.code) {
        console.error('Failed to move the window. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Window moved. Data: ' + JSON.stringify(data));

});
```
Z
zengyawen 已提交
972

C
chyyy0213 已提交
973 974 975 976
### moveTo<sup>7+</sup>

moveTo(x: number, y: number): Promise&lt;void&gt;

G
ge-yafang 已提交
977
移动窗口位置,使用Promise异步回调。
C
chyyy0213 已提交
978

G
ge-yafang 已提交
979
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
980

G
ge-yafang 已提交
981
**参数:** 
C
chyyy0213 已提交
982

G
ge-yafang 已提交
983 984 985 986
| 参数名 | 类型   | 必填 | 说明                                              |
| ------ | ------ | ---- | ------------------------------------------------- |
| x      | number | 是   | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 |
| y      | number | 是   | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 |
C
chyyy0213 已提交
987

G
ge-yafang 已提交
988
**返回值:** 
C
chyyy0213 已提交
989

G
ge-yafang 已提交
990 991 992
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
993

G
ge-yafang 已提交
994
**示例:** 
C
chyyy0213 已提交
995

G
ge-yafang 已提交
996 997 998 999 1000 1001 1002 1003
```js
let promise = windowClass.moveTo(300, 300);
promise.then((data)=> {
    console.info('Window moved. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
})
```
C
chyyy0213 已提交
1004

C
chyyy0213 已提交
1005 1006 1007
### resetSize<sup>7+</sup>

resetSize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void
Z
zengyawen 已提交
1008

G
ge-yafang 已提交
1009
改变当前窗口大小,使用callback异步回调。
Z
zengyawen 已提交
1010

G
ge-yafang 已提交
1011
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
1012

G
ge-yafang 已提交
1013
**参数:** 
C
chyyy0213 已提交
1014

G
ge-yafang 已提交
1015 1016 1017 1018 1019
| 参数名   | 类型                      | 必填 | 说明                       |
| -------- | ------------------------- | ---- | -------------------------- |
| width    | number                    | 是   | 目标窗口的宽度,单位为px。 |
| height   | number                    | 是   | 目标窗口的高度,单位为px。 |
| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。                 |
Z
zengyawen 已提交
1020

G
ge-yafang 已提交
1021
**示例:** 
C
chyyy0213 已提交
1022

G
ge-yafang 已提交
1023 1024 1025 1026 1027 1028 1029 1030 1031
```js
windowClass.resetSize(500, 1000, (err, data) => {
    if (err.code) {
        console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Window size changed. Data: ' + JSON.stringify(data));
});
```
Z
zengyawen 已提交
1032

C
chyyy0213 已提交
1033 1034 1035 1036
### resetSize<sup>7+</sup>

resetSize(width: number, height: number): Promise&lt;void&gt;

G
ge-yafang 已提交
1037
改变当前窗口大小,使用Promise异步回调。
C
chyyy0213 已提交
1038

G
ge-yafang 已提交
1039
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1040

G
ge-yafang 已提交
1041
**参数:** 
C
chyyy0213 已提交
1042

G
ge-yafang 已提交
1043 1044 1045 1046
| 参数名 | 类型   | 必填 | 说明                       |
| ------ | ------ | ---- | -------------------------- |
| width  | number | 是   | 目标窗口的宽度,单位为px。 |
| height | number | 是   | 目标窗口的高度,单位为px。 |
C
chyyy0213 已提交
1047

G
ge-yafang 已提交
1048
**返回值:** 
C
chyyy0213 已提交
1049

G
ge-yafang 已提交
1050 1051 1052
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
1053

G
ge-yafang 已提交
1054
**示例:** 
C
chyyy0213 已提交
1055

G
ge-yafang 已提交
1056 1057 1058 1059 1060 1061 1062 1063
```js
let promise = windowClass.resetSize(500, 1000);
promise.then((data)=> {
    console.info('Window size changed. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
1064

1065 1066 1067 1068
### setWindowType<sup>7+</sup>

setWindowType(type: WindowType, callback: AsyncCallback&lt;void&gt;): void

G
ge-yafang 已提交
1069
设置窗口类型,使用callback异步回调。
1070

1071
此接口为系统接口。
C
chyyy0213 已提交
1072

G
ge-yafang 已提交
1073
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1074

G
ge-yafang 已提交
1075
**参数:** 
C
chyyy0213 已提交
1076

G
ge-yafang 已提交
1077 1078 1079 1080
| 参数名   | 类型                      | 必填 | 说明       |
| -------- | ------------------------- | ---- | ---------- |
| type     | [WindowType](#windowtype) | 是   | 窗口类型。 |
| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
1081

G
ge-yafang 已提交
1082
**示例:** 
C
chyyy0213 已提交
1083

G
ge-yafang 已提交
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093
```js
var type = window.WindowType.TYPE_APP;
windowClass.setWindowType(type, (err, data) => {
  if (err.code) {
      console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
      return;
  }
  console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data));
});
```
1094

C
chyyy0213 已提交
1095 1096 1097 1098
### setWindowType<sup>7+</sup>

setWindowType(type: WindowType): Promise&lt;void&gt;

G
ge-yafang 已提交
1099
设置窗口类型,使用Promise异步回调。
C
chyyy0213 已提交
1100

1101
此接口为系统接口。
C
chyyy0213 已提交
1102

G
ge-yafang 已提交
1103
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1104

G
ge-yafang 已提交
1105
**参数:** 
C
chyyy0213 已提交
1106

G
ge-yafang 已提交
1107 1108 1109
| 参数名 | 类型                      | 必填 | 说明       |
| ------ | ------------------------- | ---- | ---------- |
| type   | [WindowType](#windowtype) | 是   | 窗口类型。 |
C
chyyy0213 已提交
1110

G
ge-yafang 已提交
1111
**返回值:** 
C
chyyy0213 已提交
1112

G
ge-yafang 已提交
1113 1114 1115
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
1116

G
ge-yafang 已提交
1117
**示例:** 
C
chyyy0213 已提交
1118

G
ge-yafang 已提交
1119 1120 1121 1122 1123 1124 1125 1126 1127
```js
var type = window.WindowType.TYPE_APP;
let promise = windowClass.setWindowType(type);
promise.then((data)=> {
    console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
1128

C
chyyy0213 已提交
1129
### getProperties
Z
zengyawen 已提交
1130

C
chyyy0213 已提交
1131
getProperties(callback: AsyncCallback&lt;WindowProperties&gt;): void
Z
zengyawen 已提交
1132

G
ge-yafang 已提交
1133
获取当前窗口的属性,使用callback异步回调,返回WindowProperties。
Z
zengyawen 已提交
1134

G
ge-yafang 已提交
1135
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
1136

G
ge-yafang 已提交
1137
**参数:** 
C
chyyy0213 已提交
1138

G
ge-yafang 已提交
1139 1140 1141
| 参数名   | 类型                                                       | 必填 | 说明                         |
| -------- | ---------------------------------------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;[WindowProperties](#windowproperties)&gt; | 是   | 回调函数。返回当前窗口属性。 |
Z
zengyawen 已提交
1142

G
ge-yafang 已提交
1143
**示例:** 
C
chyyy0213 已提交
1144

G
ge-yafang 已提交
1145 1146 1147 1148 1149 1150 1151 1152 1153
```js
windowClass.getProperties((err, data) => {
    if (err.code) {
        console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
});
```
Z
zengyawen 已提交
1154

C
chyyy0213 已提交
1155 1156 1157 1158
### getProperties

getProperties(): Promise&lt;WindowProperties&gt;

G
ge-yafang 已提交
1159
获取当前窗口的属性,使用Promise异步回调,返回WindowProperties。
C
chyyy0213 已提交
1160

G
ge-yafang 已提交
1161
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1162

G
ge-yafang 已提交
1163
**返回值:** 
C
chyyy0213 已提交
1164

G
ge-yafang 已提交
1165 1166 1167
| 类型                                                 | 说明                            |
| ---------------------------------------------------- | ------------------------------- |
| Promise&lt;[WindowProperties](#windowproperties)&gt; | Promise对象。返回当前窗口属性。 |
C
chyyy0213 已提交
1168

G
ge-yafang 已提交
1169
**示例:** 
C
chyyy0213 已提交
1170

G
ge-yafang 已提交
1171 1172 1173 1174 1175 1176 1177 1178
```js
let promise = windowClass.getProperties();
promise.then((data)=> {
    console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
1179

C
chyyy0213 已提交
1180
### getAvoidArea<sup>7+</sup>
Z
zengyawen 已提交
1181

1182
getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt;): void
Z
zengyawen 已提交
1183

G
ge-yafang 已提交
1184
获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用callback异步回调。
C
chyyy0213 已提交
1185

G
ge-yafang 已提交
1186
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
1187

G
ge-yafang 已提交
1188
**参数:** 
C
chyyy0213 已提交
1189

1190 1191 1192 1193
| 参数名   | 类型                                            | 必填 | 说明                                                         |
| -------- |-----------------------------------------------| ---- | ------------------------------------------------------------ |
| type     | [AvoidAreaType](#avoidareatype7)              | 是   | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 |
| callback | AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt; | 是   | 回调函数。返回窗口内容规避区域。                             |
Z
zengyawen 已提交
1194

G
ge-yafang 已提交
1195
**示例:** 
C
chyyy0213 已提交
1196

G
ge-yafang 已提交
1197 1198 1199 1200 1201 1202 1203 1204 1205 1206
```js
var type = window.AvoidAreaType.TYPE_SYSTEM;
windowClass.getAvoidArea(type, (err, data) => {
    if (err.code) {
        console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
});
```
Z
zengyawen 已提交
1207

C
chyyy0213 已提交
1208 1209
### getAvoidArea<sup>7+</sup>

1210
getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise&lt;[AvoidArea](#avoidarea7)&gt;
C
chyyy0213 已提交
1211

G
ge-yafang 已提交
1212
获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用Promise异步回调。
C
chyyy0213 已提交
1213

G
ge-yafang 已提交
1214
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1215

G
ge-yafang 已提交
1216
**参数:** 
C
chyyy0213 已提交
1217

1218 1219 1220
| 参数名 | 类型                               | 必填 | 说明                                                         |
| ------ |----------------------------------| ---- | ------------------------------------------------------------ |
| type   | [AvoidAreaType](#avoidareatype7) | 是   | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 |
C
chyyy0213 已提交
1221

G
ge-yafang 已提交
1222
**返回值:** 
C
chyyy0213 已提交
1223

1224 1225 1226
| 类型                                      | 说明                                |
|-----------------------------------------| ----------------------------------- |
| Promise&lt;[AvoidArea](#avoidarea7)&gt; | Promise对象。返回窗口内容规避区域。 |
C
chyyy0213 已提交
1227

G
ge-yafang 已提交
1228
**示例:** 
C
chyyy0213 已提交
1229

G
ge-yafang 已提交
1230 1231 1232 1233 1234 1235 1236 1237
```js
let promise = windowClass.getAvoidArea();
promise.then((data)=> {
    console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
1238

C
chyyy0213 已提交
1239 1240 1241
### setFullScreen

setFullScreen(isFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void
Z
zengyawen 已提交
1242

G
ge-yafang 已提交
1243
设置是否为全屏状态,使用callback异步回调。
Z
zengyawen 已提交
1244

G
ge-yafang 已提交
1245
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
1246

G
ge-yafang 已提交
1247
**参数:** 
C
chyyy0213 已提交
1248

G
ge-yafang 已提交
1249 1250 1251 1252
| 参数名       | 类型                      | 必填 | 说明                                           |
| ------------ | ------------------------- | ---- | ---------------------------------------------- |
| isFullScreen | boolean                   | 是   | 是否设为全屏状态,且全屏状态隐藏状态栏导航栏。 |
| callback     | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                     |
Z
zengyawen 已提交
1253

G
ge-yafang 已提交
1254
**示例:** 
C
chyyy0213 已提交
1255

G
ge-yafang 已提交
1256 1257 1258 1259 1260 1261 1262 1263 1264 1265
```js
var isFullScreen = true;
windowClass.setFullScreen(isFullScreen, (err, data) => {
    if (err.code) {
        console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
});
```
C
chyyy0213 已提交
1266 1267 1268 1269 1270

### setFullScreen

setFullScreen(isFullScreen: boolean): Promise&lt;void&gt;

G
ge-yafang 已提交
1271
设置是否为全屏状态,使用Promise异步回调。
C
chyyy0213 已提交
1272

G
ge-yafang 已提交
1273
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1274

G
ge-yafang 已提交
1275
**参数:** 
C
chyyy0213 已提交
1276

G
ge-yafang 已提交
1277 1278 1279
| 参数名       | 类型    | 必填 | 说明                                           |
| ------------ | ------- | ---- | ---------------------------------------------- |
| isFullScreen | boolean | 是   | 是否设为全屏状态,且全屏状态隐藏状态栏导航栏。 |
C
chyyy0213 已提交
1280

G
ge-yafang 已提交
1281
**返回值:** 
C
chyyy0213 已提交
1282

G
ge-yafang 已提交
1283 1284 1285
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
1286

G
ge-yafang 已提交
1287
**示例:** 
C
chyyy0213 已提交
1288

G
ge-yafang 已提交
1289 1290 1291 1292 1293 1294 1295 1296 1297
```js
var isFullScreen = true;
let promise = windowClass.setFullScreen(isFullScreen);
promise.then((data)=> {
    console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
});
```
Z
zengyawen 已提交
1298

C
chyyy0213 已提交
1299 1300 1301
### setLayoutFullScreen<sup>7+</sup>

setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void
Z
zengyawen 已提交
1302

G
ge-yafang 已提交
1303
设置窗口的布局是否为全屏显示状态,使用callback异步回调。
Z
zengyawen 已提交
1304

G
ge-yafang 已提交
1305
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
1306

G
ge-yafang 已提交
1307
**参数:** 
C
chyyy0213 已提交
1308

G
ge-yafang 已提交
1309 1310 1311 1312
| 参数名             | 类型                      | 必填 | 说明                                                         |
| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ |
| isLayoutFullScreen | boolean                   | 是   | 窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。 |
| callback           | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                                   |
Z
zengyawen 已提交
1313

G
ge-yafang 已提交
1314
**示例:** 
C
chyyy0213 已提交
1315

G
ge-yafang 已提交
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325
```js
var isLayoutFullScreen= true;
windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => {
    if (err.code) {
        console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data));
});
```
C
chyyy0213 已提交
1326 1327 1328 1329 1330

### setLayoutFullScreen<sup>7+</sup>

setLayoutFullScreen(isLayoutFullScreen: boolean): Promise&lt;void&gt;

G
ge-yafang 已提交
1331
设置窗口的布局是否为全屏显示状态,使用Promise异步回调。
C
chyyy0213 已提交
1332

G
ge-yafang 已提交
1333
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1334

G
ge-yafang 已提交
1335
**参数:** 
C
chyyy0213 已提交
1336

G
ge-yafang 已提交
1337 1338 1339
| 参数名             | 类型    | 必填 | 说明                                                         |
| ------------------ | ------- | ---- | ------------------------------------------------------------ |
| isLayoutFullScreen | boolean | 是   | 窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。 |
C
chyyy0213 已提交
1340

G
ge-yafang 已提交
1341
**返回值:** 
C
chyyy0213 已提交
1342

G
ge-yafang 已提交
1343 1344 1345
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
1346

G
ge-yafang 已提交
1347
**示例:** 
C
chyyy0213 已提交
1348

G
ge-yafang 已提交
1349 1350 1351 1352 1353 1354 1355 1356 1357
```js
var isLayoutFullScreen = true;
let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen);
promise.then((data)=> {
    console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
});
```
Z
zengyawen 已提交
1358 1359 1360

### setSystemBarEnable<sup>7+</sup>

C
chyyy0213 已提交
1361
setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback&lt;void&gt;): void
Z
zengyawen 已提交
1362

G
ge-yafang 已提交
1363
设置导航栏、状态栏的可见模式,使用callback异步回调。
Z
zengyawen 已提交
1364

G
ge-yafang 已提交
1365
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1366

G
ge-yafang 已提交
1367
**参数:** 
C
chyyy0213 已提交
1368

G
ge-yafang 已提交
1369 1370
| 参数名   | 类型                      | 必填 | 说明                                                         |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
G
ge-yafang 已提交
1371
| names    | Array                     | 是   | 设置状态栏和导航栏是否显示。<br>例如,需全部显示,该参数设置为["status",&nbsp;"navigation"];不设置,则默认不显示。 |
G
ge-yafang 已提交
1372
| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                                   |
Z
zengyawen 已提交
1373

G
ge-yafang 已提交
1374
**示例:** 
C
chyyy0213 已提交
1375

G
ge-yafang 已提交
1376 1377 1378 1379 1380 1381 1382 1383 1384 1385
```js
var names = ["status", "navigation"];
windowClass.setSystemBarEnable(names, (err, data) => {
    if (err.code) {
        console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data));
});
```
C
chyyy0213 已提交
1386 1387 1388 1389 1390

### setSystemBarEnable<sup>7+</sup>

setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt;

G
ge-yafang 已提交
1391
设置导航栏、状态栏的可见模式,使用Promise异步回调。
C
chyyy0213 已提交
1392

G
ge-yafang 已提交
1393
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1394

G
ge-yafang 已提交
1395
**参数:** 
C
chyyy0213 已提交
1396

G
ge-yafang 已提交
1397 1398
| 参数名 | 类型  | 必填 | 说明                                                         |
| ------ | ----- | ---- | ------------------------------------------------------------ |
G
ge-yafang 已提交
1399
| names  | Array | 是   | 设置状态栏和导航栏是否显示。<br>例如,需全部显示,该参数设置为["status",&nbsp;"navigation"];不设置,则默认不显示。 |
C
chyyy0213 已提交
1400

G
ge-yafang 已提交
1401
**返回值:** 
C
chyyy0213 已提交
1402

G
ge-yafang 已提交
1403 1404 1405
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
1406

G
ge-yafang 已提交
1407
**示例:** 
C
chyyy0213 已提交
1408

G
ge-yafang 已提交
1409 1410 1411 1412 1413 1414 1415 1416 1417
```js
var names = ["status", "navigation"];
let promise = windowClass.setSystemBarEnable(names);
promise.then((data)=> {
    console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
});
```
Z
zengyawen 已提交
1418 1419 1420 1421 1422

### setSystemBarProperties

setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback&lt;void&gt;): void

G
ge-yafang 已提交
1423
设置窗口内导航栏、状态栏的属性,使用callback异步回调。
C
chyyy0213 已提交
1424

G
ge-yafang 已提交
1425
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
1426

G
ge-yafang 已提交
1427
**参数:** 
C
chyyy0213 已提交
1428

G
ge-yafang 已提交
1429 1430 1431 1432
| 参数名              | 类型                                        | 必填 | 说明                   |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是   | 导航栏、状态栏的属性。 |
| callback            | AsyncCallback&lt;void&gt;                   | 是   | 回调函数。             |
Z
zengyawen 已提交
1433

G
ge-yafang 已提交
1434
**示例:** 
C
chyyy0213 已提交
1435

G
ge-yafang 已提交
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454
```js
var SystemBarProperties={
    statusBarColor: '#ff00ff',
    navigationBarColor: '#00ff00',
    //以下两个属性从API Version7开始支持
    isStatusBarLightIcon: true,
    isNavigationBarLightIcon:false,
    //以下两个属性从API Version8开始支持
    statusBarContentColor:'#ffffff',
    navigationBarContentColor:'#00ffff'
};
windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => {
    if (err.code) {
        console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
});
```
C
chyyy0213 已提交
1455 1456 1457 1458 1459

### setSystemBarProperties

setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise&lt;void&gt;

G
ge-yafang 已提交
1460
设置窗口内导航栏、状态栏的属性,使用Promise异步回调。
C
chyyy0213 已提交
1461

G
ge-yafang 已提交
1462
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1463

G
ge-yafang 已提交
1464
**参数:** 
C
chyyy0213 已提交
1465

G
ge-yafang 已提交
1466 1467 1468
| 参数名              | 类型                                        | 必填 | 说明                   |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是   | 导航栏、状态栏的属性。 |
C
chyyy0213 已提交
1469

G
ge-yafang 已提交
1470
**返回值:** 
C
chyyy0213 已提交
1471

G
ge-yafang 已提交
1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |

**示例:** 

```js
var SystemBarProperties={
    statusBarColor: '#ff00ff',
    navigationBarColor: '#00ff00',
    //以下两个属性从API Version7开始支持
    isStatusBarLightIcon: true,
    isNavigationBarLightIcon:false,
    //以下两个属性从API Version8开始支持
    statusBarContentColor:'#ffffff',
    navigationBarContentColor:'#00ffff'
};
let promise = windowClass.setSystemBarProperties(SystemBarProperties);
promise.then((data)=> {
    console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
});
```
Z
zengyawen 已提交
1496

X
xpeng 已提交
1497
### setPreferredOrientation<sup>9+</sup>
X
xpeng 已提交
1498 1499 1500

setPreferredOrientation(orientation: Orientation, callback: AsyncCallback&lt;void&gt;): void

X
xpeng 已提交
1501
设置窗口的显示方向属性,使用callback异步回调。
X
xpeng 已提交
1502 1503 1504 1505 1506 1507 1508

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:** 

| 参数名              | 类型                                        | 必填 | 说明                   |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
X
xpeng 已提交
1509
| Orientation         | [Orientation](#orientation9)                | 是   | 窗口显示方向的属性。         |
X
xpeng 已提交
1510 1511 1512 1513 1514
| callback            | AsyncCallback&lt;void&gt;                   | 是   | 回调函数。             |

**示例:** 

```js
X
xpeng 已提交
1515 1516
var orientation = window.Orientation.AUTO_ROTATION;
windowClass.setPreferredOrientation(orientation, (err, data) => {
X
xpeng 已提交
1517 1518 1519 1520 1521 1522 1523 1524
    if (err.code) {
        console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting window orientation. Data: ' + JSON.stringify(data));
});
```

X
xpeng 已提交
1525
### setPreferredOrientation<sup>9+</sup>
X
xpeng 已提交
1526 1527 1528

setPreferredOrientation(orientation: Orientation): Promise&lt;void&gt;

X
xpeng 已提交
1529 1530
设置窗口的显示方向属性,使用Promise异步回调。

X
xpeng 已提交
1531 1532 1533 1534 1535 1536
**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:** 

| 参数名              | 类型                                        | 必填 | 说明                   |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
X
xpeng 已提交
1537
| Orientation         | [Orientation](#orientation9)                | 是   | 窗口显示方向的属性。       |
X
xpeng 已提交
1538 1539 1540 1541 1542 1543 1544 1545 1546 1547

**返回值:** 

| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |

**示例:** 

```js
X
xpeng 已提交
1548 1549
var orientation = window.Orientation.AUTO_ROTATION;
let promise = windowClass.setPreferredOrientation(orientation);
X
xpeng 已提交
1550 1551 1552 1553 1554 1555 1556
promise.then((data)=> {
    console.info('Succeeded in setting the window orientation. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the window orientation. Cause: ' + JSON.stringify(err));
});
```

C
chyyy0213 已提交
1557
### loadContent<sup>7+</sup>
Z
zengyawen 已提交
1558

C
chyyy0213 已提交
1559
loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void
Z
zengyawen 已提交
1560

G
ge-yafang 已提交
1561
为当前窗口加载具体页面内容,使用callback异步回调。
Z
zengyawen 已提交
1562

G
ge-yafang 已提交
1563
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
1564

G
ge-yafang 已提交
1565
**参数:** 
Z
zengyawen 已提交
1566

G
ge-yafang 已提交
1567 1568 1569 1570
| 参数名   | 类型                      | 必填 | 说明                 |
| -------- | ------------------------- | ---- | -------------------- |
| path     | string                    | 是   | 设置加载页面的路径。 |
| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
G
ge-yafang 已提交
1571

G
ge-yafang 已提交
1572
**示例:** 
Z
zengyawen 已提交
1573

G
ge-yafang 已提交
1574 1575 1576 1577 1578 1579 1580 1581 1582
```js
windowClass.loadContent("pages/page2/page2", (err, data) => {
   if (err.code) {
         console.error('Failed to load the content. Cause:' + JSON.stringify(err));
         return;
   }
  console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
});
```
C
chyyy0213 已提交
1583

C
chyyy0213 已提交
1584
### loadContent<sup>7+</sup>
C
chyyy0213 已提交
1585

C
chyyy0213 已提交
1586
loadContent(path: string): Promise&lt;void&gt;
C
chyyy0213 已提交
1587

G
ge-yafang 已提交
1588
为当前窗口加载具体页面内容,使用Promise异步回调。
C
chyyy0213 已提交
1589

G
ge-yafang 已提交
1590
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1591

G
ge-yafang 已提交
1592
**参数:** 
C
chyyy0213 已提交
1593

G
ge-yafang 已提交
1594 1595 1596
| 参数名 | 类型   | 必填 | 说明                 |
| ------ | ------ | ---- | -------------------- |
| path   | string | 是   | 设置加载页面的路径。 |
G
ge-yafang 已提交
1597

G
ge-yafang 已提交
1598
**返回值:** 
C
chyyy0213 已提交
1599

G
ge-yafang 已提交
1600 1601 1602
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
1603

G
ge-yafang 已提交
1604
**示例:** 
C
chyyy0213 已提交
1605

G
ge-yafang 已提交
1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625
```js
let promise = windowClass.loadContent("pages/page2/page2");
promise.then((data)=> {
    console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
});
```
### loadContent<sup>9+</sup>

loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void&gt;): void

为当前窗口加载与LocalStorage相关联的具体页面内容,使用callback异步回调。

此接口仅可在Stage模型下使用。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:** 

G
ge-yafang 已提交
1626 1627 1628 1629 1630
| 参数名   | 类型                                            | 必填 | 说明                                                         |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path     | string                                          | 是   | 设置加载页面的路径。                                         |
| storage  | [LocalStorage](../../ui/ui-ts-local-storage.md) | 是   | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 |
| callback | AsyncCallback&lt;void&gt;                       | 是   | 回调函数。                                                   |
G
ge-yafang 已提交
1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663

**示例:**

```ts
class myAbility extends Ability {
    storage : LocalStorage  
    onWindowStageCreate(windowStage) {
        this.storage = new LocalStorage();
        this.storage.setOrCreate("storageSimpleProp",121);
        console.log('onWindowStageCreate');
        windowStage.loadContent("pages/page2",this.storage,(err, data) => {
            if (err.code) {
                console.error('Failed to load the content. Cause:' + JSON.stringify(err));
                return;
            }
            console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
        });
    }
}
```

### loadContent<sup>9+</sup>

loadContent(path: string, storage: LocalStorage): Promise&lt;void&gt;

为当前窗口加载与LocalStorage相关联的具体页面内容,使用Promise异步回调。

此接口仅可在Stage模型下使用。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:** 

G
ge-yafang 已提交
1664 1665 1666 1667
| 参数名  | 类型                                            | 必填 | 说明                                                         |
| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path    | string                                          | 是   | 设置加载页面的路径。                                         |
| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | 是   | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 |
G
ge-yafang 已提交
1668 1669 1670 1671 1672 1673

**返回值:**

| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
Z
zengyawen 已提交
1674

G
ge-yafang 已提交
1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694
**示例:**

```ts
class myAbility extends Ability {
    storage : LocalStorage 
    onWindowStageCreate(windowStage) {
        this.storage = new LocalStorage();
        this.storage.setOrCreate("storageSimpleProp",121);
        console.log('onWindowStageCreate');
        var windowClass = null;
        let promise = windowStage.loadContent("pages/page2",this.storage);
        promise.then((data)=> {
            windowClass = data;
            console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
        }).catch((err)=>{
            console.error('Failed to load the content. Cause:' + JSON.stringify(err));
        })
    }
}
```
C
chyyy0213 已提交
1695
### isShowing<sup>7+</sup>
Z
zengyawen 已提交
1696

C
chyyy0213 已提交
1697 1698
isShowing(callback: AsyncCallback&lt;boolean&gt;): void

G
ge-yafang 已提交
1699
判断当前窗口是否已显示,使用callback异步回调。
Z
zengyawen 已提交
1700

G
ge-yafang 已提交
1701
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
1702

G
ge-yafang 已提交
1703
**参数:** 
C
chyyy0213 已提交
1704

G
ge-yafang 已提交
1705 1706 1707
| 参数名   | 类型                         | 必填 | 说明                                                         |
| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示当前窗口已显示,返回false则表示当前窗口未显示。 |
Z
zengyawen 已提交
1708

G
ge-yafang 已提交
1709
**示例:** 
C
chyyy0213 已提交
1710

G
ge-yafang 已提交
1711 1712 1713 1714 1715 1716 1717 1718 1719
```js
windowClass.isShowing((err, data) => {
    if (err.code) {
        console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
});
```
C
chyyy0213 已提交
1720 1721 1722 1723 1724

### isShowing<sup>7+</sup>

isShowing(): Promise&lt;boolean&gt;

G
ge-yafang 已提交
1725
判断当前窗口是否已显示,使用Promise异步回调。
C
chyyy0213 已提交
1726

G
ge-yafang 已提交
1727
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1728

G
ge-yafang 已提交
1729
**返回值:** 
C
chyyy0213 已提交
1730

G
ge-yafang 已提交
1731 1732 1733
| 类型                   | 说明                                                         |
| ---------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise对象。返回true表示当前窗口已显示,返回false则表示当前窗口未显示。 |
C
chyyy0213 已提交
1734

G
ge-yafang 已提交
1735
**示例:** 
C
chyyy0213 已提交
1736

G
ge-yafang 已提交
1737 1738 1739 1740 1741 1742 1743 1744
```js
let promise = windowClass.isShowing();
promise.then((data)=> {
    console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err));
});
```
Z
zengyawen 已提交
1745

C
chyyy0213 已提交
1746
### on('windowSizeChange')<sup>7+</sup>
Z
zengyawen 已提交
1747

C
chyyy0213 已提交
1748
on(type:  'windowSizeChange', callback: Callback&lt;Size&gt;): void
Z
zengyawen 已提交
1749

G
ge-yafang 已提交
1750
开启窗口尺寸变化的监听。
C
chyyy0213 已提交
1751

G
ge-yafang 已提交
1752
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
1753

G
ge-yafang 已提交
1754
**参数:** 
C
chyyy0213 已提交
1755

G
ge-yafang 已提交
1756 1757 1758 1759
| 参数名   | 类型                           | 必填 | 说明                                                     |
| -------- | ------------------------------ | ---- | -------------------------------------------------------- |
| type     | string                         | 是   | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 |
| callback | Callback&lt;[Size](#size7)&gt; | 是   | 回调函数。返回当前的窗口尺寸。                           |
Z
zengyawen 已提交
1760

G
ge-yafang 已提交
1761
**示例:** 
C
chyyy0213 已提交
1762

G
ge-yafang 已提交
1763 1764 1765 1766 1767
```js
windowClass.on('windowSizeChange', (data) => {
    console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data));
});
```
Z
zengyawen 已提交
1768

C
chyyy0213 已提交
1769
### off('windowSizeChange')<sup>7+</sup>
Z
zengyawen 已提交
1770

C
chyyy0213 已提交
1771
off(type: 'windowSizeChange', callback?: Callback&lt;Size &gt;): void
Z
zengyawen 已提交
1772

G
ge-yafang 已提交
1773
关闭窗口尺寸变化的监听。
C
chyyy0213 已提交
1774

G
ge-yafang 已提交
1775
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
1776

G
ge-yafang 已提交
1777
**参数:** 
C
chyyy0213 已提交
1778

G
ge-yafang 已提交
1779 1780 1781
| 参数名   | 类型                          | 必填 | 说明                                                     |
| -------- | ----------------------------- | ---- | -------------------------------------------------------- |
| type     | string                        | 是   | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 |
G
ge-yafang 已提交
1782
| callback | Callback&lt;[Size](#size)&gt; | 否   | 回调函数。返回当前的窗口尺寸。                           |
Z
zengyawen 已提交
1783

G
ge-yafang 已提交
1784
**示例:** 
C
chyyy0213 已提交
1785

G
ge-yafang 已提交
1786 1787 1788
```js
windowClass.off('windowSizeChange');
```
Z
zengyawen 已提交
1789

1790
### on('systemAvoidAreaChange')<sup>(deprecated)</sup>
C
chyyy0213 已提交
1791

1792
on(type: 'systemAvoidAreaChange', callback: Callback&lt;[AvoidArea](#avoidarea7)&gt;): void
C
chyyy0213 已提交
1793

1794 1795 1796 1797
开启系统规避区变化的监听。
> **说明:** 从API version 9开始废弃,推荐使用[on('avoidAreaChange')](#onavoidareachange9)。
>
> 从 API version 7开始支持。
C
chyyy0213 已提交
1798

G
ge-yafang 已提交
1799
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1800

G
ge-yafang 已提交
1801
**参数:** 
C
chyyy0213 已提交
1802

1803 1804 1805 1806
| 参数名   | 类型                                       | 必填 | 说明                                                    |
| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
| type     | string                                   | 是   | 监听事件,固定为'systemAvoidAreaChange',即系统规避区变化事件。 |
| callback | Callback&lt;[AvoidArea](#avoidarea7)&gt; | 是   | 回调函数。返回当前规避区。                             |
C
chyyy0213 已提交
1807

G
ge-yafang 已提交
1808
**示例:** 
C
chyyy0213 已提交
1809

G
ge-yafang 已提交
1810 1811 1812 1813 1814
```js
windowClass.on('systemAvoidAreaChange', (data) => {
    console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
});
```
C
chyyy0213 已提交
1815

1816
### off('systemAvoidAreaChange')<sup>(deprecated)</sup>
C
chyyy0213 已提交
1817

1818
off(type: 'systemAvoidAreaChange', callback?: Callback&lt;[AvoidArea](#avoidarea7)&gt;): void
C
chyyy0213 已提交
1819

1820 1821 1822 1823
关闭系统规避区变化的监听。
> **说明:** 从API version 9开始废弃,推荐使用[off('avoidAreaChange')](#offavoidareachange9)。
>
> 从 API version 7开始支持。
C
chyyy0213 已提交
1824

G
ge-yafang 已提交
1825
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1826

G
ge-yafang 已提交
1827
**参数:** 
C
chyyy0213 已提交
1828

1829 1830 1831 1832
| 参数名   | 类型                                       | 必填 | 说明                                                    |
| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
| type     | string                                   | 是   | 监听事件,固定为'systemAvoidAreaChange',即系统规避区变化事件。 |
| callback | Callback&lt;[AvoidArea](#avoidarea7)&gt; | 否   | 回调函数。返回当前规避区。                            |
C
chyyy0213 已提交
1833

G
ge-yafang 已提交
1834
**示例:** 
C
chyyy0213 已提交
1835

G
ge-yafang 已提交
1836 1837 1838
```js
windowClass.off('systemAvoidAreaChange');
```
C
chyyy0213 已提交
1839

1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858

### on('avoidAreaChange')<sup>9+</sup>

on(type: 'avoidAreaChange', callback: Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt;): void

开启系统规避区变化的监听。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名   | 类型                                                               | 必填 | 说明                                   |
| -------- |------------------------------------------------------------------| ---- |--------------------------------------|
| type     | string                                                           | 是   | 监听事件,固定为'avoidAreaChange',即系统规避区变化事件。 |
| callback | Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt; | 是   | 回调函数。返回当前规避区以及规避区类型。|

**示例:**

```js
1859 1860
windowClass.on('avoidAreaChange', (data) => {
    console.info('Succeeded in enabling the listener for system avoid area changes. type:'  + JSON.stringify(data.type) + ', area: ' + JSON.stringify(data.area));
1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884
});
```

### off('avoidAreaChange')<sup>9+</sup>

off(type: 'avoidAreaChange', callback: Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt;): void

关闭系统规避区变化的监听。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名   | 类型                                                                          | 必填  | 说明                                 |
| -------- |-----------------------------------------------------------------------------|-----|------------------------------------|
| type     | string                                                                      | 是   | 监听事件,固定为'avoidAreaChange',即系统规避区变化事件。 |
| callback | Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt; | 否   | 回调函数。返回当前规避区以及规避区类型。|

**示例:**

```js
windowClass.off('avoidAreaChange');
```

C
chyyy0213 已提交
1885 1886 1887 1888 1889 1890
### on('keyboardHeightChange')<sup>7+</sup>

on(type: 'keyboardHeightChange', callback: Callback&lt;number&gt;): void

开启键盘高度变化的监听。

G
ge-yafang 已提交
1891
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1892

G
ge-yafang 已提交
1893
**参数:** 
C
chyyy0213 已提交
1894

G
ge-yafang 已提交
1895 1896 1897 1898
| 参数名   | 类型                | 必填 | 说明                                                         |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
| type     | string              | 是   | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 |
| callback | Callback<number&gt; | 是   | 回调函数。返回当前的键盘高度。                               |
C
chyyy0213 已提交
1899

G
ge-yafang 已提交
1900
**示例:** 
C
chyyy0213 已提交
1901

G
ge-yafang 已提交
1902 1903 1904 1905 1906
```js
windowClass.on('keyboardHeightChange', (data) => {
    console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
});
```
C
chyyy0213 已提交
1907 1908 1909 1910 1911 1912 1913

### off('keyboardHeightChange')<sup>7+</sup>

off(type: 'keyboardHeightChange', callback?: Callback&lt;number&gt;): void

关闭键盘高度变化的监听。

G
ge-yafang 已提交
1914
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
1915

G
ge-yafang 已提交
1916
**参数:** 
C
chyyy0213 已提交
1917

G
ge-yafang 已提交
1918 1919 1920
| 参数名   | 类型                   | 必填 | 说明                                                         |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| type     | string                 | 是   | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 |
G
ge-yafang 已提交
1921
| callback | Callback&lt;number&gt; | 否   | 回调函数。返回当前的键盘高度。                               |
C
chyyy0213 已提交
1922

G
ge-yafang 已提交
1923
**示例:** 
C
chyyy0213 已提交
1924

G
ge-yafang 已提交
1925 1926 1927
```js
windowClass.off('keyboardHeightChange');
```
C
chyyy0213 已提交
1928

D
dubj 已提交
1929 1930 1931 1932 1933
### on('touchOutside')<sup>9+</sup>

on(type: 'touchOutside', callback: Callback&lt;void&gt;): void

开启本窗口区域范围外的点击事件的监听。
1934
此接口为系统接口。
D
dubj 已提交
1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名   | 类型                | 必填 | 说明                                                         |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
| type     | string              | 是   | 监听事件,固定为'touchOutside',即本窗口范围外的点击事件。 |
| callback | Callback<void&gt; | 是   | 回调函数。当点击事件发生在本窗口范围之外的回调。                               |

**示例:**

```js
windowClass.on('touchOutside', () => {
    console.info('touch outside');
});
```

### off('touchOutside')<sup>9+</sup>

off(type: 'touchOutside', callback?: Callback&lt;void&gt;): void

关闭本窗口区域范围外的点击事件的监听。
1958
此接口为系统接口。
D
dubj 已提交
1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名   | 类型                   | 必填 | 说明                                                         |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| type     | string                 | 是   | 监听事件,固定为'touchOutside',即本窗口范围外的点击事件。 |
| callback | Callback&lt;number&gt; | 否   | 回调函数。当点击事件发生在本窗口范围之外的回调。                               |

**示例:**

```js
windowClass.off('touchOutside');
```

1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025
### on('screenshot')<sup>9+</sup>

on(type: 'screenshot', callback: Callback&lt;void&gt;): void

开启截屏事件的监听。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名   | 类型                | 必填 | 说明                                                         |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
| type     | string              | 是   | 监听事件,固定为'screenshot',即截屏事件。 |
| callback | Callback&lt;void&gt; | 是   | 回调函数。发生截屏事件时的回调。                               |

**示例:**

```js
windowClass.on('screenshot', () => {
    console.info('screenshot happened');
});
```

### off('screenshot')<sup>9+</sup>

off(type: 'screenshot', callback?: Callback&lt;void&gt;): void

关闭截屏事件的监听。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名   | 类型                   | 必填 | 说明                                                         |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| type     | string                 | 是   | 监听事件,固定为'screenshot',即截屏事件。 |
| callback | Callback&lt;void&gt; | 否   | 回调函数。发生截屏事件时的回调。 |

**示例:**

```js
var callback = ()=>{
    console.info('screenshot happened');
}
windowClass.on('screenshot', callback)
windowClass.off('screenshot', callback)

// 如果通过on开启多个callback进行监听,同时关闭所有监听:
windowClass.off('screenshot');
```

2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167
### on('dialogTargetTouch')<sup>9+</sup>

on(type: 'dialogTargetTouch', callback: Callback&lt;void&gt;): void

开启模态窗口目标窗口的点击事件的监听。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名   | 类型                 | 必填 | 说明                                                          |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
| type     | string              | 是   | 监听事件,固定为'dialogTargetTouch',即模态窗口目标窗口的点击事件。 |
| callback | Callback&lt;void&gt;| 是   | 回调函数。当点击事件发生在模态窗口目标窗口的回调。 |

**示例:**

```js
windowClass.on('dialogTargetTouch', () => {
    console.info('touch dialog target');
});
```

### off('dialogTargetTouch')<sup>9+</sup>

off(type: 'dialogTargetTouch', callback?: Callback&lt;void&gt;): void

关闭模态窗口目标窗口的点击事件的监听。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名   | 类型                    | 必填 | 说明                                                          |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| type     | string                 | 是   | 监听事件,固定为'dialogTargetTouch',即模态窗口目标窗口的点击事件。 |
| callback | Callback&lt;void&gt;      | 否   | 回调函数。当点击事件发生在模态窗口目标窗口的回调。 |

**示例:**

```js
windowClass.off('dialogTargetTouch');
```

### bindDialogTarget<sup>9+</sup>

bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;, callback: AsyncCallback&lt;void&gt;): void

绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用callback异步回调。

此接口为系统接口。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:** 

| 参数名       | 类型                      | 必填 | 说明                  |
| ----------- | ------------------------- | ---- | -------------------- |
| token       | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是   | 目标窗口token值。 |
| deathCallback | Callback&lt;void&gt;        | 是   | 模态窗口销毁监听。 |
| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |

**示例:** 

```js
class TestRemoteObject extends rpc.RemoteObject {
    constructor(descriptor) {
        super(descriptor);
    }
    addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
        return true;
    }
    removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
        return true;
    }
    isObjectDead(): boolean {
        return false;
    }
}
let token = new TestRemoteObject("testObject");
windowClass.bindDialogTarget(token, () => {
    console.info('Dialog Window Need Destroy.');
}, (err, data) => {
    if (err.code) {
        console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data));
});
```

### bindDialogTarget<sup>9+</sup>

bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;): Promise&lt;void&gt;

绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用Promise异步回调。

此接口为系统接口。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:** 

| 参数名       | 类型                      | 必填 | 说明                  |
| ----------- | ------------------------- | ---- | -------------------- |
| token       | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是   | 目标窗口token值。 |
| deathCallback | Callback&lt;void&gt;        | 是   | 模态窗口销毁监听。 |

**返回值:** 

| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |

**示例:** 

```js
class TestRemoteObject extends rpc.RemoteObject {
    constructor(descriptor) {
        super(descriptor);
    }
    addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
        return true;
    }
    removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
        return true;
    }
    isObjectDead(): boolean {
        return false;
    }
}
let token = new TestRemoteObject("testObject");
let promise = windowClass.bindDialogTarget(token, () => {
    console.info('Dialog Window Need Destroy.');
});
promise.then((data)=> {
    console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data));
}).catch((err)=>{
        console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
});
```

C
chyyy0213 已提交
2168
### isSupportWideGamut<sup>8+</sup>
Z
zengyawen 已提交
2169

C
chyyy0213 已提交
2170
isSupportWideGamut(callback: AsyncCallback&lt;boolean&gt;): void
C
chyyy0213 已提交
2171

G
ge-yafang 已提交
2172
判断当前窗口是否支持广色域模式,使用callback异步回调。
Z
zengyawen 已提交
2173

G
ge-yafang 已提交
2174
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
2175

G
ge-yafang 已提交
2176
**参数:** 
C
chyyy0213 已提交
2177

G
ge-yafang 已提交
2178 2179 2180
| 参数名   | 类型                         | 必填 | 说明                                                         |
| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 |
Z
zengyawen 已提交
2181

G
ge-yafang 已提交
2182
**示例:** 
C
chyyy0213 已提交
2183

G
ge-yafang 已提交
2184 2185 2186 2187 2188 2189 2190 2191 2192
```js
windowClass.isSupportWideGamut((err, data) => {
    if (err.code) {
        console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
})
```
Z
zengyawen 已提交
2193

C
chyyy0213 已提交
2194 2195 2196 2197
### isSupportWideGamut<sup>8+</sup>

isSupportWideGamut(): Promise&lt;boolean&gt;

G
ge-yafang 已提交
2198
判断当前窗口是否支持广色域模式,使用Promise异步回调。
C
chyyy0213 已提交
2199

G
ge-yafang 已提交
2200
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2201

G
ge-yafang 已提交
2202
**返回值:** 
C
chyyy0213 已提交
2203

G
ge-yafang 已提交
2204 2205
| 类型                   | 说明                                                         |
| ---------------------- | ------------------------------------------------------------ |
G
ge-yafang 已提交
2206
| Promise&lt;boolean&gt; | Promise对象。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 |
C
chyyy0213 已提交
2207

G
ge-yafang 已提交
2208
**示例:** 
C
chyyy0213 已提交
2209

G
ge-yafang 已提交
2210 2211 2212 2213 2214 2215 2216 2217
```js
let promise = windowClass.isSupportWideGamut();
promise.then((data)=> {
    console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
2218

C
chyyy0213 已提交
2219 2220
### setColorSpace<sup>8+</sup>

C
chyyy0213 已提交
2221
setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback&lt;void&gt;): void
Z
zengyawen 已提交
2222

G
ge-yafang 已提交
2223
设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。
Z
zengyawen 已提交
2224

G
ge-yafang 已提交
2225
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
2226

G
ge-yafang 已提交
2227
**参数:** 
C
chyyy0213 已提交
2228

G
ge-yafang 已提交
2229 2230 2231 2232
| 参数名     | 类型                      | 必填 | 说明         |
| ---------- | ------------------------- | ---- | ------------ |
| colorSpace | [ColorSpace](#colorspace) | 是   | 设置色域模式 |
| callback   | AsyncCallback&lt;void&gt; | 是   | 回调函数。   |
Z
zengyawen 已提交
2233

G
ge-yafang 已提交
2234
**示例:** 
C
chyyy0213 已提交
2235

G
ge-yafang 已提交
2236 2237 2238 2239 2240 2241 2242 2243 2244
```js
windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => {
    if (err.code) {
        console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data));
})
```
Z
zengyawen 已提交
2245

C
chyyy0213 已提交
2246 2247 2248 2249
### setColorSpace<sup>8+</sup>

setColorSpace(colorSpace:ColorSpace): Promise&lt;void&gt;

G
ge-yafang 已提交
2250
设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。
C
chyyy0213 已提交
2251

G
ge-yafang 已提交
2252
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2253

G
ge-yafang 已提交
2254
**参数:** 
C
chyyy0213 已提交
2255

G
ge-yafang 已提交
2256 2257 2258
| 参数名     | 类型                      | 必填 | 说明           |
| ---------- | ------------------------- | ---- | -------------- |
| colorSpace | [ColorSpace](#colorspace) | 是   | 设置色域模式。 |
C
chyyy0213 已提交
2259

G
ge-yafang 已提交
2260
**返回值:** 
C
chyyy0213 已提交
2261

G
ge-yafang 已提交
2262 2263 2264
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
2265

G
ge-yafang 已提交
2266
**示例:** 
C
chyyy0213 已提交
2267

G
ge-yafang 已提交
2268
```js
X
xpeng 已提交
2269
let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT);
G
ge-yafang 已提交
2270 2271 2272 2273 2274 2275
promise.then((data)=> {
    console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
2276

C
chyyy0213 已提交
2277
### getColorSpace<sup>8+</sup>
Z
zengyawen 已提交
2278

C
chyyy0213 已提交
2279
getColorSpace(callback: AsyncCallback&lt;ColorSpace&gt;): void
Z
zengyawen 已提交
2280

G
ge-yafang 已提交
2281
获取当前窗口色域模式,使用callback异步回调。
Z
zengyawen 已提交
2282

G
ge-yafang 已提交
2283
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
2284

G
ge-yafang 已提交
2285
**参数:** 
C
chyyy0213 已提交
2286

G
ge-yafang 已提交
2287 2288 2289
| 参数名   | 类型                                           | 必填 | 说明                                                       |
| -------- | ---------------------------------------------- | ---- | ---------------------------------------------------------- |
| callback | AsyncCallback&lt;[ColorSpace](#colorspace)&gt; | 是   | 回调函数。当获取成功,err为undefined,data为当前色域模式。 |
Z
zengyawen 已提交
2290

G
ge-yafang 已提交
2291
**示例:** 
C
chyyy0213 已提交
2292

G
ge-yafang 已提交
2293 2294 2295 2296 2297 2298 2299 2300 2301
```js
windowClass.getColorSpace((err, data) => {
    if (err.code) {
        console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data));
})
```
Z
zengyawen 已提交
2302

C
chyyy0213 已提交
2303 2304 2305 2306
### getColorSpace<sup>8+</sup>

getColorSpace(): Promise&lt;ColorSpace&gt;

G
ge-yafang 已提交
2307
获取当前窗口色域模式,使用Promise异步回调。
C
chyyy0213 已提交
2308

G
ge-yafang 已提交
2309
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2310

G
ge-yafang 已提交
2311
**返回值:** 
C
chyyy0213 已提交
2312

G
ge-yafang 已提交
2313 2314 2315
| 类型                                     | 说明                            |
| ---------------------------------------- | ------------------------------- |
| Promise&lt;[ColorSpace](#colorspace)&gt; | Promise对象。返回当前色域模式。 |
C
chyyy0213 已提交
2316

G
ge-yafang 已提交
2317
**示例:** 
C
chyyy0213 已提交
2318

G
ge-yafang 已提交
2319 2320 2321 2322 2323 2324 2325 2326
```js
let promise = windowClass.getColorSpace();
promise.then((data)=> {
    console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
2327

C
chyyy0213 已提交
2328 2329 2330 2331
### setBackgroundColor

setBackgroundColor(color: string, callback: AsyncCallback&lt;void&gt;): void

D
dubj 已提交
2332
设置窗口的背景色,使用callback异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。
C
chyyy0213 已提交
2333

G
ge-yafang 已提交
2334
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2335

G
ge-yafang 已提交
2336
**参数:** 
C
chyyy0213 已提交
2337

G
ge-yafang 已提交
2338 2339
| 参数名   | 类型                      | 必填 | 说明                                                         |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
G
ge-yafang 已提交
2340
| color    | string                    | 是   | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00``#FF00FF00`。 |
G
ge-yafang 已提交
2341
| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                                   |
C
chyyy0213 已提交
2342

G
ge-yafang 已提交
2343
**示例:** 
C
chyyy0213 已提交
2344

G
ge-yafang 已提交
2345 2346 2347 2348 2349 2350 2351 2352 2353 2354
```js
var color = '#00ff33';
windowClass.setBackgroundColor(color, (err, data) => {
    if (err.code) {
        console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data));
});
```
C
chyyy0213 已提交
2355 2356 2357 2358 2359

### setBackgroundColor

setBackgroundColor(color: string): Promise&lt;void&gt;

D
dubj 已提交
2360
设置窗口的背景色,使用Promise异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。
C
chyyy0213 已提交
2361

G
ge-yafang 已提交
2362
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2363

G
ge-yafang 已提交
2364
**参数:** 
C
chyyy0213 已提交
2365

G
ge-yafang 已提交
2366 2367
| 参数名 | 类型   | 必填 | 说明                                                         |
| ------ | ------ | ---- | ------------------------------------------------------------ |
G
ge-yafang 已提交
2368
| color  | string | 是   | 需要设置的背景色,为十六进制颜色,不区分大小写,例如"#00FF00"或"#FF00FF00"。 |
C
chyyy0213 已提交
2369

G
ge-yafang 已提交
2370
**返回值:** 
C
chyyy0213 已提交
2371

G
ge-yafang 已提交
2372 2373 2374
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
2375

G
ge-yafang 已提交
2376
**示例:** 
C
chyyy0213 已提交
2377

G
ge-yafang 已提交
2378 2379 2380 2381 2382 2383 2384 2385 2386
```js
var color = '#00ff33';
let promise = windowClass.setBackgroundColor(color);
promise.then((data)=> {
    console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
2387 2388 2389 2390 2391

### setBrightness

setBrightness(brightness: number, callback: AsyncCallback&lt;void&gt;): void

G
ge-yafang 已提交
2392
设置屏幕亮度值,使用callback异步回调。
C
chyyy0213 已提交
2393

G
ge-yafang 已提交
2394
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2395

G
ge-yafang 已提交
2396
**参数:** 
C
chyyy0213 已提交
2397

G
ge-yafang 已提交
2398 2399 2400 2401
| 参数名     | 类型                      | 必填 | 说明                                 |
| ---------- | ------------------------- | ---- | ------------------------------------ |
| brightness | number                    | 是   | 屏幕亮度值,值为0-1之间。1表示最亮。 |
| callback   | AsyncCallback&lt;void&gt; | 是   | 回调函数。                           |
C
chyyy0213 已提交
2402

G
ge-yafang 已提交
2403
**示例:** 
C
chyyy0213 已提交
2404

G
ge-yafang 已提交
2405 2406 2407 2408 2409 2410 2411 2412 2413 2414
```js
var brightness = 1;
windowClass.setBrightness(brightness, (err, data) => {
    if (err.code) {
        console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data));
});
```
C
chyyy0213 已提交
2415 2416 2417 2418 2419

### setBrightness

setBrightness(brightness: number): Promise&lt;void&gt;

G
ge-yafang 已提交
2420
设置屏幕亮度值,使用Promise异步回调。
C
chyyy0213 已提交
2421

G
ge-yafang 已提交
2422
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2423

G
ge-yafang 已提交
2424
**参数:** 
C
chyyy0213 已提交
2425

G
ge-yafang 已提交
2426 2427 2428
| 参数名     | 类型   | 必填 | 说明                                 |
| ---------- | ------ | ---- | ------------------------------------ |
| brightness | number | 是   | 屏幕亮度值,值为0-1之间。1表示最亮。 |
C
chyyy0213 已提交
2429

G
ge-yafang 已提交
2430
**返回值:** 
C
chyyy0213 已提交
2431

G
ge-yafang 已提交
2432 2433 2434
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
2435

G
ge-yafang 已提交
2436
**示例:** 
C
chyyy0213 已提交
2437

G
ge-yafang 已提交
2438 2439 2440 2441 2442 2443 2444 2445 2446
```js
var brightness = 1;
let promise = windowClass.setBrightness(brightness);
promise.then((data)=> {
    console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
2447

Z
xxx  
zhirong 已提交
2448 2449 2450 2451
### setDimBehind<sup>(deprecated)</sup>

setDimBehind(dimBehindValue: number, callback: AsyncCallback&lt;void&gt;): void

G
ge-yafang 已提交
2452
窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用callback异步回调。
Z
xxx  
zhirong 已提交
2453

2454
> **说明:** 从API version 9开始废弃。该API不支持使用。
Z
xxx  
zhirong 已提交
2455 2456 2457 2458 2459 2460 2461
> 
> 从 API version 7开始支持。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

G
ge-yafang 已提交
2462 2463 2464 2465
| 参数名         | 类型                      | 必填 | 说明                                               |
| -------------- | ------------------------- | ---- | -------------------------------------------------- |
| dimBehindValue | number                    | 是   | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 |
| callback       | AsyncCallback&lt;void&gt; | 是   | 回调函数。                                         |
Z
xxx  
zhirong 已提交
2466 2467 2468

**示例:**

G
ge-yafang 已提交
2469 2470 2471 2472 2473 2474 2475 2476 2477
```js
windowClass.setDimBehind(0.5, (err, data) => {
    if (err.code) {
        console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data));
});
```
Z
xxx  
zhirong 已提交
2478 2479 2480 2481 2482

### setDimBehind<sup>(deprecated)</sup>

setDimBehind(dimBehindValue: number): Promise&lt;void&gt;

G
ge-yafang 已提交
2483
窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用Promise异步回调。
Z
xxx  
zhirong 已提交
2484

2485
> **说明:** 从API version 9开始废弃。该API不支持使用。
Z
xxx  
zhirong 已提交
2486 2487 2488 2489 2490 2491 2492
> 
> 从 API version 7开始支持。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

G
ge-yafang 已提交
2493 2494 2495
| 参数名         | 类型   | 必填 | 说明                                               |
| -------------- | ------ | ---- | -------------------------------------------------- |
| dimBehindValue | number | 是   | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 |
Z
xxx  
zhirong 已提交
2496 2497 2498

**返回值:**

G
ge-yafang 已提交
2499 2500 2501
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
Z
xxx  
zhirong 已提交
2502 2503 2504

**示例:**

G
ge-yafang 已提交
2505 2506 2507 2508 2509 2510 2511 2512
```js
let promise = windowClass.setDimBehind(0.5);
promise.then((data)=> {
    console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
});
```
Z
xxx  
zhirong 已提交
2513

C
chyyy0213 已提交
2514 2515 2516 2517
### setFocusable<sup>7+</sup>

setFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): void

G
ge-yafang 已提交
2518
设置点击时是否支持切换焦点窗口,使用callback异步回调。
C
chyyy0213 已提交
2519

G
ge-yafang 已提交
2520
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2521

G
ge-yafang 已提交
2522
**参数:** 
C
chyyy0213 已提交
2523

G
ge-yafang 已提交
2524 2525 2526 2527
| 参数名      | 类型                      | 必填 | 说明                         |
| ----------- | ------------------------- | ---- | ---------------------------- |
| isFocusable | boolean                   | 是   | 点击时是否支持切换焦点窗口。 |
| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。                   |
C
chyyy0213 已提交
2528

G
ge-yafang 已提交
2529
**示例:** 
C
chyyy0213 已提交
2530

G
ge-yafang 已提交
2531 2532 2533 2534 2535 2536 2537 2538 2539 2540
```js
var isFocusable= true;
windowClass.setFocusable(isFocusable, (err, data) => {
    if (err.code) {
        console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
});
```
C
chyyy0213 已提交
2541 2542 2543 2544 2545

### setFocusable<sup>7+</sup>

setFocusable(isFocusable: boolean): Promise&lt;void&gt;

G
ge-yafang 已提交
2546
设置点击时是否支持切换焦点窗口,使用Promise异步回调。
C
chyyy0213 已提交
2547

G
ge-yafang 已提交
2548
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2549

G
ge-yafang 已提交
2550
**参数:** 
C
chyyy0213 已提交
2551

G
ge-yafang 已提交
2552 2553 2554
| 参数名      | 类型    | 必填 | 说明                         |
| ----------- | ------- | ---- | ---------------------------- |
| isFocusable | boolean | 是   | 点击时是否支持切换焦点窗口。 |
C
chyyy0213 已提交
2555

G
ge-yafang 已提交
2556
**返回值:** 
C
chyyy0213 已提交
2557

G
ge-yafang 已提交
2558 2559 2560
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
2561

G
ge-yafang 已提交
2562
**示例:** 
C
chyyy0213 已提交
2563

G
ge-yafang 已提交
2564 2565 2566 2567 2568 2569 2570 2571 2572
```js
var isFocusable= true;
let promise = windowClass.setFocusable(isFocusable);
promise.then((data)=> {
    console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
2573 2574 2575 2576 2577

### setKeepScreenOn

setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback&lt;void&gt;): void

G
ge-yafang 已提交
2578
设置屏幕是否为常亮状态,使用callback异步回调。
C
chyyy0213 已提交
2579

G
ge-yafang 已提交
2580
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2581

G
ge-yafang 已提交
2582
**参数:** 
C
chyyy0213 已提交
2583

G
ge-yafang 已提交
2584 2585
| 参数名         | 类型                      | 必填 | 说明                     |
| -------------- | ------------------------- | ---- | ------------------------ |
G
ge-yafang 已提交
2586
| isKeepScreenOn | boolean                   | 是   | 设置屏幕是否为常亮状态。 |
G
ge-yafang 已提交
2587
| callback       | AsyncCallback&lt;void&gt; | 是   | 回调函数。               |
C
chyyy0213 已提交
2588

G
ge-yafang 已提交
2589
**示例:** 
C
chyyy0213 已提交
2590

G
ge-yafang 已提交
2591 2592 2593 2594 2595 2596 2597 2598 2599 2600
```js
var isKeepScreenOn = true;
windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => {
    if (err.code) {
        console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
});
```
Z
xxx  
zhirong 已提交
2601

G
ge-yafang 已提交
2602
### setKeepScreenOn
Z
xxx  
zhirong 已提交
2603

G
ge-yafang 已提交
2604
setKeepScreenOn(isKeepScreenOn: boolean): Promise&lt;void&gt;
Z
xxx  
zhirong 已提交
2605

G
ge-yafang 已提交
2606
设置屏幕是否为常亮状态,使用Promise异步回调。
Z
xxx  
zhirong 已提交
2607 2608 2609

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

G
ge-yafang 已提交
2610 2611 2612 2613 2614 2615 2616
**参数:** 

| 参数名         | 类型    | 必填 | 说明                     |
| -------------- | ------- | ---- | ------------------------ |
| isKeepScreenOn | boolean | 是   | 设置屏幕是否为常亮状态。 |

**返回值:** 
Z
xxx  
zhirong 已提交
2617

G
ge-yafang 已提交
2618 2619 2620
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
Z
xxx  
zhirong 已提交
2621 2622 2623

**示例:**

G
ge-yafang 已提交
2624 2625 2626 2627 2628 2629 2630 2631 2632
```js
var isKeepScreenOn = true;
let promise = windowClass.setKeepScreenOn(isKeepScreenOn);
promise.then((data) => {
    console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.info('Failed to set the screen to be always on. Cause:  ' + JSON.stringify(err)); 
});
```
Z
xxx  
zhirong 已提交
2633 2634 2635

### setOutsideTouchable<sup>(deprecated)</sup>

G
ge-yafang 已提交
2636
setOutsideTouchable(touchable: boolean, callback: AsyncCallback&lt;void&gt;): void
Z
xxx  
zhirong 已提交
2637

G
ge-yafang 已提交
2638
设置是否允许可点击子窗口之外的区域,使用callback异步回调。
Z
xxx  
zhirong 已提交
2639

2640
> **说明:** 从API version 9开始废弃。该API不支持使用。
Z
xxx  
zhirong 已提交
2641 2642 2643 2644 2645 2646 2647
> 
> 从 API version 7开始支持。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

G
ge-yafang 已提交
2648 2649 2650 2651
| 参数名    | 类型                      | 必填 | 说明             |
| --------- | ------------------------- | ---- | ---------------- |
| touchable | boolean                   | 是   | 设置是否可点击。 |
| callback  | AsyncCallback&lt;void&gt; | 是   | 回调函数。       |
Z
xxx  
zhirong 已提交
2652 2653 2654

**示例:**

G
ge-yafang 已提交
2655 2656 2657 2658 2659 2660 2661 2662 2663
```js
windowClass.setOutsideTouchable(true, (err, data) => {
    if (err.code) {
        console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data));
})
```
Z
xxx  
zhirong 已提交
2664

G
ge-yafang 已提交
2665
### setOutsideTouchable<sup>(deprecated)</sup>
C
chyyy0213 已提交
2666

G
ge-yafang 已提交
2667
setOutsideTouchable(touchable: boolean): Promise&lt;void&gt;
C
chyyy0213 已提交
2668

G
ge-yafang 已提交
2669 2670
设置是否允许可点击子窗口之外的区域,使用Promise异步回调。。

2671
> **说明:** 从API version 9开始废弃。该API不支持使用。
G
ge-yafang 已提交
2672 2673
> 
> 从 API version 7开始支持。
C
chyyy0213 已提交
2674

G
ge-yafang 已提交
2675
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2676

G
ge-yafang 已提交
2677
**参数:**
C
chyyy0213 已提交
2678

G
ge-yafang 已提交
2679 2680 2681
| 参数名    | 类型    | 必填 | 说明             |
| --------- | ------- | ---- | ---------------- |
| touchable | boolean | 是   | 设置是否可点击。 |
C
chyyy0213 已提交
2682

G
ge-yafang 已提交
2683
**返回值:**
C
chyyy0213 已提交
2684

G
ge-yafang 已提交
2685 2686 2687
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
2688

G
ge-yafang 已提交
2689
**示例:**
C
chyyy0213 已提交
2690

G
ge-yafang 已提交
2691 2692 2693 2694 2695 2696 2697 2698
```js
let promise = windowClass.setOutsideTouchable(true);
promise.then((data)=> {
    console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
2699 2700 2701 2702 2703

### setPrivacyMode<sup>7+</sup>

setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback&lt;void&gt;): void

G
ge-yafang 已提交
2704
设置窗口是否为隐私模式,使用callback异步回调。
C
chyyy0213 已提交
2705

G
ge-yafang 已提交
2706
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2707

G
ge-yafang 已提交
2708
**参数:** 
C
chyyy0213 已提交
2709

G
ge-yafang 已提交
2710 2711 2712 2713
| 参数名        | 类型                      | 必填 | 说明                 |
| ------------- | ------------------------- | ---- | -------------------- |
| isPrivacyMode | boolean                   | 是   | 窗口是否为隐私模式。 |
| callback      | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
C
chyyy0213 已提交
2714

G
ge-yafang 已提交
2715
**示例:** 
C
chyyy0213 已提交
2716

G
ge-yafang 已提交
2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727
```js
var isPrivacyMode = true;
windowClass.setPrivacyMode(isPrivacyMode, (err, data) => {
    if (err.code) {
        console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data));

});
```
C
chyyy0213 已提交
2728 2729 2730 2731 2732

### setPrivacyMode<sup>7+</sup>

setPrivacyMode(isPrivacyMode: boolean): Promise&lt;void&gt;

G
ge-yafang 已提交
2733
设置窗口是否为隐私模式,使用Promise异步回调。
C
chyyy0213 已提交
2734

G
ge-yafang 已提交
2735
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2736

G
ge-yafang 已提交
2737
**参数:** 
C
chyyy0213 已提交
2738

G
ge-yafang 已提交
2739 2740 2741
| 参数名        | 类型    | 必填 | 说明                 |
| ------------- | ------- | ---- | -------------------- |
| isPrivacyMode | boolean | 是   | 窗口是否为隐私模式。 |
C
chyyy0213 已提交
2742

G
ge-yafang 已提交
2743
**返回值:** 
C
chyyy0213 已提交
2744

G
ge-yafang 已提交
2745 2746 2747
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
2748

G
ge-yafang 已提交
2749
**示例:** 
C
chyyy0213 已提交
2750

G
ge-yafang 已提交
2751 2752 2753 2754 2755 2756 2757 2758 2759
```js
var isPrivacyMode = true;
let promise = windowClass.setPrivacyMode(isPrivacyMode);
promise.then((data)=> {
    console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
2760 2761 2762 2763 2764

### setTouchable<sup>7+</sup>

setTouchable(isTouchable: boolean, callback: AsyncCallback&lt;void&gt;): void

G
ge-yafang 已提交
2765
设置窗口是否为可触状态,使用callback异步回调。
C
chyyy0213 已提交
2766

G
ge-yafang 已提交
2767
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2768

G
ge-yafang 已提交
2769
**参数:** 
C
chyyy0213 已提交
2770

G
ge-yafang 已提交
2771 2772 2773 2774
| 参数名      | 类型                      | 必填 | 说明                 |
| ----------- | ------------------------- | ---- | -------------------- |
| isTouchable | boolean                   | 是   | 窗口是否为可触状态。 |
| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
C
chyyy0213 已提交
2775

G
ge-yafang 已提交
2776
**示例:** 
C
chyyy0213 已提交
2777

G
ge-yafang 已提交
2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788
```js
var isTouchable = true;
windowClass.setTouchable(isTouchable, (err, data) => {
    if (err.code) {
        console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data));

});
```
C
chyyy0213 已提交
2789 2790 2791 2792 2793

### setTouchable<sup>7+</sup>

setTouchable(isTouchable: boolean): Promise&lt;void&gt;

G
ge-yafang 已提交
2794
设置窗口是否为可触状态,使用Promise异步回调。
C
chyyy0213 已提交
2795

G
ge-yafang 已提交
2796
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
C
chyyy0213 已提交
2797

G
ge-yafang 已提交
2798
**参数:** 
C
chyyy0213 已提交
2799

G
ge-yafang 已提交
2800 2801 2802
| 参数名      | 类型    | 必填 | 说明                 |
| ----------- | ------- | ---- | -------------------- |
| isTouchable | boolean | 是   | 窗口是否为可触状态。 |
C
chyyy0213 已提交
2803

G
ge-yafang 已提交
2804
**返回值:** 
C
chyyy0213 已提交
2805

G
ge-yafang 已提交
2806 2807 2808
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
C
chyyy0213 已提交
2809

G
ge-yafang 已提交
2810
**示例:** 
C
chyyy0213 已提交
2811

G
ge-yafang 已提交
2812 2813 2814 2815 2816 2817 2818 2819 2820
```js
var isTouchable = true;
let promise = windowClass.setTouchable(isTouchable);
promise.then((data)=> {
    console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
});
```
C
chyyy0213 已提交
2821

W
wlj 已提交
2822 2823 2824 2825 2826 2827
### setForbidSplitMove<sup>9+</sup>

setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback&lt;void&gt;): void

设置窗口在分屏模式下是否被禁止移动,使用callback异步回调。

2828
此接口为系统接口。
W
wlj 已提交
2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:** 

| 参数名      | 类型                      | 必填 | 说明                 |
| ----------- | ------------------------- | ---- | -------------------- |
| isForbidSplitMove | boolean                   | 是   | 窗口在分屏模式下是否被禁止移动。 |
| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |

**示例:** 

```js
var isForbidSplitMove = true;
windowClass.setForbidSplitMove(isForbidSplitMove, (err, data) => {
    if (err.code) {
        console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in forbidding window moving in split screen mode. Data:' + JSON.stringify(data));

});
```

### setForbidSplitMove<sup>9+</sup>

setForbidSplitMove(isForbidSplitMove: boolean): Promise&lt;void&gt;

设置窗口在分屏模式下是否被禁止移动,使用Promise异步回调。

2859
此接口为系统接口。
W
wlj 已提交
2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:** 

| 参数名      | 类型    | 必填 | 说明                 |
| ----------- | ------- | ---- | -------------------- |
| isForbidSplitMove | boolean | 是   | 窗口在分屏模式下是否被禁止移动。 |

**返回值:** 

| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |

**示例:** 

```js
var isForbidSplitMove = true;
let promise = windowClass.setForbidSplitMove(isForbidSplitMove);
promise.then((data)=> {
    console.info('Succeeded in forbidding window moving in split screen mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to forbidd window moving in split screen mode. Cause: ' + JSON.stringify(err));
});
```

2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939
### snapshot<sup>9+</sup>

snapshot(callback: AsyncCallback&lt;image.PixelMap&gt;): void

获取窗口截图,使用callback异步回调。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:**

| 参数名      | 类型                      | 必填 | 说明                 |
| ----------- | ------------------------- | ---- | -------------------- |
| callback    | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | 是   | 回调函数。  |

**示例:**

```js
windowClass.snapshot((err, data) => {
    if (err.code) {
        console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
    data.release(); // PixelMap使用完后及时释放内存
});
```

### snapshot<sup>9+</sup>

snapshot(): Promise&lt;image.PixelMap&gt;

获取窗口截图,使用Promise异步回调。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**返回值:**

| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Promise对象。返回当前窗口截图。 |

**示例:**

```js
let promise = windowClass.snapshot();
promise.then((pixelMap)=> {
    console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
    pixelMap.release(); // PixelMap使用完后及时释放内存
}).catch((err)=>{
    console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
});
```

G
ge-yafang 已提交
2940
## WindowStageEventType<sup>9+</sup>
L
leafly2021 已提交
2941 2942 2943

WindowStage生命周期。

G
ge-yafang 已提交
2944 2945 2946
此接口仅可在Stage模型下使用。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core
L
leafly2021 已提交
2947

G
ge-yafang 已提交
2948 2949 2950 2951 2952 2953
| 名称       | 默认值 | 说明       |
| ---------- | ------ | ---------- |
| FOREGROUND | 1      | 切到前台。 |
| ACTIVE     | 2      | 获焦状态。 |
| INACTIVE   | 3      | 失焦状态。 |
| BACKGROUND | 4      | 切到后台。 |
L
leafly2021 已提交
2954 2955 2956

## WindowStage<sup>9+</sup>

G
ge-yafang 已提交
2957 2958
窗口管理器。管理各个基本窗口单元,即[Window](#window)实例。

L
leafly2021 已提交
2959 2960 2961 2962
下列API示例中都需在[onWindowStageCreate()](js-apis-application-ability.md#abilityonwindowstagecreate)函数中使用WindowStage的实例调用对应方法。

### getMainWindow<sup>9+</sup>

G
ge-yafang 已提交
2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997
getMainWindow(callback: AsyncCallback&lt;Window&gt;): void

获取该WindowStage实例下的主窗口,使用callback异步回调。

此接口仅可在Stage模型下使用。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:** 

| 参数名   | 类型                                   | 必填 | 说明                                          |
| -------- | -------------------------------------- | ---- | --------------------------------------------- |
| callback | AsyncCallback&lt;[Window](#window)&gt; | 是   | 回调函数。返回当前WindowStage下的主窗口对象。 |

**示例:** 

```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        var windowClass = null;
        windowStage.getMainWindow((err, data) => {
            if (err.code) {
                console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
                return;
            }
            windowClass = data;
            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
        });
    }
}
```
### getMainWindow<sup>9+</sup>

L
leafly2021 已提交
2998 2999
getMainWindow(): Promise&lt;Window&gt;

G
ge-yafang 已提交
3000
获取该WindowStage实例下的主窗口,使用Promise异步回调。
L
leafly2021 已提交
3001

G
ge-yafang 已提交
3002 3003
此接口仅可在Stage模型下使用。

G
ge-yafang 已提交
3004
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
L
leafly2021 已提交
3005

G
ge-yafang 已提交
3006
**返回值:** 
L
leafly2021 已提交
3007

G
ge-yafang 已提交
3008 3009 3010
| 类型                             | 说明                                             |
| -------------------------------- | ------------------------------------------------ |
| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前WindowStage下的主窗口对象。 |
L
leafly2021 已提交
3011

G
ge-yafang 已提交
3012
**示例:** 
L
leafly2021 已提交
3013

G
ge-yafang 已提交
3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        var windowClass = null;
        let promise = windowStage.getMainWindow();
        promise.then((data)=> {
        windowClass = data;
            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
        }).catch((err)=>{
            console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
        });
    }
}
```
### createSubWindow<sup>9+</sup>
L
leafly2021 已提交
3031

G
ge-yafang 已提交
3032 3033 3034 3035 3036
createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void

创建该WindowStage实例下的子窗口,使用callback异步回调。

此接口仅可在Stage模型下使用。
L
leafly2021 已提交
3037

G
ge-yafang 已提交
3038
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
L
leafly2021 已提交
3039

G
ge-yafang 已提交
3040
**参数:** 
L
leafly2021 已提交
3041

G
ge-yafang 已提交
3042 3043 3044 3045
| 参数名   | 类型                                   | 必填 | 说明                                          |
| -------- | -------------------------------------- | ---- | --------------------------------------------- |
| name     | String                                 | 是   | 子窗口的名字。                                |
| callback | AsyncCallback&lt;[Window](#window)&gt; | 是   | 回调函数。返回当前WindowStage下的子窗口对象。 |
L
leafly2021 已提交
3046

G
ge-yafang 已提交
3047
**示例:** 
L
leafly2021 已提交
3048

G
ge-yafang 已提交
3049 3050 3051 3052 3053 3054 3055 3056
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        var windowClass = null;
        windowStage.createSubWindow("mySubWindow", (err, data) => {
            if (err.code) {
3057
                console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
G
ge-yafang 已提交
3058 3059 3060
                return;
            }
            windowClass = data;
3061
            console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
G
ge-yafang 已提交
3062 3063 3064 3065 3066
            windowClass.resetSize(500, 1000);
        });
    }
}
```
L
leafly2021 已提交
3067 3068 3069 3070
### createSubWindow<sup>9+</sup>

createSubWindow(name: string): Promise&lt;Window&gt;

G
ge-yafang 已提交
3071
创建该WindowStage实例下的子窗口,使用Promise异步回调。
L
leafly2021 已提交
3072

G
ge-yafang 已提交
3073 3074
此接口仅可在Stage模型下使用。

G
ge-yafang 已提交
3075
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
3076

G
ge-yafang 已提交
3077
**参数:** 
L
leafly2021 已提交
3078

G
ge-yafang 已提交
3079 3080 3081
| 参数名 | 类型   | 必填 | 说明           |
| ------ | ------ | ---- | -------------- |
| name   | String | 是   | 子窗口的名字。 |
G
ge-yafang 已提交
3082

G
ge-yafang 已提交
3083
**返回值:** 
L
leafly2021 已提交
3084

G
ge-yafang 已提交
3085 3086 3087
| 类型                             | 说明                                             |
| -------------------------------- | ------------------------------------------------ |
| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前WindowStage下的子窗口对象。 |
L
leafly2021 已提交
3088

G
ge-yafang 已提交
3089
**示例:** 
L
leafly2021 已提交
3090

G
ge-yafang 已提交
3091 3092 3093 3094 3095 3096 3097 3098 3099
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        var windowClass = null;
        let promise = windowStage.createSubWindow("mySubWindow");
        promise.then((data)=> {
            windowClass = data;
3100
            console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
G
ge-yafang 已提交
3101
        }).catch((err)=>{
3102
            console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
G
ge-yafang 已提交
3103 3104 3105 3106 3107
        })
    }
}
```
### getSubWindow<sup>9+</sup>
L
leafly2021 已提交
3108

G
ge-yafang 已提交
3109 3110 3111 3112 3113
getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void

获取该WindowStage实例下的所有子窗口,使用callback异步回调。

此接口仅可在Stage模型下使用。
L
leafly2021 已提交
3114

G
ge-yafang 已提交
3115
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
L
leafly2021 已提交
3116

G
ge-yafang 已提交
3117
**参数:** 
L
leafly2021 已提交
3118

G
ge-yafang 已提交
3119 3120 3121
| 参数名   | 类型                                                | 必填 | 说明                                              |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[Window](#window)&gt;&gt; | 是   | 回调函数。返回当前WindowStage下的所有子窗口对象。 |
L
leafly2021 已提交
3122

G
ge-yafang 已提交
3123
**示例:** 
L
leafly2021 已提交
3124

G
ge-yafang 已提交
3125 3126 3127 3128 3129 3130 3131 3132
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        var windowClass = null;
        windowStage.getSubWindow((err, data) => {
            if (err.code) {
3133
                console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
G
ge-yafang 已提交
3134 3135 3136
                return;
            }
            windowClass = data;
3137
            console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
G
ge-yafang 已提交
3138 3139 3140 3141
        });
    }
}
```
L
leafly2021 已提交
3142 3143 3144 3145
### getSubWindow<sup>9+</sup>

getSubWindow(): Promise&lt;Array&lt;Window&gt;&gt;

G
ge-yafang 已提交
3146
获取该WindowStage实例下的所有子窗口,使用Promise异步回调。
L
leafly2021 已提交
3147

G
ge-yafang 已提交
3148 3149
此接口仅可在Stage模型下使用。

G
ge-yafang 已提交
3150
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
3151

G
ge-yafang 已提交
3152
**返回值:** 
L
leafly2021 已提交
3153

G
ge-yafang 已提交
3154 3155 3156
| 类型                                          | 说明                                                 |
| --------------------------------------------- | ---------------------------------------------------- |
| Promise&lt;Array&lt;[Window](#window)&gt;&gt; | Promise对象。返回当前WindowStage下的所有子窗口对象。 |
L
leafly2021 已提交
3157

G
ge-yafang 已提交
3158
**示例:** 
L
leafly2021 已提交
3159

G
ge-yafang 已提交
3160 3161 3162 3163 3164 3165 3166 3167 3168
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        var windowClass = null;
        let promise = windowStage.getSubWindow();
        promise.then((data)=> {
            windowClass = data;
3169
            console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
G
ge-yafang 已提交
3170
        }).catch((err)=>{
3171
            console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
G
ge-yafang 已提交
3172 3173 3174 3175 3176
        })
    }
}
```
### loadContent<sup>9+</sup>
L
leafly2021 已提交
3177

G
ge-yafang 已提交
3178 3179 3180 3181 3182
loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void&gt;): void

为当前WindowStage的主窗口加载与LocalStorage相关联的具体页面内容,使用callback异步回调。

此接口仅可在Stage模型下使用。
L
leafly2021 已提交
3183

G
ge-yafang 已提交
3184
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
3185

G
ge-yafang 已提交
3186
**参数:** 
L
leafly2021 已提交
3187

G
ge-yafang 已提交
3188 3189 3190 3191 3192
| 参数名   | 类型                                            | 必填 | 说明                                                         |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path     | string                                          | 是   | 设置加载页面的路径。                                         |
| storage  | [LocalStorage](../../ui/ui-ts-local-storage.md) | 是   | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 |
| callback | AsyncCallback&lt;void&gt;                       | 是   | 回调函数。                                                   |
L
leafly2021 已提交
3193

G
ge-yafang 已提交
3194
**示例:**
L
leafly2021 已提交
3195

G
ge-yafang 已提交
3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    storage : LocalStorage  
    onWindowStageCreate(windowStage) {
        this.storage = new LocalStorage();
        this.storage.setOrCreate("storageSimpleProp",121);
        console.log('onWindowStageCreate');
        windowStage.loadContent("pages/page2",this.storage,(err, data) => {
            if (err.code) {
                console.error('Failed to load the content. Cause:' + JSON.stringify(err));
                return;
            }
            console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
        });
    }
}
```

### loadContent<sup>9+</sup>

G
ge-yafang 已提交
3217
loadContent(path: string, storage?: LocalStorage): Promise&lt;void&gt;
G
ge-yafang 已提交
3218 3219 3220 3221 3222 3223 3224 3225 3226

为当前WindowStage的主窗口加载与LocalStorage相关联的具体页面内容,使用Promise异步回调。

此接口仅可在Stage模型下使用。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:** 

G
ge-yafang 已提交
3227 3228 3229 3230
| 参数名  | 类型                                            | 必填 | 说明                                                         |
| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path    | string                                          | 是   | 设置加载页面的路径。                                         |
| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | 否   | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 |
G
ge-yafang 已提交
3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258

**返回值:**

| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |

**示例:**

```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    storage : LocalStorage 
    onWindowStageCreate(windowStage) {
        this.storage = new LocalStorage();
        this.storage.setOrCreate("storageSimpleProp",121);
        console.log('onWindowStageCreate');
        var windowClass = null;
        let promise = windowStage.loadContent("pages/page2",this.storage);
        promise.then((data)=> {
            windowClass = data;
            console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
        }).catch((err)=>{
            console.error('Failed to load the content. Cause:' + JSON.stringify(err));
        })
    }
}
```
L
leafly2021 已提交
3259 3260 3261 3262 3263

### loadContent<sup>9+</sup>

loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void

G
ge-yafang 已提交
3264
为当前WindowStage的主窗口加载具体页面内容,使用callback异步回调。
L
leafly2021 已提交
3265

G
ge-yafang 已提交
3266 3267 3268
此接口仅可在Stage模型下使用。

**系统能力:** SystemCapability.WindowManager.WindowManager.Core
L
leafly2021 已提交
3269

G
ge-yafang 已提交
3270
**参数:** 
L
leafly2021 已提交
3271

G
ge-yafang 已提交
3272 3273 3274 3275
| 参数名   | 类型                      | 必填 | 说明                 |
| -------- | ------------------------- | ---- | -------------------- |
| path     | string                    | 是   | 设置加载页面的路径。 |
| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
G
ge-yafang 已提交
3276

G
ge-yafang 已提交
3277
**示例:** 
L
leafly2021 已提交
3278

G
ge-yafang 已提交
3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        windowStage.loadContent("pages/page2", (err, data) => {
            if (err.code) {
                console.error('Failed to load the content. Cause:' + JSON.stringify(err));
                return;
            }
            console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
        });
    }
}
```
G
ge-yafang 已提交
3294

L
leafly2021 已提交
3295 3296 3297 3298 3299 3300
### on('windowStageEvent')<sup>9+</sup>

on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void

开启WindowStage生命周期变化的监听。

G
ge-yafang 已提交
3301 3302
此接口仅可在Stage模型下使用。

G
ge-yafang 已提交
3303
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
3304

G
ge-yafang 已提交
3305
**参数:** 
L
leafly2021 已提交
3306

G
ge-yafang 已提交
3307 3308 3309
| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type     | string                                                       | 是   | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 |
G
ge-yafang 已提交
3310
| callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | 是   | 回调函数。返回当前的WindowStage生命周期状态。                |
L
leafly2021 已提交
3311

G
ge-yafang 已提交
3312
**示例:** 
L
leafly2021 已提交
3313

G
ge-yafang 已提交
3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        windowStage.on('windowStageEvent', (data) => {
            console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data));
        });
    }
}
```
L
leafly2021 已提交
3325 3326 3327 3328 3329 3330 3331

### off('windowStageEvent')<sup>9+</sup>

off(eventType: 'windowStageEvent', callback?: Callback&lt;WindowStageEventType&gt;): void

关闭WindowStage生命周期变化的监听。

G
ge-yafang 已提交
3332 3333
此接口仅可在Stage模型下使用。

G
ge-yafang 已提交
3334
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
3335

G
ge-yafang 已提交
3336
**参数:** 
L
leafly2021 已提交
3337

G
ge-yafang 已提交
3338 3339 3340
| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type     | string                                                       | 是   | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 |
G
ge-yafang 已提交
3341
| callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | 否   | 回调函数。返回当前的WindowStage生命周期状态。                |
G
ge-yafang 已提交
3342

G
ge-yafang 已提交
3343
**示例:** 
L
leafly2021 已提交
3344

G
ge-yafang 已提交
3345 3346 3347 3348 3349 3350 3351 3352 3353
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        windowStage.off('windowStageEvent');
    }
}
```
Q
qianlf 已提交
3354

L
leafly2021 已提交
3355 3356 3357 3358 3359 3360 3361 3362
### disableWindowDecor()<sup>9+</sup>

disableWindowDecor(): void

禁止窗口装饰。

此接口仅可在Stage模型下使用。

3363
此接口为系统接口。
L
leafly2021 已提交
3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379

**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**示例:** 

```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('disableWindowDecor');
        windowStage.disableWindowDecor();
    }
}
```

### setShowOnLockScreen()<sup>9+</sup>
Q
qianlf 已提交
3380 3381 3382 3383 3384

setShowOnLockScreen(showOnLockScreen: boolean): void

设置应用显示在锁屏之上。

G
ge-yafang 已提交
3385 3386
此接口仅可在Stage模型下使用。

Q
qianlf 已提交
3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397
**系统能力:** SystemCapability.WindowManager.WindowManager.Core

**参数:** 

| 参数名           | 类型    | 必填 | 说明                         |
| ---------------- | ------- | ---- | ---------------------------- |
| showOnLockScreen | boolean | 是   | 是否设置应用显示在锁屏之上。 |

**示例:** 

```ts
G
ge-yafang 已提交
3398
import Ability from '@ohos.application.Ability';
Q
qianlf 已提交
3399 3400 3401 3402 3403 3404 3405 3406
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        windowStage.setShowOnLockScreen(true);
    }
}
```