js-apis-window.md 150.1 KB
Newer Older
W
wusongqing 已提交
1
# Window
Z
zengyawen 已提交
2

3
The `Window` module provides basic window management capabilities, such as creating and destroying the current window, setting properties for the current window, and managing and scheduling windows.
W
wusongqing 已提交
4

5 6 7 8 9 10 11
This module provides the following common window-related functions:

- [Window](#window): the current window instance, which is the basic unit managed by the window manager.
- [WindowStage](#windowstage9): window manager that manages windows.

> **NOTE**
>
W
wusongqing 已提交
12
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Z
zengyawen 已提交
13

W
wusongqing 已提交
14
## Modules to Import
Z
zengyawen 已提交
15

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

W
wusongqing 已提交
20
## WindowType<sup>7+</sup>
W
wusongqing 已提交
21

W
wusongqing 已提交
22
Enumerates the window types.
W
wusongqing 已提交
23

W
wusongqing 已提交
24
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
25

26
| Name             | Value| Description              |
W
wusongqing 已提交
27
| ----------------- | ------ | ------------------ |
28
| TYPE_APP          | 0      | Application subwindow.<br>**Model restriction**: This API can be used only in the FA model.|
W
wusongqing 已提交
29
| TYPE_SYSTEM_ALERT | 1      | System alert window.|
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| TYPE_INPUT_METHOD<sup>9+</sup> | 2      | Input method window.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
| TYPE_STATUS_BAR<sup>9+</sup>   | 3      | Status bar.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
| TYPE_PANEL<sup>9+</sup>        | 4      | Notification panel.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
| TYPE_KEYGUARD<sup>9+</sup>     | 5      | Lock screen.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
| TYPE_VOLUME_OVERLAY<sup>9+</sup> | 6      | Volume bar.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
| TYPE_NAVIGATION_BAR<sup>9+</sup> | 7      | Navigation bar.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
| TYPE_FLOAT<sup>9+</sup> | 8      | Floating window.<br>**Model restriction**: This API can be used only in the stage model.<br>**Required permissions**: ohos.permission.SYSTEM_FLOAT_WINDOW|
| TYPE_WALLPAPER<sup>9+</sup> | 9      | Wallpaper.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
| TYPE_DESKTOP<sup>9+</sup> | 10      | Home screen.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
| TYPE_LAUNCHER_RECENT<sup>9+</sup> | 11      | Recent tasks screen.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
| TYPE_LAUNCHER_DOCK<sup>9+</sup> | 12      | Dock bar on the home screen.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
| TYPE_VOICE_INTERACTION<sup>9+</sup> | 13      | Voice assistant.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
| TYPE_POINTER<sup>9+</sup> | 14      | Mouse.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
| TYPE_FLOAT_CAMERA<sup>9+</sup> | 15      | Floating camera window.<br>**Model restriction**: This API can be used only in the stage model.<br>**Required permissions**: ohos.permission.SYSTEM_FLOAT_WINDOW|
| TYPE_DIALOG<sup>9+</sup>  | 16      | Modal window.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
| TYPE_SCREENSHOT<sup>9+</sup>  | 17      | Screenshot window.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
Z
zengyawen 已提交
46

W
wusongqing 已提交
47
## AvoidAreaType<sup>7+</sup>
W
wusongqing 已提交
48 49 50 51 52

Enumerates the types of the area where the window cannot be displayed.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

53 54 55 56 57 58
| Name                              | Value | Description             |
|----------------------------------|-----| ----------------- |
| TYPE_SYSTEM                      | 0   | Default area of the system.|
| TYPE_CUTOUT                      | 1   | Notch. |
| TYPE_SYSTEM_GESTURE<sup>9+</sup> | 2   | Gesture area.   |
| TYPE_KEYBOARD<sup>9+</sup>       | 3   | Soft keyboard area. |
W
wusongqing 已提交
59

W
wusongqing 已提交
60
## WindowMode<sup>7+</sup>
W
wusongqing 已提交
61

62 63
Enumerates the window modes.

64
**System API**: This is a system API.
65 66 67 68 69 70 71 72 73 74 75 76 77 78

**System capability**: SystemCapability.WindowManager.WindowManager.Core

| Name      | Value  | Description                         |
| ---------- | ---- | ----------------------------- |
| UNDEFINED  | 1    | The window mode is not defined by the application.      |
| FULLSCREEN | 2    | The application is displayed in full screen.            |
| PRIMARY    | 3    | The application is displayed in the primary window in split-screen mode.  |
| SECONDARY  | 4    | The application is displayed in the secondary window in split-screen mode.  |
| FLOATING   | 5    | The application is displayed in a floating window.|

## WindowLayoutMode<sup>9+</sup>

Enumerates the window layout modes.
W
wusongqing 已提交
79

80
**System API**: This is a system API.
W
wusongqing 已提交
81 82 83

**System capability**: SystemCapability.WindowManager.WindowManager.Core

84 85 86 87
| Name      | Value  | Description                         |
| ---------- | ---- | ----------------------------- |
| WINDOW_LAYOUT_MODE_CASCADE  | 0    | Cascade mode.      |
| WINDOW_LAYOUT_MODE_TILE | 1    | Tile mode.            |
W
wusongqing 已提交
88

W
wusongqing 已提交
89
## SystemBarProperties
Z
zengyawen 已提交
90 91 92

Describes the properties of the status bar and navigation bar.

W
wusongqing 已提交
93 94
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
95 96
| Name                                  | Type| Readable| Writable| Description                                                        |
| -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ |
97
| statusBarColor                         | string   | Yes  | Yes  | Background color of the status bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
W
wusongqing 已提交
98 99
| isStatusBarLightIcon<sup>7+</sup>      | boolean  | No  | Yes  | Whether any icon on the status bar is highlighted.                                  |
| statusBarContentColor<sup>8+</sup>     | string   | No  | Yes  | Color of the text on the status bar.                                            |
100
| navigationBarColor                     | string   | Yes  | Yes  | Background color of the navigation bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
W
wusongqing 已提交
101 102
| isNavigationBarLightIcon<sup>7+</sup>  | boolean  | No  | No  | Whether any icon on the navigation bar is highlighted.                                  |
| navigationBarContentColor<sup>8+</sup> | string   | No  | Yes  | Color of the text on the navigation bar.                                            |
W
wusongqing 已提交
103

104 105 106 107 108 109 110 111 112 113 114
## Orientation<sup>9+</sup>

Enumerates the window orientations.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

| Name                                 | Value  | Description                         |
| ------------------------------------- | ---- | ----------------------------- |
| UNSPECIFIED                           | 0    | Unspecified. The orientation is determined by the system.|
| PORTRAIT                              | 1    | Portrait.            |
| LANDSCAPE                             | 2    | Landscape.  |
X
xpeng 已提交
115
| PORTRAIT_INVERTED                     | 3    | Reverse portrait.  |
116 117 118 119 120 121 122 123 124
| LANDSCAPE_INVERTED                    | 4    | Reverse landscape.|
| AUTO_ROTATION                         | 5    | Auto rotation.|
| AUTO_ROTATION_PORTRAIT                | 6    | Auto rotation in the vertical direction.|
| AUTO_ROTATION_LANDSCAPE               | 7    | Auto rotation in the horizontal direction.|
| AUTO_ROTATION_RESTRICTED              | 8    | Switched-determined auto rotation.|
| AUTO_ROTATION_PORTRAIT_RESTRICTED     | 9    | Switched-determined auto rotation in the vertical direction.|
| AUTO_ROTATION_LANDSCAPE_RESTRICTED    | 10   | Switched-determined auto rotation in the horizontal direction.|
| LOCKED                                | 11   | Locked.|

125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
## BlurStyle<sup>9+</sup>

Enumerates the window blur styles.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

| Name   | Value  | Description                |
| ------- | ---- | -------------------- |
| OFF     | 0    | Blur disabled.      |
| THIN    | 1    | Thin blur.|
| REGULAR | 2    | Regular blur.|
| THICK   | 3    | Thick blur.|

W
wusongqing 已提交
140
## SystemBarRegionTint<sup>8+</sup>
W
wusongqing 已提交
141 142 143

Describes the callback for a single system bar.

144
**System API**: This is a system API.
W
wusongqing 已提交
145 146 147

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
148 149
| Name           | Type                 | Readable| Writable| Description                                                        |
| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
150
| type            | [WindowType](#windowtype) | Yes  | Yes  | Type of the system bar whose properties are changed. Only the status bar and navigation bar are supported.|
W
wusongqing 已提交
151 152
| isEnable        | boolean                   | Yes  | Yes  | Whether the system bar is displayed.                                        |
| region          | [Rect](#rect)             | Yes  | Yes  | Current position and size of the system bar.                                    |
153
| backgroundColor | string                    | Yes  | Yes  | Background color of the system bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
W
wusongqing 已提交
154
| contentColor    | string                    | Yes  | Yes  | Color of the text on the system bar.                                            |
W
wusongqing 已提交
155

W
wusongqing 已提交
156
## SystemBarTintState<sup>8+</sup>
W
wusongqing 已提交
157 158 159

Describes the callback for the current system bar.

160
**System API**: This is a system API.
W
wusongqing 已提交
161 162 163

**System capability**: SystemCapability.WindowManager.WindowManager.Core

164 165 166 167
| Name      | Type                                           | Readable| Writable| Description                        |
| ---------- | --------------------------------------------------- | ---- | ---- | ---------------------------- |
| displayId  | number                                              | Yes  | No  | ID of the current physical screen.            |
| regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | Yes  | Yes  | All system bar information that has been changed.|
W
wusongqing 已提交
168

W
wusongqing 已提交
169
## Rect<sup>7+</sup>
Z
zengyawen 已提交
170

W
wusongqing 已提交
171
Describes the rectangular area of the window.
Z
zengyawen 已提交
172

W
wusongqing 已提交
173 174
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
175 176 177 178 179 180
| Name  | Type| Readable| Writable| Description              |
| ------ | -------- | ---- | ---- | ------------------ |
| left   | number   | Yes  | Yes  | Left boundary of the rectangle.|
| top    | number   | Yes  | Yes  | Top boundary of the rectangle.|
| width  | number   | Yes  | Yes  | Width of the rectangle.  |
| height | number   | Yes  | Yes  | Height of the rectangle.  |
W
wusongqing 已提交
181

W
wusongqing 已提交
182
## AvoidArea<sup>7+</sup>
Z
zengyawen 已提交
183 184 185

Describes the area where the window cannot be displayed.

W
wusongqing 已提交
186 187
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
188 189
| Name      | Type     | Readable| Writable| Description              |
| ---------- | ------------- | ---- | ---- | ------------------ |
190
| visible<sup>9+</sup>    | boolean       | Yes  | Yes  | Whether the window can be displayed in the area.|
W
wusongqing 已提交
191 192 193 194
| leftRect   | [Rect](#rect) | Yes  | Yes  | Rectangle on the left of the screen.|
| topRect    | [Rect](#rect) | Yes  | Yes  | Rectangle at the top of the screen.|
| rightRect  | [Rect](#rect) | Yes  | Yes  | Rectangle on the right of the screen.|
| bottomRect | [Rect](#rect) | Yes  | Yes  | Rectangle at the bottom of the screen.|
W
wusongqing 已提交
195

W
wusongqing 已提交
196
## Size<sup>7+</sup>
Z
zengyawen 已提交
197 198 199

Describes the window size.

W
wusongqing 已提交
200 201
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
202 203 204 205
| Name  | Type| Readable| Writable| Description      |
| ------ | -------- | ---- | ---- | ---------- |
| width  | number   | Yes  | Yes  | Window width.|
| height | number   | Yes  | Yes  | Window height.|
W
wusongqing 已提交
206

W
wusongqing 已提交
207
## WindowProperties
Z
zengyawen 已提交
208 209 210

Describes the window properties.

W
wusongqing 已提交
211
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
212

213 214 215 216 217 218 219 220 221 222 223 224 225 226
| Name                                 | Type                 | Readable| Writable| Description                                                        |
| ------------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| windowRect<sup>7+</sup>               | [Rect](#rect)             | Yes  | Yes  | Window size.                                                  |
| type<sup>7+</sup>                     | [WindowType](#windowtype) | Yes  | Yes  | Window type.                                                  |
| isFullScreen                          | boolean                   | Yes  | Yes  | Whether the window is displayed in full screen mode. The default value is `false`.                                     |
| isLayoutFullScreen<sup>7+</sup>       | boolean                   | Yes  | Yes  | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is `false`.                             |
| focusable<sup>7+</sup>                | boolean                   | Yes  | No  | Whether the window can gain focus. The default value is `true`.                                |
| touchable<sup>7+</sup>                | boolean                   | Yes  | No  | Whether the window is touchable. The default value is `true`.                                |
| brightness                            | number                    | Yes  | Yes  | Screen brightness. The value ranges from 0 to 1. The value `1` indicates the maximum brightness.                 |
| dimBehindValue<sup>(deprecated)</sup> | number                    | Yes  | Yes  | Dimness of the window that is not on top. The value ranges from 0 to 1. The value `1` indicates the maximum dimness.<br>**NOTE**<br>This property is supported since API version 7 and deprecated since API version 9.<br> |
| isKeepScreenOn                        | boolean                   | Yes  | Yes  | Whether the screen is always on. The default value is `false`.                                 |
| isPrivacyMode<sup>7+</sup>            | boolean                   | Yes  | Yes  | Whether the window is in privacy mode. The default value is `false`.                                     |
| isRoundCorner<sup>(deprecated)</sup>  | boolean                   | Yes  | Yes  | Whether the window has rounded corners. The default value is `false`.<br>**NOTE**<br>This property is supported since API version 7 and deprecated since API version 9.<br> |
| isTransparent<sup>7+</sup>            | boolean                   | Yes  | Yes  | Whether the window is transparent. The default value is `false`.                                 |
W
wusongqing 已提交
227

W
wusongqing 已提交
228
## ColorSpace<sup>8+</sup>
W
wusongqing 已提交
229 230 231 232 233

Describes the color gamut mode.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
234
| Name      | Default Value | Description          |
W
wusongqing 已提交
235 236 237
| ---------- | ------ | -------------- |
| DEFAULT    | 0      | Default color gamut mode.|
| WIDE_GAMUT | 1      | Wide color gamut mode.  |
W
wusongqing 已提交
238

239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
## ScaleOptions<sup>9+</sup>

Describes the scale parameters.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

| Name  | Type| Readable| Writable| Description                                              |
| ------ | -------- | ---- | ---- | -------------------------------------------------- |
| x      | number   | No  | Yes  | Scale factor of the x-axis. The default value is `1.0`.                      |
| y      | number   | No  | Yes  | Scale factor of the y-axis. The default value is `1.0`.                      |
| pivotX | number   | No  | Yes  | X coordinate of the scale center. The value ranges from 0.0 to 1.0, and the default value is `0.5`.|
| pivotY | number   | No  | Yes  | Y coordinate of the scale center. The value ranges from 0.0 to 1.0, and the default value is `0.5`.|

## RotateOptions<sup>9+</sup>

Describes the rotation parameters.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

| Name  | Type| Readable| Writable| Description                                              |
| ------ | -------- | ---- | ---- | -------------------------------------------------- |
| x      | number   | No  | Yes  | Rotation angle around the x-axis. The default value is `0.0`.                    |
| y      | number   | No  | Yes  | Rotation angle around the y-axis. The default value is `0.0`.                    |
| z      | number   | No  | Yes  | Rotation angle around the z-xis. The default value is `0.0`.                    |
| pivotX | number   | No  | Yes  | X coordinate of the rotation center. The value ranges from 0.0 to 1.0, and the default value is `0.5`.|
| pivotY | number   | No  | Yes  | Y coordinate of the rotation center. The value ranges from 0.0 to 1.0, and the default value is `0.5`.|

## TranslateOptions<sup>9+</sup>

Describes the translation parameters.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

| Name| Type| Readable| Writable| Description                        |
| ---- | -------- | ---- | ---- | ---------------------------- |
| x    | number   | No  | Yes  | Distance to translate along the x-axis. The default value is `0.0`.|
| y    | number   | No  | Yes  | Distance to translate along the y-axis. The default value is `0.0`.|
| z    | number   | No  | Yes  | Distance to translate along the z-axis. The default value is `0.0`.|

W
wusongqing 已提交
284
## window.create<sup>7+</sup>
W
wusongqing 已提交
285 286 287 288 289

create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void

Creates a subwindow. This API uses an asynchronous callback to return the result.

290
**Model restriction**: This API can be used only in the FA model.
W
wusongqing 已提交
291

W
wusongqing 已提交
292 293
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
294
**Parameters**
W
wusongqing 已提交
295

296 297 298 299
| Name  | Type                                  | Mandatory| Description                                |
| -------- | -------------------------------------- | ---- | ------------------------------------ |
| id       | string                                 | Yes  | Window ID.                            |
| type     | [WindowType](#windowtype)              | Yes  | Window type.                          |
W
wusongqing 已提交
300
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the subwindow created.|
W
wusongqing 已提交
301

W
wusongqing 已提交
302
**Example**
W
wusongqing 已提交
303

304 305
```js
var windowClass = null;
306 307 308 309 310 311 312 313
window.create("first", window.WindowType.TYPE_APP,(err,data) => {
    if(err.code){
        console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
        return;
    }
    windowClass = data;
    console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
});
314
```
W
wusongqing 已提交
315

W
wusongqing 已提交
316
## window.create<sup>7+</sup>
W
wusongqing 已提交
317 318 319 320 321

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

Creates a subwindow. This API uses a promise to return the result.

322
**Model restriction**: This API can be used only in the FA model.
W
wusongqing 已提交
323

W
wusongqing 已提交
324 325
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
326
**Parameters**
W
wusongqing 已提交
327

W
wusongqing 已提交
328 329 330 331
| Name| Type                     | Mandatory| Description      |
| ------ | ------------------------- | ---- | ---------- |
| id     | string                    | Yes  | Window ID.  |
| type   | [WindowType](#windowtype) | Yes  | Window type.|
W
wusongqing 已提交
332

W
wusongqing 已提交
333
**Return value**
W
wusongqing 已提交
334

335 336
| Type                            | Description                                   |
| -------------------------------- | --------------------------------------- |
W
wusongqing 已提交
337
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
W
wusongqing 已提交
338

W
wusongqing 已提交
339
**Example**
W
wusongqing 已提交
340

341 342 343 344 345
```js
var windowClass = null;
let promise = window.create("first", window.WindowType.TYPE_APP);
promise.then((data)=> {
    windowClass = data;
346
    console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
347 348 349 350
}).catch((err)=>{
    console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
});
```
Z
zengyawen 已提交
351

W
wusongqing 已提交
352 353 354 355
## window.create<sup>8+</sup>

create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void

W
wusongqing 已提交
356
Creates a subwindow (in API version 8) or a system window (from API version 9). This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
357 358 359

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
360
**Parameters**
W
wusongqing 已提交
361

W
wusongqing 已提交
362 363
| Name  | Type                                  | Mandatory| Description                                                        |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
364
| ctx      | Context                                | Yes  | Current application context.<br>For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).<br>For the definition of `Context` of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md).|
W
wusongqing 已提交
365 366
| id       | string                                 | Yes  | Window ID.                                                    |
| type     | [WindowType](#windowtype)              | Yes  | Window type.                                                  |
367
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the subwindow created.                        |
W
wusongqing 已提交
368

W
wusongqing 已提交
369
**Example**
W
wusongqing 已提交
370

371 372 373 374
```js
var windowClass = null;
 window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
    if (err.code) {
375
        console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
376 377 378
        return;
    }
    windowClass = data;
379
    console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data));
380 381 382
    windowClass.resetSize(500, 1000);
});
```
Z
zengyawen 已提交
383

W
wusongqing 已提交
384
## window.create<sup>8+</sup>
E
ester.zhou 已提交
385

W
wusongqing 已提交
386
create(ctx: Context, id: string, type: WindowType): Promise&lt;Window&gt;
E
ester.zhou 已提交
387

W
wusongqing 已提交
388
Creates a subwindow (in API version 8) or a system window (from API version 9). This API uses a promise to return the result.
W
wusongqing 已提交
389 390

**System capability**: SystemCapability.WindowManager.WindowManager.Core
E
ester.zhou 已提交
391

W
wusongqing 已提交
392
**Parameters**
E
ester.zhou 已提交
393

W
wusongqing 已提交
394 395
| Name| Type                     | Mandatory| Description                                                        |
| ------ | ------------------------- | ---- | ------------------------------------------------------------ |
396
| ctx    | Context                   | Yes  | Current application context.<br>For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).<br>For the definition of `Context` of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md).|
W
wusongqing 已提交
397 398
| id     | string                    | Yes  | Window ID.                                                    |
| type   | [WindowType](#windowtype) | Yes  | Window type.                                                  |
W
wusongqing 已提交
399

W
wusongqing 已提交
400
**Return value**
E
ester.zhou 已提交
401

402 403
| Type                            | Description                                   |
| -------------------------------- | --------------------------------------- |
404
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
E
ester.zhou 已提交
405

W
wusongqing 已提交
406
**Example**
W
wusongqing 已提交
407

408 409 410 411
```js
var windowClass = null;
let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT);
promise.then((data)=> {
412 413
    windowClass = data;
    console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
414 415 416 417
}).catch((err)=>{
    console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
});
```
W
wusongqing 已提交
418

W
wusongqing 已提交
419
## window.find<sup>7+</sup>
W
wusongqing 已提交
420 421 422 423 424 425 426

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

Finds a window based on the ID. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
427
**Parameters**
W
wusongqing 已提交
428

429 430 431
| Name  | Type                                  | Mandatory| Description                                |
| -------- | -------------------------------------- | ---- | ------------------------------------ |
| id       | string                                 | Yes  | Window ID.                            |
W
wusongqing 已提交
432
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the window found.|
W
wusongqing 已提交
433

W
wusongqing 已提交
434
**Example**
W
wusongqing 已提交
435

436 437 438 439 440 441 442 443
```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;
444
   console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
445 446
});
```
E
ester.zhou 已提交
447

W
wusongqing 已提交
448
## window.find<sup>7+</sup>
Z
zengyawen 已提交
449

W
wusongqing 已提交
450
find(id: string): Promise&lt;Window&gt;
Z
zengyawen 已提交
451

W
wusongqing 已提交
452
Finds a window based on the ID. This API uses a promise to return the result.
Z
zengyawen 已提交
453

W
wusongqing 已提交
454
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
455

W
wusongqing 已提交
456
**Parameters**
W
wusongqing 已提交
457

W
wusongqing 已提交
458 459 460
| Name| Type  | Mandatory| Description    |
| ------ | ------ | ---- | -------- |
| id     | string | Yes  | Window ID.|
W
wusongqing 已提交
461

W
wusongqing 已提交
462
**Return value**
W
wusongqing 已提交
463

464 465
| Type                            | Description                                 |
| -------------------------------- | ------------------------------------- |
W
wusongqing 已提交
466
| Promise&lt;[Window](#window)&gt; | Promise used to return the window found.|
W
wusongqing 已提交
467

W
wusongqing 已提交
468
**Example**
W
wusongqing 已提交
469

470 471 472 473 474
```js
var windowClass = null;
let promise = window.find("alertWindow");
promise.then((data)=> {
 	windowClass = data;
475
    console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
476 477 478 479
}).catch((err)=>{
    console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
});
```
Z
zengyawen 已提交
480

W
wusongqing 已提交
481
## window.getTopWindow
W
wusongqing 已提交
482 483 484 485 486

getTopWindow(callback: AsyncCallback&lt;Window&gt;): void

Obtains the top window of the current application. This API uses an asynchronous callback to return the result.

487
**Model restriction**: This API can be used only in the FA model.
W
wusongqing 已提交
488

W
wusongqing 已提交
489
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
490

W
wusongqing 已提交
491
**Parameters**
Z
zengyawen 已提交
492

493 494
| Name  | Type                                  | Mandatory| Description                                        |
| -------- | -------------------------------------- | ---- | -------------------------------------------- |
W
wusongqing 已提交
495
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the top window obtained.|
Z
zengyawen 已提交
496

W
wusongqing 已提交
497
**Example**
Z
zengyawen 已提交
498

499 500 501 502 503 504 505 506 507 508 509
```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));
});
```
W
wusongqing 已提交
510 511 512 513 514 515 516

## window.getTopWindow

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

Obtains the top window of the current application. This API uses a promise to return the result.

517
**Model restriction**: This API can be used only in the FA model.
W
wusongqing 已提交
518

W
wusongqing 已提交
519 520
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
521
**Return value**
W
wusongqing 已提交
522

523 524
| Type                            | Description                                           |
| -------------------------------- | ----------------------------------------------- |
W
wusongqing 已提交
525
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
W
wusongqing 已提交
526

W
wusongqing 已提交
527
**Example**
W
wusongqing 已提交
528

529 530 531 532 533 534 535 536 537 538
```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));
})
```
W
wusongqing 已提交
539 540 541 542 543 544 545 546 547

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

getTopWindow(ctx: Context, callback: AsyncCallback&lt;Window&gt;): void

Obtains the top window of the current application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
548
**Parameters**
W
wusongqing 已提交
549

W
wusongqing 已提交
550 551
| Name  | Type                                  | Mandatory| Description                                                        |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
552 553
| ctx      | Context                                | Yes  | Current application context.<br>For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).<br>For the definition of `Context` of API version 9, see [AbilityContext](js-apis-ability-context.md).|
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the top window obtained.                |
W
wusongqing 已提交
554

W
wusongqing 已提交
555
**Example**
W
wusongqing 已提交
556

557 558 559 560 561 562 563 564 565 566 567
```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));
});
```
W
wusongqing 已提交
568 569 570 571 572 573 574 575 576

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

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

Obtains the top window of the current application. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
577
**Parameters**
W
wusongqing 已提交
578

W
wusongqing 已提交
579 580
| Name| Type   | Mandatory| Description                                                        |
| ------ | ------- | ---- | ------------------------------------------------------------ |
581
| ctx    | Context | Yes  | Current application context.<br>For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).<br>For the definition of `Context` of API version 9, see [AbilityContext](js-apis-ability-context.md).|
W
wusongqing 已提交
582

W
wusongqing 已提交
583
**Return value**
W
wusongqing 已提交
584

585 586
| Type                            | Description                                           |
| -------------------------------- | ----------------------------------------------- |
W
wusongqing 已提交
587
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
W
wusongqing 已提交
588

W
wusongqing 已提交
589
**Example**
W
wusongqing 已提交
590

591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606
```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));
})
```

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

Minimizes all windows on a display. This API uses an asynchronous callback to return the result.

607
**System API**: This is a system API.
608 609 610 611 612 613 614

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                     | Mandatory| Description          |
| -------- | ------------------------- | ---- | -------------- |
615
| id       | number                    | Yes  | ID of the [display](js-apis-display.md#display).|
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.    |

**Example**

```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) {
            console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in minimizing all windows.');
    });
});
```

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

Minimizes all windows on a display. This API uses a promise to return the result.

645
**System API**: This is a system API.
646 647 648 649 650 651 652 653 654 655 656 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 682 683 684 685 686

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                     | Mandatory| Description          |
| -------- | ------------------------- | ---- | -------------- |
| id       | number                    | Yes  | ID of the [display](js-apis-display.md#display).|

**Return value**

| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|

**Example**

```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)=> {
        console.info('Succeeded in minimizing all windows.');
    }).catch((err)=>{
        console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
    })
});
```

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

Hides or restores the application's windows during quick multi-window switching. This API uses an asynchronous callback to return the result.

687
**System API**: This is a system API.
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                     | Mandatory| Description          |
| -------- | ------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.    |

**Example**

```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;

Hides or restores the application's windows during quick multi-window switching. This API uses a promise to return the result.

714
**System API**: This is a system API.
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Return value**

| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|

**Example**

```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

Sets the window layout mode. This API uses an asynchronous callback to return the result.

740
**System API**: This is a system API.
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                     | Mandatory| Description          |
| -------- | ------------------------- | ---- | -------------- |
| mode       | [WindowLayoutMode](#windowlayoutmode9)                  | Yes  | Window layout mode to set.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.    |

**Example**

```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;

Sets the window layout mode. This API uses a promise to return the result.

764
**System API**: This is a system API.
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                     | Mandatory| Description          |
| -------- | ------------------------- | ---- | -------------- |
| mode       | [WindowLayoutMode](#windowlayoutmode9)                    | Yes  | Window layout mode to set.|

**Return value**

| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|

**Example**

```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));
})
```
W
wusongqing 已提交
790 791 792 793 794

## on('systemBarTintChange')<sup>8+</sup>

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

W
wusongqing 已提交
795
Enables listening for properties changes of the status bar and navigation bar.
W
wusongqing 已提交
796

797
**System API**: This is a system API.
W
wusongqing 已提交
798 799 800

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
801
**Parameters**
W
wusongqing 已提交
802

W
wusongqing 已提交
803 804
| Name  | Type                                                     | Mandatory| Description                                                        |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
805 806
| type     | string                                                    | Yes  | Event type. The value is fixed at `systemBarTintChange`, indicating the property change event of the status bar and navigation bar.|
| callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | Yes  | Callback used to return the properties of the status bar and navigation bar.                |
W
wusongqing 已提交
807

W
wusongqing 已提交
808
**Example**
W
wusongqing 已提交
809

810 811 812 813 814
```js
window.on('systemBarTintChange', (data) => {
    console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
});
```
Z
zengyawen 已提交
815

W
wusongqing 已提交
816 817 818
## off('systemBarTintChange')<sup>8+</sup>

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

W
wusongqing 已提交
820
Disables listening for properties changes of the status bar and navigation bar.
Z
zengyawen 已提交
821

822
**System API**: This is a system API.
W
wusongqing 已提交
823 824

**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
825

W
wusongqing 已提交
826
**Parameters**
Z
zengyawen 已提交
827

W
wusongqing 已提交
828 829
| Name  | Type                                                     | Mandatory| Description                                                        |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
830 831
| type     | string                                                    | Yes  | Event type. The value is fixed at `systemBarTintChange`, indicating the property change event of the status bar and navigation bar.|
| callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | No  | Callback used to return the properties of the status bar and navigation bar.                |
Z
zengyawen 已提交
832

W
wusongqing 已提交
833
**Example**
Z
zengyawen 已提交
834

835 836 837
```js
window.off('systemBarTintChange');
```
W
wusongqing 已提交
838 839 840

## Window

841 842 843
Represents the current window instance, which is the basic unit managed by the window manager.

In the following API examples, you must use [getTopWindow()](#windowgettopwindow), [create()](#windowcreate7), or [find()](#windowfind7) to obtain a `Window` instance and then call a method in this instance.
W
wusongqing 已提交
844 845 846 847 848 849 850

### hide<sup>7+</sup>

hide (callback: AsyncCallback&lt;void&gt;): void

Hides this window. This API uses an asynchronous callback to return the result.

851
**System API**: This is a system API.
W
wusongqing 已提交
852 853 854

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
855
**Parameters**
W
wusongqing 已提交
856

W
wusongqing 已提交
857 858
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
859
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
W
wusongqing 已提交
860

W
wusongqing 已提交
861
**Example**
W
wusongqing 已提交
862

863 864 865 866 867 868
```js
windowClass.hide((err, data) => {
    if (err.code) {
        console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
        return;
    }
869
    console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data));
870 871
})
```
W
wusongqing 已提交
872 873 874 875 876 877 878

### hide<sup>7+</sup>

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

Hides this window. This API uses a promise to return the result.

879
**System API**: This is a system API.
W
wusongqing 已提交
880 881 882

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
883
**Return value**
W
wusongqing 已提交
884

885 886 887
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
888

W
wusongqing 已提交
889
**Example**
W
wusongqing 已提交
890

891 892 893
```js
let promise = windowClass.hide();
promise.then((data)=> {
894
    console.info('Succeeded in hiding the window. Data: ' + JSON.stringify(data));
895 896 897 898
}).catch((err)=>{
    console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
})
```
W
wusongqing 已提交
899

900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954
### hideWithAnimation<sup>9+</sup>

hideWithAnimation(callback: AsyncCallback&lt;void&gt;): void

Hides this window and plays an animation during the process. This API uses an asynchronous callback to return the result.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|

**Example**

```js
windowClass.hideWithAnimation((err, data) => {
    if (err.code) {
        console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in hiding the window with animation. data: ' + JSON.stringify(data));
})
```

### hideWithAnimation<sup>9+</sup>

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

Hides this window and plays an animation during the process. This API uses a promise to return the result.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Return value**

| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|

**Example**

```js
let promise = windowClass.hideWithAnimation();
promise.then((data)=> {
    console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
})
```

W
wusongqing 已提交
955 956 957 958 959 960 961 962
### show<sup>7+</sup>

show(callback: AsyncCallback&lt;void&gt;): void

Shows this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
963
**Parameters**
W
wusongqing 已提交
964

W
wusongqing 已提交
965 966
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
967
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
W
wusongqing 已提交
968

W
wusongqing 已提交
969
**Example**
W
wusongqing 已提交
970

971 972 973 974 975 976 977 978 979
```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));
})
```
W
wusongqing 已提交
980 981 982 983 984 985 986 987 988

### show<sup>7+</sup>

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

Shows this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
989
**Return value**
W
wusongqing 已提交
990

991 992 993
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
994

W
wusongqing 已提交
995
**Example**
W
wusongqing 已提交
996

997 998 999 1000 1001 1002 1003 1004
```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));
})
```
W
wusongqing 已提交
1005

1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060
### showWithAnimation<sup>9+</sup>

showWithAnimation(callback: AsyncCallback&lt;void&gt;): void

Shows this window and plays an animation during the process. This API uses an asynchronous callback to return the result.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|

**Example**

```js
windowClass.showWithAnimation((err, data) => {
    if (err.code) {
        console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
})
```

### showWithAnimation<sup>9+</sup>

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

Shows this window and plays an animation during the process. This API uses a promise to return the result.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Return value**

| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|

**Example**

```js
let promise = windowClass.showWithAnimation();
promise.then((data)=> {
    console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
})
```

W
wusongqing 已提交
1061 1062 1063 1064 1065 1066 1067 1068
### destroy<sup>7+</sup>

destroy(callback: AsyncCallback&lt;void&gt;): void

Destroys this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1069
**Parameters**
W
wusongqing 已提交
1070

W
wusongqing 已提交
1071 1072
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
1073
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1074

W
wusongqing 已提交
1075
**Example**
W
wusongqing 已提交
1076

1077 1078 1079 1080 1081 1082 1083 1084 1085
```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));
})
```
W
wusongqing 已提交
1086 1087 1088 1089 1090 1091 1092 1093 1094

### destroy<sup>7+</sup>

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

Destroys this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1095
**Return value**
W
wusongqing 已提交
1096

1097 1098 1099
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
1100

W
wusongqing 已提交
1101
**Example**
W
wusongqing 已提交
1102

1103 1104 1105 1106 1107 1108 1109 1110
```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));
})
```
W
wusongqing 已提交
1111 1112 1113 1114 1115

### moveTo<sup>7+</sup>

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

W
wusongqing 已提交
1116
Moves this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1117 1118 1119

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1120
**Parameters**
W
wusongqing 已提交
1121

W
wusongqing 已提交
1122 1123 1124 1125
| Name  | Type                     | Mandatory| Description                                             |
| -------- | ------------------------- | ---- | ------------------------------------------------- |
| x        | number                    | Yes  | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.|
| y        | number                    | Yes  | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.|
1126
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                       |
W
wusongqing 已提交
1127

W
wusongqing 已提交
1128
**Example**
W
wusongqing 已提交
1129

1130 1131 1132 1133 1134 1135
```js
windowClass.moveTo(300, 300, (err, data)=>{
    if (err.code) {
        console.error('Failed to move the window. Cause:' + JSON.stringify(err));
        return;
    }
1136
    console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data));
1137 1138 1139

});
```
W
wusongqing 已提交
1140 1141 1142 1143 1144

### moveTo<sup>7+</sup>

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

W
wusongqing 已提交
1145
Moves this window. This API uses a promise to return the result.
W
wusongqing 已提交
1146 1147 1148

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1149
**Parameters**
W
wusongqing 已提交
1150

W
wusongqing 已提交
1151 1152 1153 1154
| Name| Type  | Mandatory| Description                                             |
| ------ | ------ | ---- | ------------------------------------------------- |
| x      | number | Yes  | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.|
| y      | number | Yes  | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.|
W
wusongqing 已提交
1155

W
wusongqing 已提交
1156
**Return value**
W
wusongqing 已提交
1157

1158 1159 1160
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
1161

W
wusongqing 已提交
1162
**Example**
W
wusongqing 已提交
1163

1164 1165 1166
```js
let promise = windowClass.moveTo(300, 300);
promise.then((data)=> {
1167
    console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data));
1168 1169 1170 1171
}).catch((err)=>{
    console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
})
```
W
wusongqing 已提交
1172 1173 1174 1175 1176 1177 1178 1179 1180

### resetSize<sup>7+</sup>

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

Changes the size of this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1181
**Parameters**
W
wusongqing 已提交
1182

W
wusongqing 已提交
1183 1184 1185 1186
| Name  | Type                     | Mandatory| Description                      |
| -------- | ------------------------- | ---- | -------------------------- |
| width    | number                    | Yes  | New width of the window, in px.|
| height   | number                    | Yes  | New height of the window, in px.|
1187
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                |
W
wusongqing 已提交
1188

W
wusongqing 已提交
1189
**Example**
W
wusongqing 已提交
1190

1191 1192 1193 1194 1195 1196
```js
windowClass.resetSize(500, 1000, (err, data) => {
    if (err.code) {
        console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
        return;
    }
1197
    console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data));
1198 1199
});
```
W
wusongqing 已提交
1200 1201 1202 1203 1204 1205 1206 1207 1208

### resetSize<sup>7+</sup>

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

Changes the size of this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1209
**Parameters**
W
wusongqing 已提交
1210

W
wusongqing 已提交
1211 1212 1213 1214
| Name| Type  | Mandatory| Description                      |
| ------ | ------ | ---- | -------------------------- |
| width  | number | Yes  | New width of the window, in px.|
| height | number | Yes  | New height of the window, in px.|
W
wusongqing 已提交
1215

W
wusongqing 已提交
1216
**Return value**
W
wusongqing 已提交
1217

1218 1219 1220
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
1221

W
wusongqing 已提交
1222
**Example**
W
wusongqing 已提交
1223

1224 1225 1226
```js
let promise = windowClass.resetSize(500, 1000);
promise.then((data)=> {
1227
    console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data));
1228 1229 1230 1231
}).catch((err)=>{
    console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
1232

1233
### setWindowType<sup>(deprecated)</sup>
W
wusongqing 已提交
1234 1235 1236 1237 1238

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

Sets the type of this window. This API uses an asynchronous callback to return the result.

1239 1240 1241 1242 1243
**System API**: This is a system API.

> **NOTE**<br>This API is supported since API version 7 and deprecated since API version 9.
>
>  
W
wusongqing 已提交
1244 1245 1246

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1247
**Parameters**
W
wusongqing 已提交
1248

W
wusongqing 已提交
1249 1250 1251
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| type     | [WindowType](#windowtype) | Yes  | Window type.|
1252
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1253

W
wusongqing 已提交
1254
**Example**
W
wusongqing 已提交
1255

1256 1257 1258 1259 1260 1261 1262 1263 1264 1265
```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));
});
```
W
wusongqing 已提交
1266

1267
### setWindowType<sup>(deprecated)</sup>
W
wusongqing 已提交
1268 1269 1270 1271 1272

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

Sets the type of this window. This API uses a promise to return the result.

1273 1274 1275 1276 1277
**System API**: This is a system API.

> **NOTE**<br>This API is supported since API version 7 and deprecated since API version 9.
>
>  
W
wusongqing 已提交
1278 1279 1280

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1281
**Parameters**
W
wusongqing 已提交
1282

W
wusongqing 已提交
1283 1284 1285
| Name| Type                     | Mandatory| Description      |
| ------ | ------------------------- | ---- | ---------- |
| type   | [WindowType](#windowtype) | Yes  | Window type.|
W
wusongqing 已提交
1286

W
wusongqing 已提交
1287
**Return value**
W
wusongqing 已提交
1288

1289 1290 1291
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
1292

W
wusongqing 已提交
1293
**Example**
W
wusongqing 已提交
1294

1295 1296 1297 1298 1299 1300 1301 1302 1303
```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));
});
```
W
wusongqing 已提交
1304 1305 1306 1307 1308 1309 1310 1311 1312

### getProperties

getProperties(callback: AsyncCallback&lt;WindowProperties&gt;): void

Obtains the properties of this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1313
**Parameters**
W
wusongqing 已提交
1314

1315 1316
| Name  | Type                                                      | Mandatory| Description                        |
| -------- | ---------------------------------------------------------- | ---- | ---------------------------- |
W
wusongqing 已提交
1317
| callback | AsyncCallback&lt;[WindowProperties](#windowproperties)&gt; | Yes  | Callback used to return the window properties.|
W
wusongqing 已提交
1318

W
wusongqing 已提交
1319
**Example**
W
wusongqing 已提交
1320

1321 1322 1323 1324 1325 1326 1327 1328 1329
```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));
});
```
W
wusongqing 已提交
1330 1331 1332 1333 1334 1335 1336 1337 1338

### getProperties

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

Obtains the properties of this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1339
**Return value**
W
wusongqing 已提交
1340

1341 1342
| Type                                                | Description                           |
| ---------------------------------------------------- | ------------------------------- |
W
wusongqing 已提交
1343
| Promise&lt;[WindowProperties](#windowproperties)&gt; | Promise used to return the window properties.|
W
wusongqing 已提交
1344

W
wusongqing 已提交
1345
**Example**
W
wusongqing 已提交
1346

1347 1348 1349 1350 1351 1352 1353 1354
```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));
});
```
W
wusongqing 已提交
1355 1356 1357

### getAvoidArea<sup>7+</sup>

1358
getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt;): void
W
wusongqing 已提交
1359 1360 1361 1362 1363

Obtains the area where this window cannot be displayed, for example, the system bar area and notch. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1364
**Parameters**
W
wusongqing 已提交
1365

1366 1367
| Name  | Type                                           | Mandatory| Description                                                        |
| -------- |-----------------------------------------------| ---- | ------------------------------------------------------------ |
1368
| type     | [AvoidAreaType](#avoidareatype7)              | Yes  | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch. `TYPE_SYSTEM_GESTURE` indicates the gesture area. `TYPE_KEYBOARD` indicates the soft keyboard area.|
1369
| callback | AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt; | Yes  | Callback used to return the area.                            |
W
wusongqing 已提交
1370

W
wusongqing 已提交
1371
**Example**
W
wusongqing 已提交
1372

1373 1374 1375 1376 1377 1378 1379 1380 1381 1382
```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));
});
```
W
wusongqing 已提交
1383 1384 1385

### getAvoidArea<sup>7+</sup>

1386
getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise&lt;[AvoidArea](#avoidarea7)&gt;
W
wusongqing 已提交
1387 1388 1389 1390 1391

Obtains the area where this window cannot be displayed, for example, the system bar area and notch. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1392
**Parameters**
W
wusongqing 已提交
1393

1394 1395
| Name| Type                              | Mandatory| Description                                                        |
| ------ |----------------------------------| ---- | ------------------------------------------------------------ |
1396
| type   | [AvoidAreaType](#avoidareatype7) | Yes  | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch. `TYPE_SYSTEM_GESTURE` indicates the gesture area. `TYPE_KEYBOARD` indicates the soft keyboard area.|
W
wusongqing 已提交
1397

W
wusongqing 已提交
1398
**Return value**
W
wusongqing 已提交
1399

1400 1401 1402
| Type                                     | Description                               |
|-----------------------------------------| ----------------------------------- |
| Promise&lt;[AvoidArea](#avoidarea7)&gt; | Promise used to return the area.|
W
wusongqing 已提交
1403

W
wusongqing 已提交
1404
**Example**
W
wusongqing 已提交
1405

1406 1407 1408 1409 1410 1411 1412 1413
```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));
});
```
W
wusongqing 已提交
1414 1415 1416 1417 1418 1419 1420 1421 1422

### setFullScreen

setFullScreen(isFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void

Sets whether to enable the full-screen mode for this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1423
**Parameters**
W
wusongqing 已提交
1424

W
wusongqing 已提交
1425 1426 1427
| Name      | Type                     | Mandatory| Description                                          |
| ------------ | ------------------------- | ---- | ---------------------------------------------- |
| isFullScreen | boolean                   | Yes  | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.|
1428
| callback     | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                    |
W
wusongqing 已提交
1429

W
wusongqing 已提交
1430
**Example**
W
wusongqing 已提交
1431

1432 1433 1434 1435 1436 1437 1438 1439 1440 1441
```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));
});
```
W
wusongqing 已提交
1442 1443 1444 1445 1446 1447 1448 1449 1450

### setFullScreen

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

Sets whether to enable the full-screen mode for this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1451
**Parameters**
W
wusongqing 已提交
1452

W
wusongqing 已提交
1453 1454 1455
| Name      | Type   | Mandatory| Description                                          |
| ------------ | ------- | ---- | ---------------------------------------------- |
| isFullScreen | boolean | Yes  | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.|
W
wusongqing 已提交
1456

W
wusongqing 已提交
1457
**Return value**
W
wusongqing 已提交
1458

1459 1460 1461
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
1462

W
wusongqing 已提交
1463
**Example**
W
wusongqing 已提交
1464

1465 1466 1467 1468 1469 1470 1471 1472 1473
```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));
});
```
W
wusongqing 已提交
1474 1475 1476 1477 1478

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

setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void

W
wusongqing 已提交
1479
Sets whether to enable the full-screen mode for the window layout. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1480 1481 1482

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1483
**Parameters**
W
wusongqing 已提交
1484

W
wusongqing 已提交
1485 1486 1487
| Name            | Type                     | Mandatory| Description                                                        |
| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ |
| isLayoutFullScreen | boolean                   | Yes  | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.|
1488
| callback           | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                                  |
W
wusongqing 已提交
1489

W
wusongqing 已提交
1490
**Example**
W
wusongqing 已提交
1491

1492 1493 1494 1495 1496 1497 1498 1499 1500 1501
```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));
});
```
W
wusongqing 已提交
1502 1503 1504 1505 1506

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

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

W
wusongqing 已提交
1507
Sets whether to enable the full-screen mode for the window layout. This API uses a promise to return the result.
W
wusongqing 已提交
1508 1509 1510

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1511
**Parameters**
W
wusongqing 已提交
1512

W
wusongqing 已提交
1513 1514 1515
| Name            | Type   | Mandatory| Description                                                        |
| ------------------ | ------- | ---- | ------------------------------------------------------------ |
| isLayoutFullScreen | boolean | Yes  | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.|
W
wusongqing 已提交
1516

W
wusongqing 已提交
1517
**Return value**
W
wusongqing 已提交
1518

1519 1520 1521
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
1522

W
wusongqing 已提交
1523
**Example**
W
wusongqing 已提交
1524

1525 1526 1527 1528 1529 1530 1531 1532 1533
```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));
});
```
W
wusongqing 已提交
1534 1535 1536 1537 1538 1539 1540 1541 1542

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

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

Sets whether to display the status bar and navigation bar in this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1543
**Parameters**
W
wusongqing 已提交
1544

W
wusongqing 已提交
1545 1546
| Name  | Type                     | Mandatory| Description                                                        |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
1547 1548
| names    | Array                     | Yes  | Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to `["status", "navigation"]`. By default, they are not displayed.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                                  |
W
wusongqing 已提交
1549

W
wusongqing 已提交
1550
**Example**
W
wusongqing 已提交
1551

1552
```js
1553 1554
// In this example, the status bar and navigation bar are not displayed.
var names = [];
1555 1556
windowClass.setSystemBarEnable(names, (err, data) => {
    if (err.code) {
1557
        console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
1558 1559
        return;
    }
1560
    console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data));
1561 1562
});
```
W
wusongqing 已提交
1563 1564 1565 1566 1567 1568 1569 1570 1571

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

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

Sets whether to display the status bar and navigation bar in this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1572
**Parameters**
W
wusongqing 已提交
1573

W
wusongqing 已提交
1574 1575
| Name| Type | Mandatory| Description                                                        |
| ------ | ----- | ---- | ------------------------------------------------------------ |
1576
| names  | Array | Yes  | Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to `["status", "navigation"]`. By default, they are not displayed.|
W
wusongqing 已提交
1577

W
wusongqing 已提交
1578
**Return value**
W
wusongqing 已提交
1579

1580 1581 1582
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
1583

W
wusongqing 已提交
1584
**Example**
W
wusongqing 已提交
1585

1586
```js
1587 1588
// In this example, the status bar and navigation bar are not displayed.
var names = [];
1589 1590
let promise = windowClass.setSystemBarEnable(names);
promise.then((data)=> {
1591
    console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data));
1592
}).catch((err)=>{
1593
    console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
1594 1595
});
```
W
wusongqing 已提交
1596 1597 1598 1599 1600 1601 1602 1603 1604

### setSystemBarProperties

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

Sets the properties of the status bar and navigation bar in this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1605
**Parameters**
W
wusongqing 已提交
1606

1607 1608
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
W
wusongqing 已提交
1609
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632
| callback            | AsyncCallback&lt;void&gt;                   | Yes  | Callback used to return the result.            |

**Example**

```js
var SystemBarProperties={
    statusBarColor: '#ff00ff',
    navigationBarColor: '#00ff00',
    // The following properties are supported since API version 7.
    isStatusBarLightIcon: true,
    isNavigationBarLightIcon:false,
    // The following properties are supported since API version 8.
    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));
});
```
W
wusongqing 已提交
1633 1634 1635 1636 1637 1638 1639 1640 1641

### setSystemBarProperties

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

Sets the properties of the status bar and navigation bar in this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1642
**Parameters**
W
wusongqing 已提交
1643

1644 1645
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
W
wusongqing 已提交
1646
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
W
wusongqing 已提交
1647

W
wusongqing 已提交
1648
**Return value**
W
wusongqing 已提交
1649

1650 1651 1652
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
1653

1654
**Example**
W
wusongqing 已提交
1655

1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673
```js
var SystemBarProperties={
    statusBarColor: '#ff00ff',
    navigationBarColor: '#00ff00',
    // The following properties are supported since API version 7.
    isStatusBarLightIcon: true,
    isNavigationBarLightIcon:false,
    // The following properties are supported since API version 8.
    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));
});
```
W
wusongqing 已提交
1674

1675 1676 1677 1678 1679
### setPreferredOrientation<sup>9+</sup>

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

Sets the preferred orientation for this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1680 1681 1682

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1683
**Parameters**
W
wusongqing 已提交
1684

1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
| Orientation         | [Orientation](#orientation9)                | Yes  | Orientation to set.        |
| callback            | AsyncCallback&lt;void&gt;                   | Yes  | Callback used to return the result.            |

**Example**

```js
var orientation = window.Orientation.AUTO_ROTATION;
windowClass.setPreferredOrientation(orientation, (err, data) => {
    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));
});
```

### setPreferredOrientation<sup>9+</sup>

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

Sets the preferred orientation for this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
| Orientation         | [Orientation](#orientation9)                | Yes  | Orientation to set.      |

**Return value**

| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|

**Example**

```js
var orientation = window.Orientation.AUTO_ROTATION;
let promise = windowClass.setPreferredOrientation(orientation);
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));
});
```

### loadContent<sup>7+</sup>

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

Loads content from a page to this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                     | Mandatory| Description                |
| -------- | ------------------------- | ---- | -------------------- |
W
wusongqing 已提交
1747
| path     | string                    | Yes  | Path of the page from which the content will be loaded.|
1748
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |
G
ge-yafang 已提交
1749

W
wusongqing 已提交
1750
**Example**
W
wusongqing 已提交
1751

1752 1753 1754 1755 1756 1757 1758 1759 1760
```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));
});
```
W
wusongqing 已提交
1761 1762 1763 1764 1765

### loadContent<sup>7+</sup>

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

1766
Loads content from a page to this window. This API uses a promise to return the result.
W
wusongqing 已提交
1767 1768 1769

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1770
**Parameters**
W
wusongqing 已提交
1771

W
wusongqing 已提交
1772 1773 1774
| Name| Type  | Mandatory| Description                |
| ------ | ------ | ---- | -------------------- |
| path   | string | Yes  | Path of the page from which the content will be loaded.|
G
ge-yafang 已提交
1775

W
wusongqing 已提交
1776
**Return value**
W
wusongqing 已提交
1777

1778 1779 1780
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
1781

W
wusongqing 已提交
1782
**Example**
W
wusongqing 已提交
1783

1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797
```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

Loads content from a page associated with a local storage to this window. This API uses an asynchronous callback to return the result.

1798
**Model restriction**: This API can be used only in the stage model.
1799 1800 1801 1802 1803 1804 1805 1806

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                                           | Mandatory| Description                                                        |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path     | string                                          | Yes  | Path of the page from which the content will be loaded.                                        |
1807
| storage  | [LocalStorage](../../ui/ui-ts-local-storage.md) | Yes  | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
1808 1809 1810 1811 1812 1813
| callback | AsyncCallback&lt;void&gt;                       | Yes  | Callback used to return the result.                                                  |

**Example**

```ts
class myAbility extends Ability {
1814
    storage : LocalStorage
1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832
    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;
W
wusongqing 已提交
1833

1834 1835
Loads content from a page associated with a local storage to this window. This API uses a promise to return the result.

1836
**Model restriction**: This API can be used only in the stage model.
1837 1838 1839 1840 1841 1842 1843 1844

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name | Type                                           | Mandatory| Description                                                        |
| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path    | string                                          | Yes  | Path of the page from which the content will be loaded.                                        |
1845
| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | Yes  | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856

**Return value**

| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|

**Example**

```ts
class myAbility extends Ability {
1857
    storage : LocalStorage
1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872
    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));
        })
    }
}
```
W
wusongqing 已提交
1873 1874 1875 1876 1877 1878 1879 1880
### isShowing<sup>7+</sup>

isShowing(callback: AsyncCallback&lt;boolean&gt;): void

Checks whether this window is displayed. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1881
**Parameters**
W
wusongqing 已提交
1882

1883 1884 1885
| Name  | Type                        | Mandatory| Description                                                        |
| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. The value `true` means that this window is displayed, and `false` means the opposite.|
W
wusongqing 已提交
1886

W
wusongqing 已提交
1887
**Example**
W
wusongqing 已提交
1888

1889 1890 1891 1892 1893 1894 1895 1896 1897
```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));
});
```
W
wusongqing 已提交
1898 1899 1900 1901 1902 1903 1904 1905 1906

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

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

Checks whether this window is displayed. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1907
**Return value**
W
wusongqing 已提交
1908

1909 1910 1911
| Type                  | Description                                                        |
| ---------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return the result. The value `true` means that this window is displayed, and `false` means the opposite.|
W
wusongqing 已提交
1912

W
wusongqing 已提交
1913
**Example**
W
wusongqing 已提交
1914

1915 1916 1917 1918 1919 1920 1921 1922
```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));
});
```
W
wusongqing 已提交
1923 1924 1925 1926 1927 1928 1929 1930 1931

### on('windowSizeChange')<sup>7+</sup>

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

Enables listening for window size changes.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1932
**Parameters**
W
wusongqing 已提交
1933

1934 1935 1936 1937
| Name  | Type                          | Mandatory| Description                                                    |
| -------- | ------------------------------ | ---- | -------------------------------------------------------- |
| type     | string                         | Yes  | Event type. The value is fixed at `windowSizeChange`, indicating the window size change event.|
| callback | Callback&lt;[Size](#size7)&gt; | Yes  | Callback used to return the window size.                          |
W
wusongqing 已提交
1938

W
wusongqing 已提交
1939
**Example**
W
wusongqing 已提交
1940

1941 1942 1943 1944 1945
```js
windowClass.on('windowSizeChange', (data) => {
    console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1946 1947 1948 1949 1950 1951 1952 1953 1954

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

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

Disables listening for window size changes.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1955
**Parameters**
W
wusongqing 已提交
1956

W
wusongqing 已提交
1957 1958
| Name  | Type                         | Mandatory| Description                                                    |
| -------- | ----------------------------- | ---- | -------------------------------------------------------- |
1959 1960
| type     | string                        | Yes  | Event type. The value is fixed at `windowSizeChange`, indicating the window size change event.|
| callback | Callback&lt;[Size](#size)&gt; | No  | Callback used to return the window size.                          |
W
wusongqing 已提交
1961

W
wusongqing 已提交
1962
**Example**
W
wusongqing 已提交
1963

1964 1965 1966
```js
windowClass.off('windowSizeChange');
```
W
wusongqing 已提交
1967

1968
### on('systemAvoidAreaChange')<sup>(deprecated)</sup>
W
wusongqing 已提交
1969

1970
on(type: 'systemAvoidAreaChange', callback: Callback&lt;[AvoidArea](#avoidarea7)&gt;): void
W
wusongqing 已提交
1971 1972

Enables listening for changes to the area where the window cannot be displayed.
1973
> **NOTE**<br> This API is supported since API version 7 and deprecated since API version 9. Use [on('avoidAreaChange')](#onavoidareachange9) instead.
1974
>
1975
>  
W
wusongqing 已提交
1976 1977 1978

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1979
**Parameters**
W
wusongqing 已提交
1980

1981 1982 1983 1984
| Name  | Type                                      | Mandatory| Description                                                   |
| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
| type     | string                                   | Yes  | Event type. The value is fixed at `systemAvoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
| callback | Callback&lt;[AvoidArea](#avoidarea7)&gt; | Yes  | Callback used to return the area.                            |
W
wusongqing 已提交
1985

W
wusongqing 已提交
1986
**Example**
W
wusongqing 已提交
1987

1988 1989 1990 1991 1992
```js
windowClass.on('systemAvoidAreaChange', (data) => {
    console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1993

1994
### off('systemAvoidAreaChange')<sup>(deprecated)</sup>
W
wusongqing 已提交
1995

1996
off(type: 'systemAvoidAreaChange', callback?: Callback&lt;[AvoidArea](#avoidarea7)&gt;): void
W
wusongqing 已提交
1997 1998

Disables listening for changes to the area where the window cannot be displayed.
1999
> **NOTE**<br> This API is supported since API version 7 and deprecated since API version 9. Use [off('avoidAreaChange')](#offavoidareachange9) instead.
2000
>
2001
>  
W
wusongqing 已提交
2002 2003 2004

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2005
**Parameters**
W
wusongqing 已提交
2006

2007 2008 2009 2010
| Name  | Type                                      | Mandatory| Description                                                   |
| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
| type     | string                                   | Yes  | Event type. The value is fixed at `systemAvoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
| callback | Callback&lt;[AvoidArea](#avoidarea7)&gt; | No  | Callback used to return the area.                           |
W
wusongqing 已提交
2011

W
wusongqing 已提交
2012
**Example**
W
wusongqing 已提交
2013

2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036
```js
windowClass.off('systemAvoidAreaChange');
```


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

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

Enables listening for changes to the area where the window cannot be displayed.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                                                              | Mandatory| Description                                  |
| -------- |------------------------------------------------------------------| ---- |--------------------------------------|
| type     | string                                                           | Yes  | Event type. The value is fixed at `avoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
| callback | Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt; | Yes  | Callback used to return the area and area type.|

**Example**

```js
2037 2038
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));
2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061
});
```

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

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

Disables listening for changes to the area where the window cannot be displayed.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                                                                         | Mandatory | Description                                |
| -------- |-----------------------------------------------------------------------------|-----|------------------------------------|
| type     | string                                                                      | Yes  | Event type. The value is fixed at `avoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
| callback | Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt; | No  | Callback used to return the area and area type.|

**Example**

```js
windowClass.off('avoidAreaChange');
```
W
wusongqing 已提交
2062 2063 2064 2065 2066 2067 2068 2069 2070

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

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

Enables listening for keyboard height changes.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2071
**Parameters**
W
wusongqing 已提交
2072

2073 2074 2075 2076
| Name  | Type               | Mandatory| Description                                                        |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
| type     | string              | Yes  | Event type. The value is fixed at `keyboardHeightChange`, indicating the keyboard height change event.|
| callback | Callback<number&gt; | Yes  | Callback used to return the current keyboard height.                              |
W
wusongqing 已提交
2077

W
wusongqing 已提交
2078
**Example**
W
wusongqing 已提交
2079

2080 2081 2082 2083 2084
```js
windowClass.on('keyboardHeightChange', (data) => {
    console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
2085 2086 2087 2088 2089 2090 2091 2092 2093

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

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

Disables listening for keyboard height changes.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2094
**Parameters**
W
wusongqing 已提交
2095

W
wusongqing 已提交
2096 2097
| Name  | Type                  | Mandatory| Description                                                        |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111
| type     | string                 | Yes  | Event type. The value is fixed at `keyboardHeightChange`, indicating the keyboard height change event.|
| callback | Callback&lt;number&gt; | No  | Callback used to return the current keyboard height.                              |

**Example**

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

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

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

Enables listening for click events outside this window.
2112 2113

**System API**: This is a system API.
2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type               | Mandatory| Description                                                        |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
| type     | string              | Yes  | Event type. The value is fixed at `touchOutside`, indicating the click event outside this window.|
| callback | Callback<void&gt; | Yes  | Callback used to Callback used to return the click event outside this window.                              |

**Example**

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

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

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

Disables listening for click events outside this window.
2137 2138

**System API**: This is a system API.
2139 2140 2141 2142 2143 2144 2145 2146 2147

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                  | Mandatory| Description                                                        |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| type     | string                 | Yes  | Event type. The value is fixed at `touchOutside`, indicating the click event outside this window.|
| callback | Callback&lt;number&gt; | No  | Callback used to Callback used to return the click event outside this window.                              |
W
wusongqing 已提交
2148

W
wusongqing 已提交
2149
**Example**
W
wusongqing 已提交
2150

2151 2152 2153
```js
windowClass.off('touchOutside');
```
W
wusongqing 已提交
2154

2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357
### on('screenshot')<sup>9+</sup>

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

Subscribes to screenshot events.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type               | Mandatory| Description                                                        |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
| type     | string              | Yes  | Event type. The value is fixed at **'screenshot'**, indicating the screenshot event.|
| callback | Callback&lt;void&gt; | Yes  | Callback invoked when a screenshot event occurs.                              |

**Example**

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

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

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

Unsubscribes from screenshot events.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                  | Mandatory| Description                                                        |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| type     | string                 | Yes  | Event type. The value is fixed at **'screenshot'**, indicating the screenshot event.|
| callback | Callback&lt;void&gt; | No  | Callback invoked when a screenshot event occurs.|

**Example**

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

// If multiple callbacks are enabled in on(), they will all be disabled.
windowClass.off('screenshot');
```

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

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

Subscribes to click events of the target window in the modal window mode.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                | Mandatory| Description                                                         |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
| type     | string              | Yes  | Event type. The value is fixed at **'dialogTargetTouch'**, indicating the click event of the target window in the modal window mode.|
| callback | Callback&lt;void&gt;| Yes  | Callback invoked when the click event occurs in the target window of the modal window mode.|

**Example**

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

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

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

Unsubscribes from click events of the target window in the modal window mode.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                   | Mandatory| Description                                                         |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| type     | string                 | Yes  | Event type. The value is fixed at **'dialogTargetTouch'**, indicating the click event of the target window in the modal window mode.|
| callback | Callback&lt;void&gt;      | No  | Callback invoked when the click event occurs in the target window of the modal window mode.|

**Example**

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

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

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

Binds the modal window to the target window, and adds a callback to listen for modal window destruction events. This API uses an asynchronous callback to return the result.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name      | Type                     | Mandatory| Description                 |
| ----------- | ------------------------- | ---- | -------------------- |
| token       | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes  | Token of the target window.|
| deathCallback | Callback&lt;void&gt;        | Yes  | Callback used to listen for modal window destruction events.|
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|

**Example**

```js
class MyDeathRecipient {
    onRemoteDied() {
        console.log("server died");
    }
}
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;

Binds the modal window to the target window, and adds a callback to listen for modal window destruction events. This API uses a promise to return the result.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name      | Type                     | Mandatory| Description                 |
| ----------- | ------------------------- | ---- | -------------------- |
| token       | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes  | Token of the target window.|
| deathCallback | Callback&lt;void&gt;        | Yes  | Callback used to listen for modal window destruction events.|

**Return value**

| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|

**Example**

```js
class MyDeathRecipient {
    onRemoteDied() {
        console.log("server died");
    }
}
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));
});
```

W
wusongqing 已提交
2358 2359 2360 2361 2362 2363 2364 2365
### isSupportWideGamut<sup>8+</sup>

isSupportWideGamut(callback: AsyncCallback&lt;boolean&gt;): void

Checks whether this window supports the wide color gamut mode. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2366
**Parameters**
W
wusongqing 已提交
2367

2368 2369 2370
| Name  | Type                        | Mandatory| Description                                                        |
| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. The value `true` means that the wide color gamut mode is supported, and `false` means the opposite.|
W
wusongqing 已提交
2371

W
wusongqing 已提交
2372
**Example**
W
wusongqing 已提交
2373

2374 2375 2376 2377 2378 2379 2380 2381 2382
```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));
})
```
W
wusongqing 已提交
2383 2384 2385 2386 2387 2388 2389 2390 2391

### isSupportWideGamut<sup>8+</sup>

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

Checks whether this window supports the wide color gamut mode. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2392
**Return value**
W
wusongqing 已提交
2393

W
wusongqing 已提交
2394 2395
| Type                  | Description                                                        |
| ---------------------- | ------------------------------------------------------------ |
2396
| Promise&lt;boolean&gt; | Promise used to return the result. The value `true` means that the wide color gamut mode is supported, and `false` means the opposite.|
W
wusongqing 已提交
2397

W
wusongqing 已提交
2398
**Example**
W
wusongqing 已提交
2399

2400 2401 2402 2403 2404 2405 2406 2407
```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));
});
```
W
wusongqing 已提交
2408 2409 2410 2411 2412 2413 2414 2415 2416

### setColorSpace<sup>8+</sup>

setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback&lt;void&gt;): void

Sets this window to the wide or default color gamut mode. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2417
**Parameters**
W
wusongqing 已提交
2418

W
wusongqing 已提交
2419 2420 2421
| Name    | Type                     | Mandatory| Description        |
| ---------- | ------------------------- | ---- | ------------ |
| colorSpace | [ColorSpace](#colorspace) | Yes  | Color gamut mode.|
2422
| callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.  |
W
wusongqing 已提交
2423

W
wusongqing 已提交
2424
**Example**
W
wusongqing 已提交
2425

2426 2427 2428 2429 2430 2431 2432 2433 2434
```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));
})
```
W
wusongqing 已提交
2435 2436 2437 2438 2439 2440 2441 2442 2443

### setColorSpace<sup>8+</sup>

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

Sets this window to the wide or default color gamut mode. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2444
**Parameters**
W
wusongqing 已提交
2445

2446 2447
| Name    | Type                     | Mandatory| Description          |
| ---------- | ------------------------- | ---- | -------------- |
W
wusongqing 已提交
2448
| colorSpace | [ColorSpace](#colorspace) | Yes  | Color gamut mode.|
W
wusongqing 已提交
2449

W
wusongqing 已提交
2450
**Return value**
W
wusongqing 已提交
2451

2452 2453 2454
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
2455

W
wusongqing 已提交
2456
**Example**
W
wusongqing 已提交
2457

2458
```js
X
xpeng 已提交
2459
let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT);
2460 2461 2462 2463 2464 2465
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));
});
```
W
wusongqing 已提交
2466 2467 2468 2469 2470 2471 2472 2473 2474

### getColorSpace<sup>8+</sup>

getColorSpace(callback: AsyncCallback&lt;ColorSpace&gt;): void

Obtains the color gamut mode of this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2475
**Parameters**
W
wusongqing 已提交
2476

2477 2478 2479
| Name  | Type                                          | Mandatory| Description                                                      |
| -------- | ---------------------------------------------- | ---- | ---------------------------------------------------------- |
| callback | AsyncCallback&lt;[ColorSpace](#colorspace)&gt; | Yes  | Callback used to return the result. When the color gamut mode is obtained successfully, `err` is `undefined`, and `data` is the current color gamut mode.|
W
wusongqing 已提交
2480

W
wusongqing 已提交
2481
**Example**
W
wusongqing 已提交
2482

2483 2484 2485 2486 2487 2488 2489 2490 2491
```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));
})
```
W
wusongqing 已提交
2492 2493 2494 2495 2496 2497 2498 2499 2500

### getColorSpace<sup>8+</sup>

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

Obtains the color gamut mode of this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2501
**Return value**
W
wusongqing 已提交
2502

2503 2504 2505
| Type                                    | Description                           |
| ---------------------------------------- | ------------------------------- |
| Promise&lt;[ColorSpace](#colorspace)&gt; | Promise used to return the current color gamut mode.|
W
wusongqing 已提交
2506

W
wusongqing 已提交
2507
**Example**
W
wusongqing 已提交
2508

2509 2510 2511 2512 2513 2514 2515 2516
```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));
});
```
W
wusongqing 已提交
2517 2518 2519 2520 2521

### setBackgroundColor

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

2522
Sets the background color for this window. This API uses an asynchronous callback to return the result. In the stage model, this API must be used after [loadContent](#loadcontent9).
W
wusongqing 已提交
2523 2524 2525

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2526
**Parameters**
W
wusongqing 已提交
2527

W
wusongqing 已提交
2528 2529
| Name  | Type                     | Mandatory| Description                                                        |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
2530
| color    | string                    | Yes  | Background color to set. The value is a hexadecimal color and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
2531
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                                  |
W
wusongqing 已提交
2532

W
wusongqing 已提交
2533
**Example**
W
wusongqing 已提交
2534

2535 2536 2537 2538 2539 2540 2541 2542 2543 2544
```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));
});
```
W
wusongqing 已提交
2545 2546 2547 2548 2549

### setBackgroundColor

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

2550
Sets the background color for this window. This API uses a promise to return the result. In the stage model, this API must be used after [loadContent](#loadcontent9).
W
wusongqing 已提交
2551 2552 2553

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2554
**Parameters**
W
wusongqing 已提交
2555

W
wusongqing 已提交
2556 2557
| Name| Type  | Mandatory| Description                                                        |
| ------ | ------ | ---- | ------------------------------------------------------------ |
2558
| color  | string | Yes  | Background color to set. The value is a hexadecimal color and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
W
wusongqing 已提交
2559

W
wusongqing 已提交
2560
**Return value**
W
wusongqing 已提交
2561

2562 2563 2564
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
2565

W
wusongqing 已提交
2566
**Example**
W
wusongqing 已提交
2567

2568 2569 2570 2571 2572 2573 2574 2575 2576
```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));
});
```
W
wusongqing 已提交
2577

2578
### setWakeUpScreen()<sup>9+</sup>
W
wusongqing 已提交
2579

2580
setWakeUpScreen(wakeUp: boolean): void;
W
wusongqing 已提交
2581

2582 2583 2584
Wakes up the screen.

**System API**: This is a system API.
W
wusongqing 已提交
2585 2586 2587

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2588
**Parameters**
W
wusongqing 已提交
2589

2590 2591 2592
| Name          | Type   | Mandatory| Description                        |
| ---------------- | ------- | ---- | ---------------------------- |
| wakeUp           | boolean | Yes  | Whether to wake up the screen.|
W
wusongqing 已提交
2593

W
wusongqing 已提交
2594
**Example**
W
wusongqing 已提交
2595

2596
```js
2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620
var wakeUp = true;
windowClass.setWakeUpScreen(wakeUp);
```

### setBrightness

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

Sets the screen brightness for this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name    | Type                     | Mandatory| Description                                |
| ---------- | ------------------------- | ---- | ------------------------------------ |
| brightness | number                    | Yes  | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.|
| callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                          |

**Example**

```js
var brightness = 1;
windowClass.setBrightness(brightness, (err, data) => {
2621 2622 2623 2624 2625 2626 2627
    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));
});
```
W
wusongqing 已提交
2628 2629 2630 2631 2632 2633 2634 2635 2636

### setBrightness

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

Sets the screen brightness for this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2637
**Parameters**
W
wusongqing 已提交
2638

W
wusongqing 已提交
2639 2640
| Name    | Type  | Mandatory| Description                                |
| ---------- | ------ | ---- | ------------------------------------ |
2641
| brightness | number | Yes  | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.|
W
wusongqing 已提交
2642

W
wusongqing 已提交
2643
**Return value**
W
wusongqing 已提交
2644

2645 2646 2647
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
2648

W
wusongqing 已提交
2649
**Example**
W
wusongqing 已提交
2650

2651 2652 2653 2654 2655 2656 2657 2658 2659
```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));
});
```
W
wusongqing 已提交
2660

W
wusongqing 已提交
2661 2662 2663 2664 2665 2666
### setDimBehind<sup>(deprecated)</sup>

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

Sets the dimness of the window that is not on top. This API uses an asynchronous callback to return the result.

W
wusongqing 已提交
2667
> **NOTE**
2668 2669 2670 2671
>
> This API cannot be used.
>
> This API is supported since API version 7 and deprecated since API version 9.  
W
wusongqing 已提交
2672 2673 2674 2675 2676 2677 2678

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name        | Type                     | Mandatory| Description                                              |
| -------------- | ------------------------- | ---- | -------------------------------------------------- |
2679 2680
| dimBehindValue | number                    | Yes  | Dimness of the window to set. The value ranges from 0 to 1. The value `1` indicates the dimmest.|
| callback       | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                        |
W
wusongqing 已提交
2681 2682 2683

**Example**

2684 2685 2686 2687 2688 2689 2690 2691 2692
```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));
});
```
W
wusongqing 已提交
2693 2694 2695 2696 2697 2698 2699

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

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

Sets the dimness of the window that is not on top. This API uses a promise to return the result.

W
wusongqing 已提交
2700
> **NOTE**
2701 2702 2703 2704
>
> This API cannot be used.
>
> This API is supported since API version 7 and deprecated since API version 9.  
W
wusongqing 已提交
2705 2706 2707 2708 2709 2710 2711

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name        | Type  | Mandatory| Description                                              |
| -------------- | ------ | ---- | -------------------------------------------------- |
2712
| dimBehindValue | number | Yes  | Dimness of the window to set. The value ranges from 0 to 1. The value `1` indicates the dimmest.|
W
wusongqing 已提交
2713 2714 2715

**Return value**

2716 2717 2718
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
2719 2720 2721

**Example**

2722 2723 2724 2725 2726 2727 2728 2729
```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));
});
```
W
wusongqing 已提交
2730

W
wusongqing 已提交
2731 2732 2733 2734 2735 2736 2737 2738
### setFocusable<sup>7+</sup>

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

Sets whether this window can gain focus. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2739
**Parameters**
W
wusongqing 已提交
2740

W
wusongqing 已提交
2741 2742 2743
| Name     | Type                     | Mandatory| Description                        |
| ----------- | ------------------------- | ---- | ---------------------------- |
| isFocusable | boolean                   | Yes  | Whether the window can gain focus.|
2744
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                  |
W
wusongqing 已提交
2745

W
wusongqing 已提交
2746
**Example**
W
wusongqing 已提交
2747

2748 2749 2750 2751 2752 2753 2754 2755 2756 2757
```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));
});
```
W
wusongqing 已提交
2758 2759 2760 2761 2762 2763 2764 2765 2766

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

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

Sets whether this window can gain focus. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2767
**Parameters**
W
wusongqing 已提交
2768

W
wusongqing 已提交
2769 2770 2771
| Name     | Type   | Mandatory| Description                        |
| ----------- | ------- | ---- | ---------------------------- |
| isFocusable | boolean | Yes  | Whether the window can gain focus.|
W
wusongqing 已提交
2772

W
wusongqing 已提交
2773
**Return value**
W
wusongqing 已提交
2774

2775 2776 2777
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
2778

W
wusongqing 已提交
2779
**Example**
W
wusongqing 已提交
2780

2781 2782 2783 2784 2785 2786 2787 2788 2789
```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));
});
```
W
wusongqing 已提交
2790 2791 2792 2793 2794 2795 2796 2797 2798

### setKeepScreenOn

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

Sets whether to keep the screen always on. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2799
**Parameters**
W
wusongqing 已提交
2800

W
wusongqing 已提交
2801 2802 2803
| Name        | Type                     | Mandatory| Description                    |
| -------------- | ------------------------- | ---- | ------------------------ |
| isKeepScreenOn | boolean                   | Yes  | Whether to keep the screen always on.|
2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837
| callback       | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.              |

**Example**

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

### setKeepScreenOn

setKeepScreenOn(isKeepScreenOn: boolean): Promise&lt;void&gt;

Sets whether to keep the screen always on. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name        | Type   | Mandatory| Description                    |
| -------------- | ------- | ---- | ------------------------ |
| isKeepScreenOn | boolean | Yes  | Whether to keep the screen always on.|

**Return value**

| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
2838

W
wusongqing 已提交
2839
**Example**
W
wusongqing 已提交
2840

2841 2842 2843 2844 2845 2846
```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)=>{
2847
    console.info('Failed to set the screen to be always on. Cause:  ' + JSON.stringify(err));
2848 2849
});
```
W
wusongqing 已提交
2850

W
wusongqing 已提交
2851 2852 2853 2854 2855 2856
### setOutsideTouchable<sup>(deprecated)</sup>

setOutsideTouchable(touchable: boolean, callback: AsyncCallback&lt;void&gt;): void

Sets whether the area outside the subwindow is touchable. This API uses an asynchronous callback to return the result.

W
wusongqing 已提交
2857
> **NOTE**
2858 2859 2860 2861
>
> This API cannot be used.
>
> This API is supported since API version 7 and deprecated since API version 9.  
W
wusongqing 已提交
2862 2863 2864 2865 2866 2867 2868

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name   | Type                     | Mandatory| Description            |
| --------- | ------------------------- | ---- | ---------------- |
2869 2870
| touchable | boolean                   | Yes  | Whether the area outside the subwindow is touchable. The value `true` means that such an area is touchable, and `false` means the opposite.|
| callback  | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.      |
W
wusongqing 已提交
2871 2872 2873

**Example**

2874 2875 2876 2877 2878 2879 2880 2881 2882
```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));
})
```
W
wusongqing 已提交
2883 2884 2885 2886 2887 2888 2889

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

setOutsideTouchable(touchable: boolean): Promise&lt;void&gt;

Sets whether the area outside the subwindow is touchable. This API uses a promise to return the result.

W
wusongqing 已提交
2890
> **NOTE**
2891 2892 2893 2894
>
> This API cannot be used.
>
> This API is supported since API version 7 and deprecated since API version 9.  
W
wusongqing 已提交
2895 2896 2897 2898 2899 2900 2901

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name   | Type   | Mandatory| Description            |
| --------- | ------- | ---- | ---------------- |
2902
| touchable | boolean | Yes  | Whether the area outside the subwindow is touchable. The value `true` means that such an area is touchable, and `false` means the opposite.|
W
wusongqing 已提交
2903 2904 2905

**Return value**

2906 2907 2908
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
2909 2910 2911

**Example**

2912 2913 2914 2915 2916 2917 2918 2919
```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));
});
```
W
wusongqing 已提交
2920 2921 2922 2923 2924

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

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

2925
Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result. When in privacy mode, the window content cannot be captured or recorded.
W
wusongqing 已提交
2926 2927 2928

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2929
**Parameters**
W
wusongqing 已提交
2930

W
wusongqing 已提交
2931 2932 2933
| Name       | Type                     | Mandatory| Description                |
| ------------- | ------------------------- | ---- | -------------------- |
| isPrivacyMode | boolean                   | Yes  | Whether the window is in privacy mode.|
2934
| callback      | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |
W
wusongqing 已提交
2935

W
wusongqing 已提交
2936
**Example**
W
wusongqing 已提交
2937

2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948
```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));

});
```
W
wusongqing 已提交
2949 2950 2951 2952 2953

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

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

2954
Sets whether this window is in privacy mode. This API uses a promise to return the result. When in privacy mode, the window content cannot be captured or recorded.
W
wusongqing 已提交
2955 2956 2957

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2958
**Parameters**
W
wusongqing 已提交
2959

W
wusongqing 已提交
2960 2961 2962
| Name       | Type   | Mandatory| Description                |
| ------------- | ------- | ---- | -------------------- |
| isPrivacyMode | boolean | Yes  | Whether the window is in privacy mode.|
W
wusongqing 已提交
2963

W
wusongqing 已提交
2964
**Return value**
W
wusongqing 已提交
2965

2966 2967 2968
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
2969

W
wusongqing 已提交
2970
**Example**
W
wusongqing 已提交
2971

2972 2973 2974 2975 2976 2977 2978 2979 2980
```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));
});
```
W
wusongqing 已提交
2981

2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000
### setSnapshotSkip<sup>9+</sup>
setSnapshotSkip(isSkip: boolean): void

Sets whether to ignore this window during screen capturing or recording.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name       | Type   | Mandatory| Description                |
| ------------- | ------- | ---- | -------------------- |
| isSkip | boolean | Yes  | Whether to ignore the window. The default value is `false`.<br>The value `true` means that the window is ignored, and `false` means the opposite.<br>|
```js
var isSkip = true;
windowClass.setSnapshotSkip(isSkip);
```

W
wusongqing 已提交
3001 3002 3003 3004 3005 3006 3007 3008
### setTouchable<sup>7+</sup>

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

Sets whether this window is touchable. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
3009
**Parameters**
W
wusongqing 已提交
3010

W
wusongqing 已提交
3011 3012 3013
| Name     | Type                     | Mandatory| Description                |
| ----------- | ------------------------- | ---- | -------------------- |
| isTouchable | boolean                   | Yes  | Whether the window is touchable.|
3014
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |
W
wusongqing 已提交
3015

W
wusongqing 已提交
3016
**Example**
W
wusongqing 已提交
3017

3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028
```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));

});
```
W
wusongqing 已提交
3029 3030 3031 3032 3033 3034 3035 3036 3037

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

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

Sets whether this window is touchable. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
3038
**Parameters**
W
wusongqing 已提交
3039

W
wusongqing 已提交
3040 3041 3042
| Name     | Type   | Mandatory| Description                |
| ----------- | ------- | ---- | -------------------- |
| isTouchable | boolean | Yes  | Whether the window is touchable.|
W
wusongqing 已提交
3043

W
wusongqing 已提交
3044
**Return value**
W
wusongqing 已提交
3045

3046 3047 3048
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
3049

W
wusongqing 已提交
3050
**Example**
W
wusongqing 已提交
3051

3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067
```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));
});
```

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

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

Sets whether this window is forbidden to move in split-screen mode. This API uses an asynchronous callback to return the result.

3068
**System API**: This is a system API.
3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name     | Type                     | Mandatory| Description                |
| ----------- | ------------------------- | ---- | -------------------- |
| isForbidSplitMove | boolean                   | Yes  | Whether the window is forbidden to move in split-screen mode.|
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |

**Example**

```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;

Sets whether this window is forbidden to move in split-screen mode. This API uses a promise to return the result.

3099
**System API**: This is a system API.
3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name     | Type   | Mandatory| Description                |
| ----------- | ------- | ---- | -------------------- |
| isForbidSplitMove | boolean | Yes  | Whether the window is forbidden to move in split-screen mode.|

**Return value**

| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|

**Example**

```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));
});
```
W
wusongqing 已提交
3126

3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 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 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445
### snapshot<sup>9+</sup>

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

Captures this window. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name     | Type                     | Mandatory| Description                |
| ----------- | ------------------------- | ---- | -------------------- |
| callback    | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Yes  | Callback used to return the result. |

**Example**

```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(); // Release the memory in time after the PixelMap is used.
});
```

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

snapshot(): Promise&lt;image.PixelMap&gt;

Captures this window. This API uses a promise to return the result.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Return value**

| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Promise used to return the window screenshot.|

**Example**

```js
let promise = windowClass.snapshot();
promise.then((pixelMap)=> {
    console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
    pixelMap.release(); // Release the memory in time after the PixelMap is used.
}).catch((err)=>{
    console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
});
```

### setBlur<sup>9+</sup>

setBlur(radius: number): void

Blurs this window.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name| Type  | Mandatory| Description                                                        |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| radius | number | Yes  | Radius of the blur. The value is greater than or equal to 0. The value `0` means that the blur is disabled for the window.|

**Example**

```js
windowClass.setBlur(4.0);
```

### setBackdropBlur<sup>9+</sup>

setBackdropBlur(radius: number): void

Blurs the background of this window.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name| Type  | Mandatory| Description                                                        |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| radius | number | Yes  | Radius of the blur. The value is greater than or equal to 0. The value `0` means that the blur is disabled for the background of the window.|

**Example**

```js
windowClass.setBackdropBlur(4.0);
```

### setBackdropBlurStyle<sup>9+</sup>

setBackdropBlurStyle(blurStyle: BlurStyle): void

Sets the blur style for the background of this window.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name   | Type     | Mandatory| Description                  |
| --------- | --------- | ---- | ---------------------- |
| blurStyle | [BlurStyle](#blurstyle9) | Yes  | Blur style to set for the background of the window.|

**Example**

```js
windowClass.setBackdropBlurStyle(window.BlurType.THIN);
```

### setShadow<sup>9+</sup>

setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void

Sets the shadow for the window borders.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name | Type  | Mandatory| Description                                                        |
| ------- | ------ | ---- | ------------------------------------------------------------ |
| radius  | number | Yes  | Radius of the blur for the borders. The value is greater than or equal to 0. The value `0` means that the shadow is disabled for the window borders.|
| color   | string | No  | Color of the shadow. The value is a hexadecimal color and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
| offsetX | number | No  | Offset of the shadow along the x-axis, in pixels.                   |
| offsetY | number | No  | Offset of the shadow along the y-axis, in pixels.                   |

**Example**

```js
windowClass.setShadow(4.0, '#FF00FF00', 2, 3);
```

### setCornerRadius<sup>9+</sup>

setCornerRadius(cornerRadius: number): void

Sets the radius of the rounded corners for this window.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name     | Type   | Mandatory| Description                |
| ----------- | ------- | ---- | -------------------- |
| radius | number | Yes  | Radius of the rounded corners. The value is greater than or equal to 0. The value `0` means that the window does not use rounded corners.|

**Example**

```js
windowClass.setCornerRadius(4.0);
```

### opacity<sup>9+</sup>

opacity(opacity: number): void

Sets the opacity for this window.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name | Type  | Mandatory| Description                 |
| ------- | ------ | ---- | --------------------- |
| opacity | number | Yes  | Opacity to set. The value ranges from 0.0 to 1.0.|

**Example**

```js
windowClass.opacity(0.5);
```

### scale<sup>9+</sup>

scale(scaleOptions: ScaleOptions): void

Sets the scale parameters for this window.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name      | Type                          | Mandatory| Description      |
| ------------ | ------------------------------ | ---- | ---------- |
| scaleOptions | [ScaleOptions](#scaleoptions9) | Yes  | Scale parameters to set.|

**Example**

```js
var obj : window.ScaleOptions;
obj.x = 2.0;
obj.y = 1.0;
obj.pivotX = 0.5;
obj.pivotY = 0.5;
windowClass.scale(obj);
```

### rotate<sup>9+</sup>

rotate(rotateOptions: RotateOptions): void

Sets the rotation parameters for this window.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name       | Type                            | Mandatory| Description      |
| ------------- | -------------------------------- | ---- | ---------- |
| rotateOptions | [RotateOptions](#rotateoptions9) | Yes  | Rotation parameters to set.|

**Example**

```js
var obj : window.RotateOptions;
obj.x = 1.0;
obj.y = 1.0;
obj.z = 45.0;
obj.pivotX = 0.5;
obj.pivotY = 0.5;
windowClass.rotate(obj);
```

### translate<sup>9+</sup>

translate(translateOptions: TranslateOptions): void

Sets the translation parameters for this window.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name          | Type                                  | Mandatory| Description      |
| ---------------- | -------------------------------------- | ---- | ---------- |
| translateOptions | [TranslateOptions](#translateoptions9) | Yes  | Translation parameters to set.|

**Example**

```js
var obj : window.TranslateOptions;
obj.x = 100.0;
obj.y = 0.0;
obj.z = 0.0;
windowClass.translate(obj);
```

###  getTransitionController<sup>9+</sup>

 getTransitionController(): TransitionController

Obtains the transition animation controller.

**System API**: This is a system API.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Return value**

| Type                                          | Description            |
| ---------------------------------------------- | ---------------- |
| [TransitionController](#transitioncontroller9) | Transition animation controller.|

**Example**

```js
let controller = windowClass.getTransitionController(); // Obtain the transition animation controller.
controller.animationForHidden = (context : window.TransitionContext) => {
	let toWindow = context.toWindow
 	animateTo({
    	duration: 1000, // Animation duration.
        tempo: 0.5, // Playback speed.
        curve: Curve.EaseInOut, // Animation curve.
        delay: 0, // Animation delay.
        iterations: 1, // Number of playback times.
        playMode: PlayMode.Normal // Animation mode.
      }, () => {
		var obj : window.TranslateOptions;
		obj.x = 100.0;
		obj.y = 0.0;
		obj.z = 0.0;
        toWindow.translate(obj); // Set the transition animation.
        console.info('toWindow translate end');
      }
    )
    context.completeTransition(true)
    console.info('complete transition end');
}
windowClass.showWithAnimation((err, data) => {
    if (err.code) {
        console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
})
```

W
wusongqing 已提交
3446
## WindowStageEventType<sup>9+</sup>
W
wusongqing 已提交
3447 3448 3449

Describes the lifecycle of a window stage.

3450
**Model restriction**: This API can be used only in the stage model.
3451

W
wusongqing 已提交
3452 3453
**System capability**: SystemCapability.WindowManager.WindowManager.Core

3454 3455
| Name      | Default Value | Description      |
| ---------- | ------ | ---------- |
W
wusongqing 已提交
3456 3457 3458 3459
| FOREGROUND | 1      | The window stage is running in the foreground.|
| ACTIVE     | 2      | The window stage gains focus.|
| INACTIVE   | 3      | The window stage loses focus.|
| BACKGROUND | 4      | The window stage is running in the background.|
W
wusongqing 已提交
3460 3461 3462

## WindowStage<sup>9+</sup>

3463 3464 3465 3466 3467 3468 3469 3470 3471 3472
Implements a window manager, which manages each basic window unit, that is, [Window](#window) instance.

Before calling any of the following APIs, you must use `[onWindowStageCreate()](js-apis-application-ability.md#abilityonwindowstagecreate)` to create a `WindowStage` instance.

### getMainWindow<sup>9+</sup>

getMainWindow(callback: AsyncCallback&lt;Window&gt;): void

Obtains the main window of this window stage. This API uses an asynchronous callback to return the result.

3473
**Model restriction**: This API can be used only in the stage model.
3474 3475 3476 3477 3478 3479 3480 3481 3482 3483

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name  | Type                                  | Mandatory| Description                                         |
| -------- | -------------------------------------- | ---- | --------------------------------------------- |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the main window.|

**Example**
W
wusongqing 已提交
3484

3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501
```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));
        });
    }
}
```
W
wusongqing 已提交
3502 3503 3504 3505 3506 3507
### getMainWindow<sup>9+</sup>

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

Obtains the main window of this window stage. This API uses a promise to return the result.

3508
**Model restriction**: This API can be used only in the stage model.
3509

W
wusongqing 已提交
3510 3511
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
3512
**Return value**
W
wusongqing 已提交
3513

3514 3515
| Type                            | Description                                            |
| -------------------------------- | ------------------------------------------------ |
W
wusongqing 已提交
3516
| Promise&lt;[Window](#window)&gt; | Promise used to return the main window.|
W
wusongqing 已提交
3517

W
wusongqing 已提交
3518
**Example**
W
wusongqing 已提交
3519

3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536
```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>
W
wusongqing 已提交
3537

3538
createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void
W
wusongqing 已提交
3539

3540
Creates a subwindow for this window stage. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
3541

3542
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
3543 3544 3545

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
3546
**Parameters**
W
wusongqing 已提交
3547

3548 3549 3550 3551
| Name  | Type                                  | Mandatory| Description                                         |
| -------- | -------------------------------------- | ---- | --------------------------------------------- |
| name     | String                                 | Yes  | Name of the subwindow.                               |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the subwindow.|
W
wusongqing 已提交
3552

W
wusongqing 已提交
3553
**Example**
W
wusongqing 已提交
3554

3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572
```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) {
                console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
                return;
            }
            windowClass = data;
            console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
            windowClass.resetSize(500, 1000);
        });
    }
}
```
W
wusongqing 已提交
3573 3574 3575 3576 3577 3578
### createSubWindow<sup>9+</sup>

createSubWindow(name: string): Promise&lt;Window&gt;

Creates a subwindow for this window stage. This API uses a promise to return the result.

3579
**Model restriction**: This API can be used only in the stage model.
3580

W
wusongqing 已提交
3581
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
3582

W
wusongqing 已提交
3583
**Parameters**
W
wusongqing 已提交
3584

W
wusongqing 已提交
3585 3586 3587
| Name| Type  | Mandatory| Description          |
| ------ | ------ | ---- | -------------- |
| name   | String | Yes  | Name of the subwindow.|
G
ge-yafang 已提交
3588

W
wusongqing 已提交
3589
**Return value**
W
wusongqing 已提交
3590

3591 3592 3593
| Type                            | Description                                            |
| -------------------------------- | ------------------------------------------------ |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow.|
G
ge-yafang 已提交
3594

W
wusongqing 已提交
3595
**Example**
W
wusongqing 已提交
3596

3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613
```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;
            console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
        }).catch((err)=>{
            console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
        })
    }
}
```
### getSubWindow<sup>9+</sup>
W
wusongqing 已提交
3614

3615
getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void
W
wusongqing 已提交
3616

3617
Obtains all the subwindows of this window stage. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
3618

3619
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
3620 3621 3622

**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
3623
**Parameters**
W
wusongqing 已提交
3624

3625 3626 3627
| Name  | Type                                               | Mandatory| Description                                             |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[Window](#window)&gt;&gt; | Yes  | Callback used to return all the subwindows.|
W
wusongqing 已提交
3628

W
wusongqing 已提交
3629
**Example**
W
wusongqing 已提交
3630

3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647
```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) {
                console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
                return;
            }
            windowClass = data;
            console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
        });
    }
}
```
W
wusongqing 已提交
3648 3649 3650 3651 3652 3653
### getSubWindow<sup>9+</sup>

getSubWindow(): Promise&lt;Array&lt;Window&gt;&gt;

Obtains all the subwindows of this window stage. This API uses a promise to return the result.

3654
**Model restriction**: This API can be used only in the stage model.
3655

W
wusongqing 已提交
3656
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
3657

W
wusongqing 已提交
3658
**Return value**
W
wusongqing 已提交
3659

3660 3661
| Type                                         | Description                                                |
| --------------------------------------------- | ---------------------------------------------------- |
W
wusongqing 已提交
3662
| Promise&lt;Array&lt;[Window](#window)&gt;&gt; | Promise used to return all the subwindows.|
W
wusongqing 已提交
3663

W
wusongqing 已提交
3664
**Example**
W
wusongqing 已提交
3665

3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682
```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;
            console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
        }).catch((err)=>{
            console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
        })
    }
}
```
### loadContent<sup>9+</sup>
W
wusongqing 已提交
3683

3684
loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
3685

3686
Loads content from a page associated with a local storage to the main window in this window stage. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
3687

3688
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
3689 3690

**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
3691

W
wusongqing 已提交
3692
**Parameters**
W
wusongqing 已提交
3693

3694 3695 3696
| Name  | Type                                           | Mandatory| Description                                                        |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path     | string                                          | Yes  | Path of the page from which the content will be loaded.                                        |
3697
| storage  | [LocalStorage](../../ui/ui-ts-local-storage.md) | Yes  | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
3698
| callback | AsyncCallback&lt;void&gt;                       | Yes  | Callback used to return the result.                                                  |
W
wusongqing 已提交
3699

W
wusongqing 已提交
3700
**Example**
W
wusongqing 已提交
3701

3702 3703 3704
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
3705
    storage : LocalStorage
3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726
    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;

Loads content from a page associated with a local storage to the main window in this window stage. This API uses a promise to return the result.

3727
**Model restriction**: This API can be used only in the stage model.
3728 3729 3730 3731 3732 3733 3734 3735

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name | Type                                           | Mandatory| Description                                                        |
| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path    | string                                          | Yes  | Path of the page from which the content will be loaded.                                        |
3736
| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | No  | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748

**Return value**

| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|

**Example**

```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
3749
    storage : LocalStorage
3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764
    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));
        })
    }
}
```
W
wusongqing 已提交
3765 3766 3767 3768 3769

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

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

3770 3771
Loads content from a page to this window stage. This API uses an asynchronous callback to return the result.

3772
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
3773

3774
**System capability**: SystemCapability.WindowManager.WindowManager.Core
W
wusongqing 已提交
3775

W
wusongqing 已提交
3776
**Parameters**
W
wusongqing 已提交
3777

W
wusongqing 已提交
3778 3779 3780
| Name  | Type                     | Mandatory| Description                |
| -------- | ------------------------- | ---- | -------------------- |
| path     | string                    | Yes  | Path of the page from which the content will be loaded.|
3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |

**Example**

```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 已提交
3800

W
wusongqing 已提交
3801 3802 3803 3804 3805 3806
### on('windowStageEvent')<sup>9+</sup>

on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void

Enables listening for window stage lifecycle changes.

3807
**Model restriction**: This API can be used only in the stage model.
3808

W
wusongqing 已提交
3809
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
3810

W
wusongqing 已提交
3811
**Parameters**
W
wusongqing 已提交
3812

W
wusongqing 已提交
3813 3814
| Name  | Type                                                        | Mandatory| Description                                                        |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3815 3816
| type     | string                                                       | Yes  | Event type. The value is fixed at `windowStageEvent`, indicating the window stage lifecycle change event.|
| callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | Yes  | Callback used to return the window stage lifecycle state.               |
W
wusongqing 已提交
3817

W
wusongqing 已提交
3818
**Example**
W
wusongqing 已提交
3819

3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830
```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));
        });
    }
}
```
W
wusongqing 已提交
3831 3832 3833 3834 3835 3836 3837

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

off(eventType: 'windowStageEvent', callback?: Callback&lt;WindowStageEventType&gt;): void

Disables listening for window stage lifecycle changes.

3838
**Model restriction**: This API can be used only in the stage model.
3839

W
wusongqing 已提交
3840
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
3841

W
wusongqing 已提交
3842
**Parameters**
W
wusongqing 已提交
3843

W
wusongqing 已提交
3844 3845
| Name  | Type                                                        | Mandatory| Description                                                        |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3846 3847
| type     | string                                                       | Yes  | Event type. The value is fixed at `windowStageEvent`, indicating the window stage lifecycle change event.|
| callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | No  | Callback used to return the window stage lifecycle state.               |
G
ge-yafang 已提交
3848

W
wusongqing 已提交
3849
**Example**
W
wusongqing 已提交
3850

3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        windowStage.off('windowStageEvent');
    }
}
```

### disableWindowDecor()<sup>9+</sup>

disableWindowDecor(): void

Disables window decorators.
W
wusongqing 已提交
3866

3867
**Model restriction**: This API can be used only in the stage model.
3868

3869
**System API**: This is a system API.
3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Example**

```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('disableWindowDecor');
        windowStage.disableWindowDecor();
    }
}
```

### setShowOnLockScreen()<sup>9+</sup>
W
wusongqing 已提交
3886 3887 3888 3889 3890

setShowOnLockScreen(showOnLockScreen: boolean): void

Sets whether to display the window of the application on the lock screen.

3891 3892 3893
**System API**: This is a system API.

**Model restriction**: This API can be used only in the stage model.
3894

W
wusongqing 已提交
3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905
**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name          | Type   | Mandatory| Description                        |
| ---------------- | ------- | ---- | ---------------------------- |
| showOnLockScreen | boolean | Yes  | Whether to display the window on the lock screen.|

**Example**

```ts
3906
import Ability from '@ohos.application.Ability';
W
wusongqing 已提交
3907 3908 3909 3910 3911 3912 3913
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        windowStage.setShowOnLockScreen(true);
    }
}
```
3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055
## TransitionContext<sup>9+</sup>

Provides the context for the transition animation.

**System API**: This is a system API.

### toWindow<sup>9+</sup>

**System capability**: SystemCapability.WindowManager.WindowManager.Core

| Name    | Type         | Readable| Writable| Description            |
| -------- | ----------------- | ---- | ---- | ---------------- |
| toWindow | [Window](#window) | Yes  | Yes  | Target window to display the animation.|

### completeTransition<sup>9+</sup>

completeTransition(isCompleted: boolean): void

Completes the transition. This API must be called after [animateTo()](../arkui-ts/ts-explicit-animation.md) is executed.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name     | Type   | Mandatory| Description                                                        |
| ----------- | ------- | ---- | ------------------------------------------------------------ |
| isCompleted | boolean | Yes  | Whether the transition is complete. The value `true` means that the transition is complete, and `false` means the opposite.|

**Example**

```js
let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => {
	let toWindow = context.toWindow
 	animateTo({
    	duration: 1000, // Animation duration.
        tempo: 0.5, // Playback speed.
        curve: Curve.EaseInOut, // Animation curve.
        delay: 0, // Animation delay.
        iterations: 1, // Number of playback times.
        playMode: PlayMode.Normal // Animation mode.
      }, () => {
		var obj : window.TranslateOptions;
		obj.x = 100.0;
		obj.y = 0.0;
		obj.z = 0.0;
        toWindow.translate(obj);
        console.info('toWindow translate end');
      }
    )
    context.completeTransition(true)
    console.info('complete transition end');
}
```

## TransitionController<sup>9+</sup>

Implements the transition animation controller.

**System API**: This is a system API.

### animationForShown<sup>9+</sup>

animationForShown(context: TransitionContext): void

Customizes the animation when the window is shown.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name | Type                                    | Mandatory| Description                |
| ------- | ---------------------------------------- | ---- | -------------------- |
| context | [TransitionContext](#transitioncontext9) | Yes  | Context of the transition animation.|

**Example**

```js
let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => {
	let toWindow = context.toWindow
 	animateTo({
    	duration: 1000, // Animation duration.
        tempo: 0.5, // Playback speed.
        curve: Curve.EaseInOut, // Animation curve.
        delay: 0, // Animation delay.
        iterations: 1, // Number of playback times.
        playMode: PlayMode.Normal // Animation mode.
      }, () => {
		var obj : window.TranslateOptions;
		obj.x = 100.0;
		obj.y = 0.0;
		obj.z = 0.0;
        toWindow.translate(obj);
        console.info('toWindow translate end');
      }
    )
    context.completeTransition(true)
    console.info('complete transition end');
}
```

### animationForHidden<sup>9+</sup>

animationForHidden(context: TransitionContext): void

Customizes the animation when the window is hidden.

**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name | Type                                    | Mandatory| Description                |
| ------- | ---------------------------------------- | ---- | -------------------- |
| context | [TransitionContext](#transitioncontext9) | Yes  | Context of the transition animation.|

**Example**

```js
let controller = windowClass.getTransitionController();
controller.animationForHidden = (context : window.TransitionContext) => {
	let toWindow = context.toWindow
 	animateTo({
    	duration: 1000, // Animation duration.
        tempo: 0.5, // Playback speed.
        curve: Curve.EaseInOut, // Animation curve.
        delay: 0, // Animation delay.
        iterations: 1, // Number of playback times.
        playMode: PlayMode.Normal // Animation mode.
      }, () => {
		var obj : window.TranslateOptions;
		obj.x = 100.0;
		obj.y = 0.0;
		obj.z = 0.0;
        toWindow.translate(obj);
        console.info('toWindow translate end');
      }
    )
    context.completeTransition(true)
    console.info('complete transition end');
}
```