You need to sign in or sign up before continuing.
js-apis-window.md 269.8 KB
Newer Older
G
Gloria 已提交
1
# @ohos.window (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
| 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.|
G
Gloria 已提交
43
| TYPE_FLOAT_CAMERA<sup>9+</sup> | 15      | Floating camera window.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.|
44 45
| 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

47 48
## Configuration<sup>9+</sup>

G
Gloria 已提交
49
Defines the parameters for creating a subwindow or system window.
50 51 52 53 54

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

| Name| Type| Mandatory| Description|
| ---------- | -------------------------- | -- | ----------------------------------- |
G
Gloria 已提交
55 56
| name       | string                     | Yes| Name of the window.                        |
| windowType | [WindowType](#windowtype7) | Yes| Type of the window.                        |
G
Gloria 已提交
57
| ctx        | [BaseContext](js-apis-inner-application-baseContext.md) | No| Current application context. If this parameter is not set, no context is used.<br>You do not need to set this parameter to create a subwindow in the FA model<br>or a system window in the stage model.|
58 59 60
| displayId  | number                     | No| ID of the current physical screen. If this parameter is not set, the default value **-1** is used.|
| parentId   | number                     | No| ID of the parent window. If this parameter is not set, the default value **-1** is used.     |

W
wusongqing 已提交
61
## AvoidAreaType<sup>7+</sup>
W
wusongqing 已提交
62 63 64 65 66

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

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

67 68
| Name                            | Value  | Description                                                        |
| -------------------------------- | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
69
| TYPE_SYSTEM                      | 0    | Default area of the system. Generally, the status bar and navigation bar are included. The default area may vary according to the device in use.|
70 71 72
| TYPE_CUTOUT                      | 1    | Notch.                                            |
| TYPE_SYSTEM_GESTURE<sup>9+</sup> | 2    | Gesture area.                                              |
| TYPE_KEYBOARD<sup>9+</sup>       | 3    | Soft keyboard area.                                            |
W
wusongqing 已提交
73

W
wusongqing 已提交
74
## WindowMode<sup>7+</sup>
W
wusongqing 已提交
75

76 77
Enumerates the window modes.

78
**System API**: This is a system API.
79 80 81 82 83 84 85 86 87 88 89 90 91 92

**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 已提交
93

94
**System API**: This is a system API.
W
wusongqing 已提交
95 96 97

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

98 99 100 101
| Name      | Value  | Description                         |
| ---------- | ---- | ----------------------------- |
| WINDOW_LAYOUT_MODE_CASCADE  | 0    | Cascade mode.      |
| WINDOW_LAYOUT_MODE_TILE | 1    | Tile mode.            |
W
wusongqing 已提交
102

W
wusongqing 已提交
103
## SystemBarProperties
Z
zengyawen 已提交
104 105 106

Describes the properties of the status bar and navigation bar.

W
wusongqing 已提交
107 108
**System capability**: SystemCapability.WindowManager.WindowManager.Core

109 110
| Name                                  | Type|  Mandatory| Description                                                        |
| -------------------------------------- | -------- | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
111
| statusBarColor                         | string   |  No  | Background color of the status bar. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**. The default value is **#0x66000000**.|
112 113
| isStatusBarLightIcon<sup>7+</sup>      | boolean  |  No  | Whether any icon on the status bar is highlighted. The value **true** means that the icon is highlighted, and **false** means the opposite. The default value is **false**.|
| statusBarContentColor<sup>8+</sup>     | string   |  No  | Color of the text on the status bar. After this property is set, the setting of **isStatusBarLightIcon** is invalid. The default value is **0xE5FFFFFF**.|
G
Gloria 已提交
114
| navigationBarColor                     | string   |  No  | Background color of the navigation bar. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**. The default value is **#0x66000000**.|
115 116
| isNavigationBarLightIcon<sup>7+</sup>  | boolean  |  No  | Whether any icon on the navigation bar is highlighted. The value **true** means that the icon is highlighted, and **false** means the opposite. The default value is **false**.|
| navigationBarContentColor<sup>8+</sup> | string   |  No  | Color of the text on the navigation bar. After this property is set, the setting of **isNavigationBarLightIcon** is invalid. The default value is **0xE5FFFFFF**.|
W
wusongqing 已提交
117

118 119 120 121 122 123 124 125 126 127 128
## 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 已提交
129
| PORTRAIT_INVERTED                     | 3    | Reverse portrait.  |
130 131 132 133 134 135 136 137 138
| 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.|

139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
## 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 已提交
154
## SystemBarRegionTint<sup>8+</sup>
W
wusongqing 已提交
155 156 157

Describes the callback for a single system bar.

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

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

W
wusongqing 已提交
162 163
| Name           | Type                 | Readable| Writable| Description                                                        |
| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
164 165 166
| type            | [WindowType](#windowtype7) | Yes  | No  | Type of the system bar whose properties are changed. Only the status bar and navigation bar are supported.|
| isEnable        | boolean                   | Yes  | No  | Whether the system bar is displayed. The value **true** means that the system bar is displayed, and **false** means the opposite.|
| region          | [Rect](#rect7)             | Yes  | No  | Current position and size of the system bar.                                    |
G
Gloria 已提交
167
| backgroundColor | string                    | Yes  | No  | Background color of the system bar. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**.|
168
| contentColor    | string                    | Yes  | No  | Color of the text on the system bar.                                            |
W
wusongqing 已提交
169

W
wusongqing 已提交
170
## SystemBarTintState<sup>8+</sup>
W
wusongqing 已提交
171 172 173

Describes the callback for the current system bar.

174
**System API**: This is a system API.
W
wusongqing 已提交
175 176 177

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

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

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

W
wusongqing 已提交
185
Describes the rectangular area of the window.
Z
zengyawen 已提交
186

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

W
wusongqing 已提交
189 190
| Name  | Type| Readable| Writable| Description              |
| ------ | -------- | ---- | ---- | ------------------ |
191 192 193 194
| left   | number   | Yes  | Yes  | Left boundary of the rectangle, in pixels.|
| top    | number   | Yes  | Yes  | Top boundary of the rectangle, in pixels.|
| width  | number   | Yes  | Yes  | Width of the rectangle, in pixels.|
| height | number   | Yes  | Yes  | Height of the rectangle, in pixels.|
W
wusongqing 已提交
195

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

Describes the area where the window cannot be displayed.

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

W
wusongqing 已提交
202 203
| Name      | Type     | Readable| Writable| Description              |
| ---------- | ------------- | ---- | ---- | ------------------ |
204 205 206 207 208
| visible<sup>9+</sup>    | boolean       | Yes  | Yes  | Whether the window can be displayed in the area. The value **true** means that the window can be displayed in the area, and **false** means the opposite.|
| leftRect   | [Rect](#rect7) | Yes  | Yes  | Rectangle on the left of the screen.|
| topRect    | [Rect](#rect7) | Yes  | Yes  | Rectangle at the top of the screen.|
| rightRect  | [Rect](#rect7) | Yes  | Yes  | Rectangle on the right of the screen.|
| bottomRect | [Rect](#rect7) | Yes  | Yes  | Rectangle at the bottom of the screen.|
W
wusongqing 已提交
209

W
wusongqing 已提交
210
## Size<sup>7+</sup>
Z
zengyawen 已提交
211 212 213

Describes the window size.

W
wusongqing 已提交
214 215
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
216 217
| Name  | Type| Readable| Writable| Description      |
| ------ | -------- | ---- | ---- | ---------- |
218 219
| width  | number   | Yes  | Yes  | Window width, in pixels.|
| height | number   | Yes  | Yes  | Window height, in pixels.|
W
wusongqing 已提交
220

W
wusongqing 已提交
221
## WindowProperties
Z
zengyawen 已提交
222 223 224

Describes the window properties.

W
wusongqing 已提交
225
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
226

227 228
| Name                                 | Type                 | Readable| Writable| Description                                                        |
| ------------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
229 230 231 232 233 234 235 236 237 238 239 240 241
| windowRect<sup>7+</sup>               | [Rect](#rect7)             | Yes  | Yes  | Window size.                                                  |
| type<sup>7+</sup>                     | [WindowType](#windowtype7) | Yes  | Yes  | Window type.                                                  |
| isFullScreen                          | boolean                   | Yes  | Yes  | Whether the window is displayed in full screen mode. The default value is **false**. The value **true** means that the window is displayed in full screen mode, and **false** means the opposite.|
| 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**. The value **true** means that the window is immersive, and **false** means the opposite.|
| focusable<sup>7+</sup>                | boolean                   | Yes  | No  | Whether the window can gain focus. The default value is **true**. The value **true** means that the window can gain focus, and **false** means the opposite.|
| touchable<sup>7+</sup>                | boolean                   | Yes  | No  | Whether the window is touchable. The default value is **true**. The value **true** means that the window is touchable, and **false** means the opposite.|
| 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**. The value **true** means that the screen is always on, and **false** means the opposite.|
| isPrivacyMode<sup>7+</sup>            | boolean                   | Yes  | Yes  | Whether the window is in privacy mode. The default value is **false**. The value **true** means that the window is in privacy mode, and **false** means the opposite.|
| isRoundCorner<sup>(deprecated)</sup>  | boolean                   | Yes  | Yes  | Whether the window has rounded corners. The default value is **false**. The value **true** means that the window has rounded corners, and **false** means the opposite.<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**. The value **true** means that the window is transparent, and **false** means the opposite.|
| id<sup>9+</sup>                       | number                    | Yes  | No  | Window ID. The default value is **0.0**.                                                 |
W
wusongqing 已提交
242

W
wusongqing 已提交
243
## ColorSpace<sup>8+</sup>
W
wusongqing 已提交
244

245
Enumerates the color spaces.
W
wusongqing 已提交
246 247 248

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

249
| Name      | Value| Description          |
W
wusongqing 已提交
250
| ---------- | ------ | -------------- |
251
| DEFAULT    | 0      | Default SRGB gamut.|
252
| WIDE_GAMUT | 1      | Wide-gamut.  |
W
wusongqing 已提交
253

254 255 256 257 258 259 260 261 262 263
## 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                                              |
| ------ | -------- | ---- | ---- | -------------------------------------------------- |
264 265 266 267
| x      | number   | No  | Yes  | Scale factor along the x-axis. The default value is **1.0**.                      |
| y      | number   | No  | Yes  | Scale factor along 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**.|
268 269 270 271 272 273 274 275 276 277 278

## 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                                              |
| ------ | -------- | ---- | ---- | -------------------------------------------------- |
279 280 281 282 283
| 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**.|
284 285 286 287 288 289 290 291 292 293 294

## 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                        |
| ---- | -------- | ---- | ---- | ---------------------------- |
295 296 297
| 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**.|
298

299 300 301 302 303 304 305 306 307 308 309 310 311
## WindowEventType<sup>10+</sup>

Enumerates the window lifecycle states.

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

| Name      | Value| Description      |
| ---------- | ------ | ---------- |
| WINDOW_SHOWN      | 1      | The window is running in the foreground.|
| WINDOW_ACTIVE     | 2      | The window gains focus.|
| WINDOW_INACTIVE   | 3      | The window loses focus.|
| WINDOW_HIDDEN     | 4      | The window is running in the background.|

312
## window.createWindow<sup>9+</sup>
W
wusongqing 已提交
313

314
createWindow(config: Configuration, callback: AsyncCallback&lt;Window&gt;): void
W
wusongqing 已提交
315

G
Gloria 已提交
316
Creates a subwindow or system window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
317 318 319

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

W
wusongqing 已提交
320
**Parameters**
W
wusongqing 已提交
321

322 323
| Name| Type| Mandatory| Description|
| -------- | -------------------------------------- | -- | --------------------------------- |
G
Gloria 已提交
324 325
| config   | [Configuration](#configuration9)       | Yes| Parameters used for creating the window.  |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes| Callback used to return the window created.|
W
wusongqing 已提交
326

327
**Error codes**
W
wusongqing 已提交
328

329
For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
W
wusongqing 已提交
330

331 332
| ID| Error Message|
| ------- | -------------------------------- |
333
| 1300001 | Repeated operation. |
334
| 1300006 | This window context is abnormal. |
W
wusongqing 已提交
335

W
wusongqing 已提交
336
**Example**
W
wusongqing 已提交
337

338
```js
339
let windowClass = null;
340 341 342 343 344 345 346 347 348 349 350 351 352
let config = {name: "alertWindow", windowType: window.WindowType.TYPE_SYSTEM_ALERT, ctx: this.context};
try {
    window.createWindow(config, (err, data) => {
        if (err.code) {
            console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
            return;
        }
        windowClass = data;
        console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data));
        windowClass.resetSize(500, 1000);
    });
} catch (exception) {
    console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
353
}
354
```
Z
zengyawen 已提交
355

356
## window.createWindow<sup>9+</sup>
E
ester.zhou 已提交
357

358
createWindow(config: Configuration): Promise&lt;Window&gt;
E
ester.zhou 已提交
359

G
Gloria 已提交
360
Creates a subwindow or system window. This API uses a promise to return the result.
W
wusongqing 已提交
361 362

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

W
wusongqing 已提交
364
**Parameters**
E
ester.zhou 已提交
365

366 367
| Name| Type| Mandatory| Description|
| ------ | -------------------------------- | -- | ------------------ |
G
Gloria 已提交
368
| config | [Configuration](#configuration9) | Yes| Parameters used for creating the window.|
W
wusongqing 已提交
369

W
wusongqing 已提交
370
**Return value**
E
ester.zhou 已提交
371

372 373
| Type| Description|
| -------------------------------- | ------------------------------------ |
G
Gloria 已提交
374
| Promise&lt;[Window](#window)&gt; | Promise used to return the window created.|
E
ester.zhou 已提交
375

376
**Error codes**
W
wusongqing 已提交
377

378
For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
W
wusongqing 已提交
379

380 381
| ID| Error Message|
| ------- | -------------------------------- |
382
| 1300001 | Repeated operation. |
383
| 1300006 | This window context is abnormal. |
W
wusongqing 已提交
384

W
wusongqing 已提交
385
**Example**
W
wusongqing 已提交
386

387
```js
388
let windowClass = null;
389 390 391 392 393 394 395 396 397 398 399
let config = {name: "alertWindow", windowType: window.WindowType.TYPE_SYSTEM_ALERT, ctx: this.context};
try {
    let promise = window.createWindow(config);
    promise.then((data)=> {
        windowClass = data;
        console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
    }).catch((err)=>{
        console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
400
}
401
```
E
ester.zhou 已提交
402

403
## window.findWindow<sup>9+</sup>
Z
zengyawen 已提交
404

405
findWindow(name: string): Window
Z
zengyawen 已提交
406

G
Gloria 已提交
407
Finds a window based on the name.
Z
zengyawen 已提交
408

W
wusongqing 已提交
409
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
410

W
wusongqing 已提交
411
**Parameters**
W
wusongqing 已提交
412

W
wusongqing 已提交
413 414
| Name| Type  | Mandatory| Description    |
| ------ | ------ | ---- | -------- |
415
| name   | string | Yes  | Window ID.|
W
wusongqing 已提交
416

W
wusongqing 已提交
417
**Return value**
W
wusongqing 已提交
418

419 420 421
| Type| Description|
| ----------------- | ------------------- |
| [Window](#window) | Window found.|
W
wusongqing 已提交
422

W
wusongqing 已提交
423
**Example**
W
wusongqing 已提交
424

425
```js
426
let windowClass = null;
427
try {
428
    windowClass = window.findWindow('alertWindow');
429 430
} catch (exception) {
    console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception));
431
}
432
```
Z
zengyawen 已提交
433

434
## window.getLastWindow<sup>9+</sup>
W
wusongqing 已提交
435

436
getLastWindow(ctx: BaseContext, callback: AsyncCallback&lt;Window&gt;): void
W
wusongqing 已提交
437 438 439 440

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

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

W
wusongqing 已提交
442
**Parameters**
Z
zengyawen 已提交
443

444 445
| Name| Type| Mandatory| Description|
| -------- | -------------------------------------- | -- | ---------------------------------------- |
G
Gloria 已提交
446
| ctx      | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Current application context.|
447
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes| Callback used to return the top window obtained.|
W
wusongqing 已提交
448

449
**Error codes**
W
wusongqing 已提交
450

451
For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
W
wusongqing 已提交
452

453 454 455 456
| ID| Error Message|
| ------- | -------------------------------- |
| 1300002 | This window state is abnormal.   |
| 1300006 | This window context is abnormal. |
W
wusongqing 已提交
457

W
wusongqing 已提交
458
**Example**
W
wusongqing 已提交
459

460
```js
461
let windowClass = null;
462 463 464 465 466 467 468 469 470 471 472
try {
    window.getLastWindow(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));
    });
} catch (exception) {
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
473
}
474
```
W
wusongqing 已提交
475

476
## window.getLastWindow<sup>9+</sup>
W
wusongqing 已提交
477

478
getLastWindow(ctx: BaseContext): Promise&lt;Window&gt;
W
wusongqing 已提交
479 480 481 482 483

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 已提交
484
**Parameters**
W
wusongqing 已提交
485

486 487
| Name| Type| Mandatory| Description|
| ------ | ----------- | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
488
| ctx    | [BaseContext](js-apis-inner-application-baseContext.md) | Yes  | Current application context.|
W
wusongqing 已提交
489

W
wusongqing 已提交
490
**Return value**
W
wusongqing 已提交
491

492 493
| Type| Description|
| -------------------------------- | ------------------------------------------- |
W
wusongqing 已提交
494
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
W
wusongqing 已提交
495

496 497 498 499 500 501 502 503 504
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------- |
| 1300002 | This window state is abnormal.   |
| 1300006 | This window context is abnormal. |

W
wusongqing 已提交
505
**Example**
W
wusongqing 已提交
506

507
```js
508
let windowClass = null;
509 510 511 512 513 514 515 516 517 518
try {
    let promise = window.getLastWindow(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));
    });
} catch (exception) {
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
519
}
520 521 522 523 524 525 526
```

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

527
**System API**: This is a system API.
528 529 530 531 532 533 534

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

**Parameters**

| Name  | Type                     | Mandatory| Description          |
| -------- | ------------------------- | ---- | -------------- |
535
| id       | number                    | Yes  | ID of the [display](js-apis-display.md#display).|
536 537
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.    |

538 539 540 541 542 543 544 545
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300003 | This window manager service works abnormally. |

546 547 548 549 550
**Example**

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

551
let displayClass = null;
552 553 554
try {
    displayClass = display.getDefaultDisplaySync();

555 556 557 558 559 560 561 562 563 564 565
    try {
        window.minimizeAll(displayClass.id, (err) => {
            if(err.code) {
                console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
                return;
            }
            console.info('Succeeded in minimizing all windows.');
        });
    } catch (exception) {
        console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
    }
566
} catch (exception) {
567 568
    console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
569 570 571 572 573 574 575
```

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

576
**System API**: This is a system API.
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591

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

592 593 594 595 596 597 598 599
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300003 | This window manager service works abnormally. |

600 601 602 603 604
**Example**

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

605
let displayClass = null;
606 607 608
try {
    displayClass = display.getDefaultDisplaySync();

609 610 611 612 613 614 615 616 617 618
    try {
        let promise = window.minimizeAll(displayClass.id);
        promise.then(()=> {
            console.info('Succeeded in minimizing all windows.');
        }).catch((err)=>{
            console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
        });
    } catch (exception) {
        console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
    }
619
} catch (exception) {
620 621
    console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
622 623 624 625 626 627 628
```

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

629
**System API**: This is a system API.
630 631 632 633 634 635 636 637 638

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

**Parameters**

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

639 640 641 642 643 644 645 646
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300003 | This window manager service works abnormally. |

647 648 649
**Example**

```js
650
window.toggleShownStateForAllAppWindows((err) => {
651 652 653 654 655
    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.');
656
});
657 658 659 660 661 662 663
```

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

664
**System API**: This is a system API.
665 666 667 668 669 670 671 672 673

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

**Return value**

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

674 675 676 677 678 679 680 681
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300003 | This window manager service works abnormally. |

682 683 684 685
**Example**

```js
let promise = window.toggleShownStateForAllAppWindows();
686 687
promise.then(()=> {
    console.info('Succeeded in toggling shown state for all app windows.');
688 689
}).catch((err)=>{
    console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
690
});
691 692 693 694 695 696 697
```

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

698
**System API**: This is a system API.
699 700 701 702 703 704 705 706 707 708

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

709
**Error codes**
710

711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
try {
    window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (err) => {
        if(err.code) {
            console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in setting window layout mode.');
    });
} catch (exception) {
    console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
730
}
731 732 733 734 735 736 737
```

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

738
**System API**: This is a system API.
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753

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

754 755 756 757 758 759 760 761
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300003 | This window manager service works abnormally. |

762 763 764
**Example**

```js
765 766 767 768 769 770 771 772 773
try {
    let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE);
    promise.then(()=> {
        console.info('Succeeded in setting window layout mode.');
    }).catch((err)=>{
        console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
774
}
775
```
W
wusongqing 已提交
776

777
## window.on('systemBarTintChange')<sup>8+</sup>
W
wusongqing 已提交
778 779 780

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

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

783
**System API**: This is a system API.
W
wusongqing 已提交
784 785 786

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

W
wusongqing 已提交
787
**Parameters**
W
wusongqing 已提交
788

789 790 791 792
| Name  | Type                                                      | Mandatory| Description                                                        |
| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| 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](#systembartintstate8)&gt; | Yes  | Callback used to return the properties of the status bar and navigation bar.                |
W
wusongqing 已提交
793

W
wusongqing 已提交
794
**Example**
W
wusongqing 已提交
795

796
```js
797 798 799 800 801 802
try {
    window.on('systemBarTintChange', (data) => {
        console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
    });
} catch (exception) {
    console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
803
}
804
```
Z
zengyawen 已提交
805

806
## window.off('systemBarTintChange')<sup>8+</sup>
W
wusongqing 已提交
807 808

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

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

812
**System API**: This is a system API.
W
wusongqing 已提交
813 814

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

W
wusongqing 已提交
816
**Parameters**
Z
zengyawen 已提交
817

818 819 820 821
| Name  | Type                                                      | Mandatory| Description                                                        |
| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| 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](#systembartintstate8)&gt; | No  | Callback used to return the properties of the status bar and navigation bar.                |
Z
zengyawen 已提交
822

W
wusongqing 已提交
823
**Example**
Z
zengyawen 已提交
824

825
```js
826 827 828 829
try {
    window.off('systemBarTintChange');
} catch (exception) {
    console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
830
}
831
```
W
wusongqing 已提交
832

G
Gloria 已提交
833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 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 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974
## window.on('gestureNavigationEnabledChange')<sup>10+</sup>

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

Enables listening for gesture navigation status changes.

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

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

**Parameters**

| Name  | Type                    | Mandatory| Description                                                                         |
| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- |
| type     | string                  | Yes  | Event type. The value is fixed at **'gestureNavigationEnabledChange'**, indicating the gesture navigation status change event.   |
| callback | Callback&lt;boolean&gt; | Yes  | Callback used to return the gesture navigation status. The value **true** means that the gesture navigation status is changed to enabled, and **false** means that the gesture navigation status is changed to disabled.|

**Example**

```js
try {
    window.on('gestureNavigationEnabledChange', (data) => {
        console.info('Succeeded in enabling the listener for gesture navigation status changes. Data: ' + JSON.stringify(data));
    });
} catch (exception) {
    console.error('Failed to enable the listener for gesture navigation status changes. Cause: ' + JSON.stringify(exception));
}
```

## window.off('gestureNavigationEnabledChange')<sup>10+</sup>

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

Disables the listening for gesture navigation status changes.

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

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

**Parameters**

| Name  | Type                    | Mandatory| Description                                                       |
| -------- | ----------------------- | -- | ------------------------------------------------------------ |
| type     | string                  | Yes| Event type. The value is fixed at **'gestureNavigationEnabledChange'**, indicating the gesture navigation status change event.|
| callback | Callback&lt;boolean&gt; | No| Callback function that has been used for registering the listener. If this parameter is passed in, only the listener registered using this callback function is removed; otherwise, all gesture navigation status change listeners are removed.|

**Example**

```js
try {
    window.off('gestureNavigationEnabledChange');
} catch (exception) {
    console.error('Failed to disable the listener for gesture navigation status changes. Cause: ' + JSON.stringify(exception));
}
```

## window.setGestureNavigationEnabled<sup>10+</sup>
setGestureNavigationEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void

Enables or disables gesture navigation. 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          |
| -------- | ------------------------- | ---- | -------------- |
| enable   | boolean                  | Yes  | Whether to enable gesture navigation. The value **true** means to enable gesture navigation, and **false** means the opposite.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | --------------------------------------------- |
| 1300002 | This window state is abnormal.                |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
try {
    window.setGestureNavigationEnabled(true, (err) => {
        if(err.code) {
            console.error('Failed to set gesture navigation enabled. Cause: ' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in setting gesture navigation enabled.');
    });
} catch (exception) {
    console.error('Failed to set gesture navigation enabled. Cause: ' + JSON.stringify(exception));
}
```

## window.setGestureNavigationEnabled<sup>10+</sup>
setGestureNavigationEnabled(enable: boolean): Promise&lt;void&gt;

Enables or disables gesture navigation. 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                |
| ------ | ------- | ---- | -------------------- |
| enable | boolean | Yes  | Whether to enable gesture navigation. The value **true** means to enable gesture navigation, and **false** means the opposite.|

**Return value**

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.                |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
try {
    let promise = window.setGestureNavigationEnabled(true);
    promise.then(()=> {
        console.info('Succeeded in setting gesture navigation enabled.');
    }).catch((err)=>{
        console.error('Failed to set gesture navigation enabled. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set gesture navigation enabled. Cause: ' + JSON.stringify(exception));
}
```

975
## window.create<sup>(deprecated)</sup>
W
wusongqing 已提交
976

977
create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
W
wusongqing 已提交
978

979
Creates a subwindow. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
980

981
> **NOTE**
982
>
983
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createWindow()](#windowcreatewindow9) instead.
W
wusongqing 已提交
984

985
**Model restriction**: This API can be used only in the FA model.
W
wusongqing 已提交
986 987 988

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

W
wusongqing 已提交
989
**Parameters**
W
wusongqing 已提交
990

991 992 993 994 995
| Name  | Type                                  | Mandatory| Description                                |
| -------- | -------------------------------------- | ---- | ------------------------------------ |
| id       | string                                 | Yes  | Window ID.                            |
| type     | [WindowType](#windowtype7)              | Yes  | Window type.                          |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the subwindow created.|
W
wusongqing 已提交
996

W
wusongqing 已提交
997
**Example**
W
wusongqing 已提交
998

999
```js
1000 1001 1002 1003
let windowClass = null;
window.create('first', window.WindowType.TYPE_APP,(err,data) => {
    if(err.code){
        console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
1004 1005
        return;
    }
1006 1007 1008
    windowClass = data;
    console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
});
1009
```
W
wusongqing 已提交
1010

1011
## window.create<sup>(deprecated)</sup>
W
wusongqing 已提交
1012

1013
create(id: string, type: WindowType): Promise&lt;Window&gt;
W
wusongqing 已提交
1014

1015
Creates a subwindow. This API uses a promise to return the result.
W
wusongqing 已提交
1016

1017
> **NOTE**
1018
>
1019 1020 1021
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createWindow()](#windowcreatewindow9-1) instead.

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

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

1025 1026 1027 1028 1029 1030 1031
**Parameters**

| Name| Type                     | Mandatory| Description      |
| ------ | ------------------------- | ---- | ---------- |
| id     | string                    | Yes  | Window ID.  |
| type   | [WindowType](#windowtype7) | Yes  | Window type.|

W
wusongqing 已提交
1032
**Return value**
W
wusongqing 已提交
1033

1034 1035 1036
| Type                            | Description                                   |
| -------------------------------- | --------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
W
wusongqing 已提交
1037

W
wusongqing 已提交
1038
**Example**
W
wusongqing 已提交
1039

1040
```js
1041 1042
let windowClass = null;
let promise = window.create('first', window.WindowType.TYPE_APP);
1043
promise.then((data)=> {
1044 1045
    windowClass = data;
    console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
1046
}).catch((err)=>{
1047 1048
    console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
});
1049
```
W
wusongqing 已提交
1050

1051
## window.create<sup>(deprecated)</sup>
1052

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

G
Gloria 已提交
1055
Creates a system window. This API uses an asynchronous callback to return the result.
1056 1057

> **NOTE**
1058
>
1059
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createWindow()](#windowcreatewindow9) instead.
1060 1061 1062 1063 1064

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

**Parameters**

G
Gloria 已提交
1065 1066 1067 1068 1069 1070
| Name  | Type                                                   | Mandatory| Description                                |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------ |
| ctx      | [BaseContext](js-apis-inner-application-baseContext.md) | Yes  | Current application context.                |
| id       | string                                                  | Yes  | Window ID.                            |
| type     | [WindowType](#windowtype7)                              | Yes  | Window type.                          |
| callback | AsyncCallback&lt;[Window](#window)&gt;                  | Yes  | Callback used to return the subwindow created.|
1071 1072 1073 1074

**Example**

```js
1075 1076
let windowClass = null;
window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
1077
    if (err.code) {
1078
        console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
1079 1080
        return;
    }
1081 1082 1083 1084
    windowClass = data;
    console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data));
    windowClass.resetSize(500, 1000);
});
1085 1086
```

1087
## window.create<sup>(deprecated)</sup>
1088

1089
create(ctx: BaseContext, id: string, type: WindowType): Promise&lt;Window&gt;
1090

G
Gloria 已提交
1091
Creates a system window. This API uses a promise to return the result.
1092 1093

> **NOTE**
1094
>
1095
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createWindow()](#windowcreatewindow9-1) instead.
1096 1097 1098

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

1099 1100 1101 1102
**Parameters**

| Name| Type                     | Mandatory| Description                                                        |
| ------ | ------------------------- | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
1103
| ctx    | [BaseContext](js-apis-inner-application-baseContext.md) | Yes  | Current application context.|
1104 1105 1106
| id     | string                    | Yes  | Window ID.                                                    |
| type   | [WindowType](#windowtype7) | Yes  | Window type.                                                  |

1107 1108
**Return value**

1109 1110 1111
| Type                            | Description                                   |
| -------------------------------- | --------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
1112 1113 1114 1115

**Example**

```js
1116 1117
let windowClass = null;
let promise = window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT);
1118
promise.then((data)=> {
1119 1120
    windowClass = data;
    console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
1121
}).catch((err)=>{
1122 1123
    console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
});
1124 1125
```

1126
## window.find<sup>(deprecated)</sup>
W
wusongqing 已提交
1127

1128
find(id: string, callback: AsyncCallback&lt;Window&gt;): void
W
wusongqing 已提交
1129

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

> **NOTE**
1133
>
1134
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [findWindow()](#windowfindwindow9) instead.
W
wusongqing 已提交
1135 1136 1137

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

W
wusongqing 已提交
1138
**Parameters**
W
wusongqing 已提交
1139

1140 1141 1142 1143
| Name  | Type                                  | Mandatory| Description                                |
| -------- | -------------------------------------- | ---- | ------------------------------------ |
| id       | string                                 | Yes  | Window ID.                            |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the window found.|
W
wusongqing 已提交
1144

W
wusongqing 已提交
1145
**Example**
W
wusongqing 已提交
1146

1147
```js
1148 1149
let windowClass = null;
window.find('alertWindow', (err, data) => {
1150
    if (err.code) {
1151
        console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
1152 1153
        return;
    }
1154 1155 1156
    windowClass = data;
    console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
});
1157
```
W
wusongqing 已提交
1158

1159
## window.find<sup>(deprecated)</sup>
W
wusongqing 已提交
1160

1161
find(id: string): Promise&lt;Window&gt;
W
wusongqing 已提交
1162

1163 1164 1165
Finds a window based on the ID. This API uses a promise to return the result.

> **NOTE**
1166
>
1167
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [findWindow()](#windowfindwindow9) instead.
W
wusongqing 已提交
1168 1169 1170

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

1171 1172 1173 1174 1175 1176
**Parameters**

| Name| Type  | Mandatory| Description    |
| ------ | ------ | ---- | -------- |
| id     | string | Yes  | Window ID.|

W
wusongqing 已提交
1177
**Return value**
W
wusongqing 已提交
1178

1179 1180 1181
| Type                            | Description                                 |
| -------------------------------- | ------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the window found.|
W
wusongqing 已提交
1182

W
wusongqing 已提交
1183
**Example**
W
wusongqing 已提交
1184

1185
```js
1186 1187
let windowClass = null;
let promise = window.find('alertWindow');
1188
promise.then((data)=> {
1189 1190
    windowClass = data;
    console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
1191
}).catch((err)=>{
1192 1193
    console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
});
1194
```
W
wusongqing 已提交
1195

1196
## window.getTopWindow<sup>(deprecated)</sup>
1197

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

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

1202
> **NOTE**
1203
>
1204 1205 1206
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [getLastWindow()](#windowgetlastwindow9) instead.

**Model restriction**: This API can be used only in the FA model.
1207 1208 1209 1210 1211

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

**Parameters**

1212 1213 1214
| Name  | Type                                  | Mandatory| Description                                        |
| -------- | -------------------------------------- | ---- | -------------------------------------------- |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the top window obtained.|
1215 1216 1217 1218

**Example**

```js
1219 1220
let windowClass = null;
window.getTopWindow((err, data) => {
1221
    if (err.code) {
1222
        console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
1223 1224
        return;
    }
1225 1226 1227
    windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
});
1228 1229
```

1230
## window.getTopWindow<sup>(deprecated)</sup>
1231

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

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

1236
> **NOTE**
1237
>
1238 1239 1240
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [getLastWindow()](#windowgetlastwindow9-1) instead.

**Model restriction**: This API can be used only in the FA model.
1241 1242 1243 1244 1245

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

**Return value**

1246 1247 1248
| Type                            | Description                                           |
| -------------------------------- | ----------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
1249 1250 1251 1252

**Example**

```js
1253 1254
let windowClass = null;
let promise = window.getTopWindow();
1255
promise.then((data)=> {
1256 1257
    windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
1258
}).catch((err)=>{
1259
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
1260
});
1261 1262
```

1263
## window.getTopWindow<sup>(deprecated)</sup>
W
wusongqing 已提交
1264

1265
getTopWindow(ctx: BaseContext, callback: AsyncCallback&lt;Window&gt;): void
W
wusongqing 已提交
1266

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

> **NOTE**
1270
>
1271
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getLastWindow()](#windowgetlastwindow9) instead.
W
wusongqing 已提交
1272 1273 1274

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

W
wusongqing 已提交
1275
**Parameters**
W
wusongqing 已提交
1276

1277 1278
| Name  | Type                                  | Mandatory| Description                                                        |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
1279
| ctx      | [BaseContext](js-apis-inner-application-baseContext.md)                            | Yes  | Current application context.|
1280
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the top window obtained.                |
W
wusongqing 已提交
1281

W
wusongqing 已提交
1282
**Example**
W
wusongqing 已提交
1283

1284
```js
1285 1286
let windowClass = null;
window.getTopWindow(this.context, (err, data) => {
1287
    if (err.code) {
1288
        console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
1289 1290
        return;
    }
1291 1292 1293
    windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
});
1294
```
W
wusongqing 已提交
1295

1296
## window.getTopWindow<sup>(deprecated)</sup>
W
wusongqing 已提交
1297

1298
getTopWindow(ctx: BaseContext): Promise&lt;Window&gt;
W
wusongqing 已提交
1299

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

> **NOTE**
1303
>
1304
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getLastWindow()](#windowgetlastwindow9-1) instead.
W
wusongqing 已提交
1305 1306 1307

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

1308 1309 1310 1311
**Parameters**

| Name| Type   | Mandatory| Description                                                        |
| ------ | ----------- | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
1312
| ctx    | [BaseContext](js-apis-inner-application-baseContext.md) | Yes  | Current application context.|
1313

W
wusongqing 已提交
1314
**Return value**
W
wusongqing 已提交
1315

1316 1317 1318
| Type                            | Description                                           |
| -------------------------------- | ----------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
W
wusongqing 已提交
1319

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

1322
```js
1323 1324
let windowClass = null;
let promise = window.getTopWindow(this.context);
1325
promise.then((data)=> {
1326 1327
 	windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
1328
}).catch((err)=>{
1329
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
1330
});
1331
```
W
wusongqing 已提交
1332

1333
## Window
W
wusongqing 已提交
1334

1335
Represents the current window instance, which is the basic unit managed by the window manager.
W
wusongqing 已提交
1336

1337 1338 1339 1340 1341 1342 1343 1344 1345
In the following API examples, you must use [getLastWindow()](#windowgetlastwindow9), [createWindow()](#windowcreatewindow9), or [findWindow()](#windowfindwindow9) to obtain a **Window** instance and then call a method in this instance.

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

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

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

**System API**: This is a system API.
W
wusongqing 已提交
1346 1347 1348

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

W
wusongqing 已提交
1349
**Parameters**
W
wusongqing 已提交
1350

1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
W
wusongqing 已提交
1362

W
wusongqing 已提交
1363
**Example**
W
wusongqing 已提交
1364

1365
```js
1366
windowClass.hide((err) => {
1367
    if (err.code) {
1368
        console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
1369 1370
        return;
    }
1371 1372
    console.info('Succeeded in hiding the window.');
});
1373
```
W
wusongqing 已提交
1374

1375
### hide<sup>7+</sup>
W
wusongqing 已提交
1376

1377
hide(): Promise&lt;void&gt;
W
wusongqing 已提交
1378

1379
Hides this window. This API uses a promise to return the result.
W
wusongqing 已提交
1380

1381
**System API**: This is a system API.
W
wusongqing 已提交
1382

1383
**System capability**: SystemCapability.WindowManager.WindowManager.Core
W
wusongqing 已提交
1384

W
wusongqing 已提交
1385
**Return value**
W
wusongqing 已提交
1386

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

1391 1392 1393 1394 1395 1396 1397 1398
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

W
wusongqing 已提交
1399
**Example**
W
wusongqing 已提交
1400

1401
```js
1402 1403 1404
let promise = windowClass.hide();
promise.then(()=> {
    console.info('Succeeded in hiding the window.');
1405
}).catch((err)=>{
1406
    console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
1407
});
1408
```
W
wusongqing 已提交
1409

1410
### hideWithAnimation<sup>9+</sup>
W
wusongqing 已提交
1411

1412
hideWithAnimation(callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
1413

1414 1415 1416
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.
W
wusongqing 已提交
1417 1418 1419

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

W
wusongqing 已提交
1420
**Parameters**
W
wusongqing 已提交
1421

1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
| 1300004 | Unauthorized operation.                |
W
wusongqing 已提交
1435

W
wusongqing 已提交
1436
**Example**
W
wusongqing 已提交
1437

1438
```js
1439
windowClass.hideWithAnimation((err) => {
1440
    if (err.code) {
1441
        console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
1442 1443
        return;
    }
1444
    console.info('Succeeded in hiding the window with animation.');
1445
});
1446
```
W
wusongqing 已提交
1447

1448
### hideWithAnimation<sup>9+</sup>
W
wusongqing 已提交
1449

1450
hideWithAnimation(): Promise&lt;void&gt;
W
wusongqing 已提交
1451

1452
Hides this window and plays an animation during the process. This API uses a promise to return the result.
W
wusongqing 已提交
1453

1454
**System API**: This is a system API.
W
wusongqing 已提交
1455

1456
**System capability**: SystemCapability.WindowManager.WindowManager.Core
W
wusongqing 已提交
1457

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

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

1464 1465 1466 1467 1468 1469 1470 1471 1472 1473
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
| 1300004 | Unauthorized operation.                |

W
wusongqing 已提交
1474
**Example**
W
wusongqing 已提交
1475

1476
```js
1477 1478
let promise = windowClass.hideWithAnimation();
promise.then(()=> {
1479
    console.info('Succeeded in hiding the window with animation.');
1480
}).catch((err)=>{
1481
    console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
1482
});
1483
```
W
wusongqing 已提交
1484

1485
### showWindow<sup>9+</sup>
W
wusongqing 已提交
1486

1487
showWindow(callback: AsyncCallback&lt;void&gt;): void
1488

1489
Shows this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1490 1491 1492

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

W
wusongqing 已提交
1493
**Parameters**
W
wusongqing 已提交
1494

1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505
| Name| Type| Mandatory| Description|
| -------- | ------------------------- | -- | --------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
W
wusongqing 已提交
1506

W
wusongqing 已提交
1507
**Example**
W
wusongqing 已提交
1508

1509
```js
1510 1511 1512 1513 1514 1515
windowClass.showWindow((err) => {
    if (err.code) {
        console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in showing the window.');
1516 1517
});
```
W
wusongqing 已提交
1518

1519
### showWindow<sup>9+</sup>
W
wusongqing 已提交
1520

1521
showWindow(): Promise&lt;void&gt;
1522

1523
Shows this window. This API uses a promise to return the result.
W
wusongqing 已提交
1524 1525 1526

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

W
wusongqing 已提交
1527
**Return value**
W
wusongqing 已提交
1528

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

1533 1534 1535 1536 1537 1538 1539 1540
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

W
wusongqing 已提交
1541
**Example**
W
wusongqing 已提交
1542

1543
```js
1544 1545 1546
let promise = windowClass.showWindow();
promise.then(()=> {
    console.info('Succeeded in showing the window.');
1547
}).catch((err)=>{
1548
    console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
1549 1550
});
```
W
wusongqing 已提交
1551

1552
### showWithAnimation<sup>9+</sup>
W
wusongqing 已提交
1553

1554
showWithAnimation(callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
1555

1556 1557 1558
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.
W
wusongqing 已提交
1559 1560 1561

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

W
wusongqing 已提交
1562
**Parameters**
W
wusongqing 已提交
1563

1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
| 1300004 | Unauthorized operation.                |
W
wusongqing 已提交
1577

W
wusongqing 已提交
1578
**Example**
W
wusongqing 已提交
1579

1580
```js
1581
windowClass.showWithAnimation((err) => {
1582
    if (err.code) {
1583
        console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
1584 1585
        return;
    }
1586
    console.info('Succeeded in showing the window with animation.');
1587
});
1588
```
W
wusongqing 已提交
1589

1590 1591 1592
### showWithAnimation<sup>9+</sup>

showWithAnimation(): Promise&lt;void&gt;
W
wusongqing 已提交
1593

1594
Shows this window and plays an animation during the process. This API uses a promise to return the result.
W
wusongqing 已提交
1595

1596
**System API**: This is a system API.
W
wusongqing 已提交
1597 1598 1599

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

W
wusongqing 已提交
1600
**Return value**
W
wusongqing 已提交
1601

1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
| 1300004 | Unauthorized operation.                |
W
wusongqing 已提交
1615

W
wusongqing 已提交
1616
**Example**
W
wusongqing 已提交
1617

1618
```js
1619 1620 1621
let promise = windowClass.showWithAnimation();
promise.then(()=> {
    console.info('Succeeded in showing the window with animation.');
1622
}).catch((err)=>{
1623
    console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
1624
});
1625
```
W
wusongqing 已提交
1626

1627
### destroyWindow<sup>9+</sup>
W
wusongqing 已提交
1628

1629
destroyWindow(callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
1630

1631
Destroys this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1632 1633 1634

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

W
wusongqing 已提交
1635
**Parameters**
W
wusongqing 已提交
1636

1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648
| Name| Type| Mandatory| Description|
| -------- | ------------------------- | -- | --------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
W
wusongqing 已提交
1649

W
wusongqing 已提交
1650
**Example**
W
wusongqing 已提交
1651

1652
```js
1653
windowClass.destroyWindow((err) => {
1654
    if (err.code) {
1655
        console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
1656 1657
        return;
    }
1658
    console.info('Succeeded in destroying the window.');
1659
});
1660
```
W
wusongqing 已提交
1661

1662
### destroyWindow<sup>9+</sup>
W
wusongqing 已提交
1663

1664
destroyWindow(): Promise&lt;void&gt;
W
wusongqing 已提交
1665

1666
Destroys this window. This API uses a promise to return the result.
W
wusongqing 已提交
1667 1668 1669

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

1670 1671 1672 1673 1674
**Return value**

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

1676
**Error codes**
W
wusongqing 已提交
1677

1678
For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
W
wusongqing 已提交
1679

1680 1681 1682 1683
| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
W
wusongqing 已提交
1684

W
wusongqing 已提交
1685
**Example**
W
wusongqing 已提交
1686

1687
```js
1688 1689 1690
let promise = windowClass.destroyWindow();
promise.then(()=> {
    console.info('Succeeded in destroying the window.');
1691
}).catch((err)=>{
1692
    console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
1693
});
1694
```
W
wusongqing 已提交
1695

1696
### moveWindowTo<sup>9+</sup>
W
wusongqing 已提交
1697

1698
moveWindowTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
1699

1700
Moves this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1701

1702 1703
This operation is not supported in a window in full-screen mode.

W
wusongqing 已提交
1704 1705
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1706
**Parameters**
W
wusongqing 已提交
1707

1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721
| 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.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.                                    |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
W
wusongqing 已提交
1722

W
wusongqing 已提交
1723
**Example**
W
wusongqing 已提交
1724

1725
```js
1726 1727 1728 1729 1730 1731 1732 1733 1734 1735
try {
    windowClass.moveWindowTo(300, 300, (err)=>{
        if (err.code) {
            console.error('Failed to move the window. Cause:' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in moving the window.');
    });
} catch (exception) {
    console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
1736
}
1737
```
W
wusongqing 已提交
1738

1739
### moveWindowTo<sup>9+</sup>
W
wusongqing 已提交
1740

1741
moveWindowTo(x: number, y: number): Promise&lt;void&gt;
W
wusongqing 已提交
1742

1743
Moves this window. This API uses a promise to return the result.
W
wusongqing 已提交
1744

1745 1746
This operation is not supported in a window in full-screen mode.

W
wusongqing 已提交
1747 1748
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1749
**Parameters**
W
wusongqing 已提交
1750

1751 1752 1753 1754
| 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 已提交
1755

W
wusongqing 已提交
1756
**Return value**
W
wusongqing 已提交
1757

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

1762 1763 1764 1765 1766 1767 1768 1769 1770
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

W
wusongqing 已提交
1771
**Example**
W
wusongqing 已提交
1772

1773
```js
1774 1775 1776 1777 1778 1779 1780 1781 1782
try {
    let promise = windowClass.moveWindowTo(300, 300);
    promise.then(()=> {
        console.info('Succeeded in moving the window.');
    }).catch((err)=>{
        console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
1783
}
1784
```
W
wusongqing 已提交
1785

1786
### resize<sup>9+</sup>
W
wusongqing 已提交
1787

1788
resize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
1789

1790
Changes the size of this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1791

1792 1793 1794 1795 1796 1797
The main window and subwindow have the following size limits: [320, 2560] in width and [240, 2560] in height, both in units of vp.

The system window has the following size limits: [0, 2560] in width and [0, 2560] in height, both in units of vp.

The new width and height you set must meet the limits.

1798 1799
This operation is not supported in a window in full-screen mode.

W
wusongqing 已提交
1800 1801
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1802
**Parameters**
W
wusongqing 已提交
1803

1804 1805 1806 1807 1808
| Name| Type| Mandatory| Description|
| -------- | ------------------------- | -- | ------------------------ |
| width    | number                    | Yes| New width of the window, in px.|
| height   | number                    | Yes| New height of the window, in px.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.               |
W
wusongqing 已提交
1809

1810
**Error codes**
W
wusongqing 已提交
1811

1812
For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
W
wusongqing 已提交
1813

1814 1815 1816 1817
| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
W
wusongqing 已提交
1818

1819
**Example**
W
wusongqing 已提交
1820

1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831
```js
try {
    windowClass.resize(500, 1000, (err) => {
        if (err.code) {
            console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in changing the window size.');
    });
} catch (exception) {
    console.error('Failed to change the window size. Cause:' + JSON.stringify(exception));
1832
}
1833 1834 1835 1836 1837 1838 1839
```

### resize<sup>9+</sup>

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

Changes the size of this window. This API uses a promise to return the result.
W
wusongqing 已提交
1840

1841 1842 1843 1844 1845 1846
The main window and subwindow have the following size limits: [320, 2560] in width and [240, 2560] in height, both in units of vp.

The system window has the following size limits: [0, 2560] in width and [0, 2560] in height, both in units of vp.

The new width and height you set must meet the limits.

1847 1848
This operation is not supported in a window in full-screen mode.

W
wusongqing 已提交
1849 1850
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1851
**Parameters**
W
wusongqing 已提交
1852

1853 1854 1855 1856
| 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 已提交
1857

W
wusongqing 已提交
1858
**Return value**
W
wusongqing 已提交
1859

1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884
| Type| Description|
| ------------------- | ------------------------ |
| Promise&lt;void&gt; | Promise that returns no value.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
try {
    let promise = windowClass.resize(500, 1000);
    promise.then(()=> {
        console.info('Succeeded in changing the window size.');
    }).catch((err)=>{
        console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to change the window size. Cause: ' + JSON.stringify(exception));
1885
}
1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927
```

### setWindowMode<sup>9+</sup>

setWindowMode(mode: WindowMode, callback: AsyncCallback&lt;void&gt;): void

Sets the mode of this window. 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|
| -------- | -------------------------- | -- | --------- |
| mode     | [WindowMode](#windowmode7) | Yes| Window mode to set.|
| callback | AsyncCallback&lt;void&gt;  | Yes| Callback used to return the result.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
let mode = window.WindowMode.FULLSCREEN;
try {
    windowClass.setWindowMode(mode, (err) => {
    if (err.code) {
        console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the window mode.');
    });
} catch (exception) {
    console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
1928
}
1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966
```

### setWindowMode<sup>9+</sup>

setWindowMode(mode: WindowMode): Promise&lt;void&gt;

Sets the type of this window. 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|
| -------- | -------------------------- | -- | --------- |
| mode     | [WindowMode](#windowmode7) | Yes| Window mode to set.|

**Return value**

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
let mode = window.WindowMode.FULLSCREEN;
try {
1967
    let promise = windowClass.setWindowMode(mode);
1968 1969 1970 1971 1972 1973 1974
    promise.then(()=> {
        console.info('Succeeded in setting the window mode.');
    }).catch((err)=>{
        console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
1975
}
1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006
```

### getWindowProperties<sup>9+</sup>

getWindowProperties(): WindowProperties

Obtains the properties of this window.

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

**Return value**

| Type| Description|
| ------------------------------------- | ------------- |
| [WindowProperties](#windowproperties) | Window properties obtained.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

**Example**

```js
try {
    let properties = windowClass.getWindowProperties();
} catch (exception) {
    console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
2007
}
2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021
```

### getWindowAvoidArea<sup>9+</sup>

getWindowAvoidArea(type: AvoidAreaType): AvoidArea

Obtains the area where this window cannot be displayed, for example, the system bar area, notch, gesture area, and soft keyboard area.

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

**Parameters**

| Name| Type| Mandatory| Description|
| ---- |----------------------------------| -- | ------------------------------------------------------------ |
G
Gloria 已提交
2022
| type | [AvoidAreaType](#avoidareatype7) | Yes| Type of the area.|
2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045

**Return value**

| Type| Description|
|--------------------------| ----------------- |
| [AvoidArea](#avoidarea7) | Area where the window cannot be displayed.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

**Example**

```js
let type = window.AvoidAreaType.TYPE_SYSTEM;
try {
    let avoidArea = windowClass.getWindowAvoidArea(type);
} catch (exception) {
    console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception));
2046
}
2047 2048 2049 2050 2051 2052
```

### setWindowLayoutFullScreen<sup>9+</sup>

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

G
Gloria 已提交
2053 2054 2055
Sets whether the window layout is immersive. This API uses an asynchronous callback to return the result.
An immersive layout means that the layout does not avoid the status bar and navigation bar, and components may overlap with them.
A non-immersive layout means that the layout avoids the status bar and navigation bar, and components do not overlap with them.
2056 2057 2058 2059 2060 2061 2062

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

**Parameters**

| Name| Type| Mandatory| Description|
| ------------------ | ------------------------- | -- | --------- |
G
Gloria 已提交
2063
| isLayoutFullScreen | boolean                   | Yes| Whether the window layout is immersive. (The status bar and navigation bar of the immersive layout are still displayed.) The value **true** means that the window layout is immersive, and **false** means the opposite.|
2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088
| callback           | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
let isLayoutFullScreen= true;
try {
    windowClass.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => {
        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.');
    });
} catch (exception) {
    console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
2089
}
2090 2091 2092 2093 2094 2095
```

### setWindowLayoutFullScreen<sup>9+</sup>

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

G
Gloria 已提交
2096 2097 2098
Sets whether the window layout is immersive. This API uses a promise to return the result.
An immersive layout means that the layout does not avoid the status bar and navigation bar, and components may overlap with them.
A non-immersive layout means that the layout avoids the status bar and navigation bar, and components do not overlap with them.
2099 2100 2101 2102 2103 2104 2105

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

**Parameters**

| Name| Type| Mandatory| Description|
| ------------------ | ------- | -- | ------------------------------------------------------------------------------------------------ |
G
Gloria 已提交
2106
| isLayoutFullScreen | boolean | Yes| Whether the window layout is immersive. (The status bar and navigation bar of the immersive layout are still displayed.) The value **true** means that the window layout is immersive, and **false** means the opposite.|
2107 2108 2109 2110 2111

**Return value**

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

2114 2115 2116 2117 2118 2119 2120 2121 2122
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

W
wusongqing 已提交
2123
**Example**
W
wusongqing 已提交
2124

2125
```js
2126
let isLayoutFullScreen = true;
2127 2128 2129 2130 2131 2132 2133 2134 2135
try {
    let promise = windowClass.setWindowLayoutFullScreen(isLayoutFullScreen);
    promise.then(()=> {
        console.info('Succeeded in setting the window layout to full-screen mode.');
    }).catch((err)=>{
        console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
2136
}
2137
```
W
wusongqing 已提交
2138

2139
### setWindowSystemBarEnable<sup>9+</sup>
W
wusongqing 已提交
2140

2141
setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
2142 2143 2144 2145 2146

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 已提交
2147
**Parameters**
W
wusongqing 已提交
2148

2149
| Name| Type| Mandatory| Description|
2150
| -------- | ---------------------------- | -- | --------- |
G
Gloria 已提交
2151
| names    | Array<'status'\|'navigation'> | 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.|
2152 2153 2154 2155 2156 2157 2158 2159 2160 2161
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
W
wusongqing 已提交
2162

W
wusongqing 已提交
2163
**Example**
W
wusongqing 已提交
2164

2165
```js
2166
// In this example, the status bar and navigation bar are not displayed.
2167
let names = [];
2168 2169 2170 2171 2172 2173 2174 2175 2176 2177
try {
    windowClass.setWindowSystemBarEnable(names, (err) => {
        if (err.code) {
            console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in setting the system bar to be invisible.');
    });
} catch (exception) {
    console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
2178
}
2179
```
W
wusongqing 已提交
2180

2181
### setWindowSystemBarEnable<sup>9+</sup>
W
wusongqing 已提交
2182

2183
setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt;
W
wusongqing 已提交
2184 2185 2186 2187 2188

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 已提交
2189
**Parameters**
W
wusongqing 已提交
2190

2191
| Name| Type | Mandatory| Description|
2192 2193
| ----- | ---------------------------- | -- | --------------------------------- |
| names | Array<'status'\|'navigation'> | 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 已提交
2194

W
wusongqing 已提交
2195
**Return value**
W
wusongqing 已提交
2196

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

2201 2202 2203 2204 2205 2206 2207 2208 2209
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

W
wusongqing 已提交
2210
**Example**
W
wusongqing 已提交
2211

2212
```js
2213
// In this example, the status bar and navigation bar are not displayed.
2214
let names = [];
2215 2216 2217 2218 2219 2220 2221 2222 2223
try {
    let promise = windowClass.setWindowSystemBarEnable(names);
    promise.then(()=> {
        console.info('Succeeded in setting the system bar to be invisible.');
    }).catch((err)=>{
        console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
2224
}
2225
```
W
wusongqing 已提交
2226

2227
### setWindowSystemBarProperties<sup>9+</sup>
W
wusongqing 已提交
2228

2229
setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
2230 2231 2232 2233 2234

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 已提交
2235
**Parameters**
W
wusongqing 已提交
2236

2237 2238
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
W
wusongqing 已提交
2239
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
2240 2241
| callback            | AsyncCallback&lt;void&gt;                   | Yes  | Callback used to return the result.            |

2242 2243 2244 2245 2246 2247 2248 2249 2250
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

2251 2252 2253
**Example**

```js
2254
let SystemBarProperties = {
2255 2256 2257 2258 2259 2260
    statusBarColor: '#ff00ff',
    navigationBarColor: '#00ff00',
    // The following properties are supported since API version 8.
    statusBarContentColor:'#ffffff',
    navigationBarContentColor:'#00ffff'
};
2261 2262 2263 2264 2265 2266 2267 2268 2269 2270
try {
    windowClass.setWindowSystemBarProperties(SystemBarProperties, (err) => {
        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.');
    });
} catch (exception) {
    console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
2271
}
2272
```
W
wusongqing 已提交
2273

2274
### setWindowSystemBarProperties<sup>9+</sup>
W
wusongqing 已提交
2275

2276
setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise&lt;void&gt;
W
wusongqing 已提交
2277 2278 2279 2280 2281

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 已提交
2282
**Parameters**
W
wusongqing 已提交
2283

2284 2285
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
W
wusongqing 已提交
2286
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
W
wusongqing 已提交
2287

W
wusongqing 已提交
2288
**Return value**
W
wusongqing 已提交
2289

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

2294 2295 2296 2297 2298 2299 2300 2301 2302
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

2303
**Example**
W
wusongqing 已提交
2304

2305
```js
2306
let SystemBarProperties = {
2307 2308 2309 2310 2311 2312
    statusBarColor: '#ff00ff',
    navigationBarColor: '#00ff00',
    // The following properties are supported since API version 8.
    statusBarContentColor:'#ffffff',
    navigationBarContentColor:'#00ffff'
};
2313 2314 2315 2316 2317 2318 2319 2320 2321
try {
    let promise = windowClass.setWindowSystemBarProperties(SystemBarProperties);
    promise.then(()=> {
        console.info('Succeeded in setting the system bar properties.');
    }).catch((err)=>{
        console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
2322
}
2323
```
W
wusongqing 已提交
2324

2325 2326 2327 2328 2329
### 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 已提交
2330 2331 2332

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

W
wusongqing 已提交
2333
**Parameters**
W
wusongqing 已提交
2334

2335 2336 2337 2338 2339
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
| Orientation         | [Orientation](#orientation9)                | Yes  | Orientation to set.        |
| callback            | AsyncCallback&lt;void&gt;                   | Yes  | Callback used to return the result.            |

2340 2341 2342 2343 2344 2345 2346 2347
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

2348 2349 2350
**Example**

```js
2351
let orientation = window.Orientation.AUTO_ROTATION;
2352 2353 2354 2355 2356 2357 2358 2359 2360 2361
try {
    windowClass.setPreferredOrientation(orientation, (err) => {
        if (err.code) {
            console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in setting window orientation.');
    });
} catch (exception) {
    console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception));
2362
}
2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384
```

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

2385 2386 2387 2388 2389 2390 2391 2392
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

2393 2394 2395
**Example**

```js
2396
let orientation = window.Orientation.AUTO_ROTATION;
2397 2398 2399 2400 2401 2402 2403 2404 2405
try {
    let promise = windowClass.setPreferredOrientation(orientation);
    promise.then(()=> {
        console.info('Succeeded in setting the window orientation.');
    }).catch((err)=>{
        console.error('Failed to set the window orientation. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception));
2406
}
2407 2408
```

2409
### setUIContent<sup>9+</sup>
2410

2411
setUIContent(path: string, callback: AsyncCallback&lt;void&gt;): void
2412 2413 2414 2415 2416 2417 2418

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

2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431
| Name| Type| Mandatory| Description|
| -------- | ------------------------- | -- | -------------------- |
| path     | string                    | Yes| Path of the page from which the content will be loaded.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.         |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
G
ge-yafang 已提交
2432

W
wusongqing 已提交
2433
**Example**
W
wusongqing 已提交
2434

2435
```js
2436 2437 2438 2439 2440 2441 2442 2443 2444 2445
try {
    windowClass.setUIContent('pages/page2/page2', (err) => {
    if (err.code) {
            console.error('Failed to load the content. Cause:' + JSON.stringify(err));
            return;
    }
    console.info('Succeeded in loading the content.');
    });
} catch (exception) {
    console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
2446
}
2447
```
W
wusongqing 已提交
2448

2449
### setUIContent<sup>9+</sup>
W
wusongqing 已提交
2450

2451
setUIContent(path: string): Promise&lt;void&gt;
W
wusongqing 已提交
2452

2453
Loads content from a page to this window. This API uses a promise to return the result.
W
wusongqing 已提交
2454 2455 2456

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

W
wusongqing 已提交
2457
**Parameters**
W
wusongqing 已提交
2458

2459 2460 2461
| Name| Type| Mandatory| Description|
| ---- | ------ | -- | ------------------ |
| path | string | Yes| Path of the page from which the content will be loaded.|
G
ge-yafang 已提交
2462

W
wusongqing 已提交
2463
**Return value**
W
wusongqing 已提交
2464

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

2469 2470 2471 2472 2473 2474 2475 2476 2477
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

W
wusongqing 已提交
2478
**Example**
W
wusongqing 已提交
2479

2480
```js
2481 2482 2483 2484 2485 2486 2487 2488 2489
try {
    let promise = windowClass.setUIContent('pages/page2/page2');
    promise.then(()=> {
        console.info('Succeeded in loading the content.');
    }).catch((err)=>{
        console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to load the content. Cause: ' + JSON.stringify(exception));
2490
}
2491
```
2492

2493 2494 2495 2496 2497 2498
### 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.

2499
**Model restriction**: This API can be used only in the stage model.
2500 2501 2502 2503 2504 2505 2506 2507

**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.                                        |
G
Gloria 已提交
2508
| storage  | [LocalStorage](../../quick-start/arkts-localstorage.md) | Yes  | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
2509 2510
| callback | AsyncCallback&lt;void&gt;                       | Yes  | Callback used to return the result.                                                  |

2511 2512 2513 2514 2515 2516 2517 2518 2519
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

2520 2521 2522
**Example**

```ts
2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535
let storage = new LocalStorage();
storage.setOrCreate('storageSimpleProp',121);
console.log('onWindowStageCreate');
try {
    windowClass.loadContent('pages/page2', storage, (err) => {
        if (err.code) {
            console.error('Failed to load the content. Cause:' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in loading the content.');
    });
} catch (exception) {
    console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
2536
}
2537 2538 2539 2540 2541
```

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

loadContent(path: string, storage: LocalStorage): Promise&lt;void&gt;
W
wusongqing 已提交
2542

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

2545
**Model restriction**: This API can be used only in the stage model.
2546 2547 2548 2549 2550 2551 2552 2553

**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.                                        |
G
Gloria 已提交
2554
| storage | [LocalStorage](../../quick-start/arkts-localstorage.md) | Yes  | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
2555 2556 2557 2558 2559 2560 2561

**Return value**

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

2562
**Error codes**
W
wusongqing 已提交
2563

2564
For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
W
wusongqing 已提交
2565

2566 2567 2568 2569
| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
W
wusongqing 已提交
2570

W
wusongqing 已提交
2571
**Example**
W
wusongqing 已提交
2572

2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585
```ts
let storage = new LocalStorage();
storage.setOrCreate('storageSimpleProp',121);
console.log('onWindowStageCreate');
try {
    let promise = windowClass.loadContent('pages/page2', storage);
    promise.then(() => {
        console.info('Succeeded in loading the content.');
    }).catch((err) => {
        console.error('Failed to load the content. Cause:' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
2586
}
2587
```
W
wusongqing 已提交
2588

2589
### isWindowShowing<sup>9+</sup>
W
wusongqing 已提交
2590

2591
isWindowShowing(): boolean
W
wusongqing 已提交
2592

2593
Checks whether this window is displayed.
W
wusongqing 已提交
2594 2595 2596

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

W
wusongqing 已提交
2597
**Return value**
W
wusongqing 已提交
2598

2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609
| Type| Description|
| ------- | ------------------------------------------------------------------ |
| boolean | Whether the window is displayed. The value **true** means that the window is displayed, and **false** means the opposite.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
W
wusongqing 已提交
2610

W
wusongqing 已提交
2611
**Example**
W
wusongqing 已提交
2612

2613
```js
2614 2615
try {
    let data = windowClass.isWindowShowing();
2616
    console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
2617 2618
} catch (exception) {
    console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception));
2619
}
2620
```
W
wusongqing 已提交
2621 2622 2623 2624 2625 2626 2627 2628 2629

### 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 已提交
2630
**Parameters**
W
wusongqing 已提交
2631

2632 2633
| Name  | Type                          | Mandatory| Description                                                    |
| -------- | ------------------------------ | ---- | -------------------------------------------------------- |
2634
| type     | string                         | Yes  | Event type. The value is fixed at **'windowSizeChange'**, indicating the window size change event.|
2635
| callback | Callback&lt;[Size](#size7)&gt; | Yes  | Callback used to return the window size.                          |
W
wusongqing 已提交
2636

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

2639
```js
2640 2641 2642 2643 2644 2645
try {
    windowClass.on('windowSizeChange', (data) => {
        console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data));
    });
} catch (exception) {
    console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception));
2646
}
2647
```
W
wusongqing 已提交
2648 2649 2650

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

2651
off(type: 'windowSizeChange', callback?: Callback&lt;Size&gt;): void
W
wusongqing 已提交
2652 2653 2654 2655 2656

Disables listening for window size changes.

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

W
wusongqing 已提交
2657
**Parameters**
W
wusongqing 已提交
2658

W
wusongqing 已提交
2659 2660
| Name  | Type                         | Mandatory| Description                                                    |
| -------- | ----------------------------- | ---- | -------------------------------------------------------- |
2661
| type     | string                        | Yes  | Event type. The value is fixed at **'windowSizeChange'**, indicating the window size change event.|
G
ge-yafang 已提交
2662
| callback | Callback&lt;[Size](#size7)&gt; | No  | Callback used to return the window size.                          |
W
wusongqing 已提交
2663

W
wusongqing 已提交
2664
**Example**
W
wusongqing 已提交
2665

2666
```js
2667 2668 2669 2670
try {
    windowClass.off('windowSizeChange');
} catch (exception) {
    console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception));
2671
}
2672 2673 2674 2675
```

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

2676
on(type: 'avoidAreaChange', callback: Callback&lt;{AvoidAreaType, AvoidArea}&gt;): void
2677 2678 2679 2680 2681 2682 2683 2684 2685

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

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

**Parameters**

| Name  | Type                                                              | Mandatory| Description                                  |
| -------- |------------------------------------------------------------------| ---- |--------------------------------------|
2686
| 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.|
2687 2688 2689 2690 2691
| callback | Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt; | Yes  | Callback used to return the area and area type.|

**Example**

```js
2692 2693 2694 2695 2696 2697 2698
try {
    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));
    });
} catch (exception) {
    console.error('Failed to enable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
2699
}
2700 2701 2702 2703
```

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

2704
off(type: 'avoidAreaChange', callback: Callback&lt;{AvoidAreaType, AvoidArea}&gt;): void
2705 2706 2707 2708 2709 2710 2711 2712 2713

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

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

**Parameters**

| Name  | Type                                                                         | Mandatory | Description                                |
| -------- |-----------------------------------------------------------------------------|-----|------------------------------------|
2714
| 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.|
2715 2716 2717 2718 2719
| callback | Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt; | No  | Callback used to return the area and area type.|

**Example**

```js
2720 2721 2722 2723
try {
    windowClass.off('avoidAreaChange');
} catch (exception) {
    console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
2724
}
2725
```
W
wusongqing 已提交
2726 2727 2728 2729 2730 2731 2732 2733 2734

### 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 已提交
2735
**Parameters**
W
wusongqing 已提交
2736

2737 2738
| Name  | Type               | Mandatory| Description                                                        |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
2739 2740
| type     | string              | Yes  | Event type. The value is fixed at **'keyboardHeightChange'**, indicating the keyboard height change event.|
| callback | Callback&lt;number&gt; | Yes  | Callback used to return the current keyboard height.                              |
W
wusongqing 已提交
2741

W
wusongqing 已提交
2742
**Example**
W
wusongqing 已提交
2743

2744
```js
2745 2746 2747 2748 2749 2750
try {
    windowClass.on('keyboardHeightChange', (data) => {
        console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
    });
} catch (exception) {
    console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
2751
}
2752
```
W
wusongqing 已提交
2753 2754 2755 2756 2757 2758 2759 2760 2761

### 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 已提交
2762
**Parameters**
W
wusongqing 已提交
2763

W
wusongqing 已提交
2764 2765
| Name  | Type                  | Mandatory| Description                                                        |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
2766
| type     | string                 | Yes  | Event type. The value is fixed at **'keyboardHeightChange'**, indicating the keyboard height change event.|
2767 2768 2769 2770 2771
| callback | Callback&lt;number&gt; | No  | Callback used to return the current keyboard height.                              |

**Example**

```js
2772 2773 2774 2775
try {
    windowClass.off('keyboardHeightChange');
} catch (exception) {
    console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
2776
}
2777 2778 2779 2780 2781 2782 2783
```

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

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

Enables listening for click events outside this window.
2784 2785

**System API**: This is a system API.
2786 2787 2788 2789 2790 2791 2792

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

**Parameters**

| Name  | Type               | Mandatory| Description                                                        |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
2793 2794
| type     | string              | Yes  | Event type. The value is fixed at **'touchOutside'**, indicating the click event outside this window.|
| callback | Callback&lt;void&gt; | Yes  | Callback used to return the click event outside this window.                              |
2795 2796 2797 2798

**Example**

```js
2799 2800 2801 2802 2803 2804
try {
    windowClass.on('touchOutside', () => {
        console.info('touch outside');
    });
} catch (exception) {
    console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
2805
}
2806 2807 2808 2809 2810 2811 2812
```

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

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

Disables listening for click events outside this window.
2813 2814

**System API**: This is a system API.
2815 2816 2817 2818 2819 2820 2821

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

**Parameters**

| Name  | Type                  | Mandatory| Description                                                        |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
2822 2823
| 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 return the click event outside this window.                              |
W
wusongqing 已提交
2824

W
wusongqing 已提交
2825
**Example**
W
wusongqing 已提交
2826

2827
```js
2828 2829 2830 2831
try {
    windowClass.off('touchOutside');
} catch (exception) {
    console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
2832
}
2833
```
W
wusongqing 已提交
2834

2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846
### 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                                                        |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
2847
| type     | string              | Yes  | Event type. The value is fixed at **'screenshot'**, indicating the screenshot event.|
2848 2849 2850 2851 2852
| callback | Callback&lt;void&gt; | Yes  | Callback invoked when a screenshot event occurs.                              |

**Example**

```js
2853 2854 2855 2856 2857 2858
try {
    windowClass.on('screenshot', () => {
        console.info('screenshot happened');
    });
} catch (exception) {
    console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
2859
}
2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873
```

### 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                                                        |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
2874
| type     | string                 | Yes  | Event type. The value is fixed at **'screenshot'**, indicating the screenshot event.|
2875 2876 2877 2878 2879
| callback | Callback&lt;void&gt; | No  | Callback invoked when a screenshot event occurs.|

**Example**

```js
2880
let callback = () => {
2881
    console.info('screenshot happened');
2882 2883 2884 2885 2886
};
try {
    windowClass.on('screenshot', callback);
} catch (exception) {
    console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
2887
}
2888 2889 2890 2891 2892 2893
try {
    windowClass.off('screenshot', callback);
    // If multiple callbacks are enabled in on(), they will all be disabled.
    windowClass.off('screenshot');
} catch (exception) {
    console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
2894
}
2895 2896
```

2897
### on('dialogTargetTouch')<sup>10+</sup>
2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908

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                                                         |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
2909
| type     | string              | Yes  | Event type. The value is fixed at **'dialogTargetTouch'**, indicating the click event of the target window in the modal window mode.|
2910 2911 2912 2913 2914
| callback | Callback&lt;void&gt;| Yes  | Callback invoked when the click event occurs in the target window of the modal window mode.|

**Example**

```js
2915 2916 2917 2918 2919 2920
try {
    windowClass.on('dialogTargetTouch', () => {
        console.info('touch dialog target');
    });
} catch (exception) {
    console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
2921
}
2922 2923
```

2924
### off('dialogTargetTouch')<sup>10+</sup>
2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935

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                                                         |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
2936
| type     | string                 | Yes  | Event type. The value is fixed at **'dialogTargetTouch'**, indicating the click event of the target window in the modal window mode.|
2937 2938 2939 2940 2941
| callback | Callback&lt;void&gt;      | No  | Callback invoked when the click event occurs in the target window of the modal window mode.|

**Example**

```js
2942 2943 2944 2945
try {
    windowClass.off('dialogTargetTouch');
} catch (exception) {
    console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
2946
}
2947 2948
```

2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004
### on('windowEvent')<sup>10+</sup>

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

Enables listening for window lifecycle changes.

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

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

**Parameters**

| Name  | Type                                                      | Mandatory| Description                                                        |
| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | string                                                     | Yes  | Event type. The value is fixed at **'windowEvent'**, indicating the window lifecycle change event.|
| callback | Callback&lt;[WindowEventType](#windoweventtype10)&gt; | Yes  | Callback used to return the window lifecycle state.                |

**Example**

```js
try {
    windowClass.on('windowEvent', (data) => {
        console.info('Window event happened. Event:' + JSON.stringify(data));
    });
} catch (exception) {
    console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
}
```

### off('windowEvent')<sup>10+</sup>

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

Disables listening for window lifecycle changes.

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

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

**Parameters**

| Name  | Type                                                      | Mandatory| Description                                                        |
| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | string                                                     | Yes  | Event type. The value is fixed at **'windowEvent'**, indicating the window lifecycle change event.|
| callback | Callback&lt;[WindowEventType](#windoweventtype10)&gt; | No  | Callback used to return the window lifecycle state.                |

**Example**

```js
try {
    windowClass.off('windowEvent');
} catch (exception) {
    console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
}
```

3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022
### 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.|

3023 3024 3025 3026 3027 3028 3029 3030 3031
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

3032 3033 3034
**Example**

```js
3035 3036
import rpc from '@ohos.rpc';

3037 3038
class MyDeathRecipient {
    onRemoteDied() {
3039
        console.log('server died');
3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055
    }
}
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;
    }
}
3056

3057
let token = new TestRemoteObject('testObject');
3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069
try {
    windowClass.bindDialogTarget(token, () => {
        console.info('Dialog Window Need Destroy.');
    }, (err) => {
        if (err.code) {
            console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in binding dialog target.');
    });
} catch (exception) {
    console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
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
```

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

3096 3097 3098 3099 3100 3101 3102 3103 3104
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

3105 3106 3107
**Example**

```js
3108 3109
import rpc from '@ohos.rpc';

3110 3111
class MyDeathRecipient {
    onRemoteDied() {
3112
        console.log('server died');
3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128
    }
}
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;
    }
}
3129

3130
let token = new TestRemoteObject('testObject');
3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141
try {
    let promise = windowClass.bindDialogTarget(token, () => {
        console.info('Dialog Window Need Destroy.');
    });
    promise.then(()=> {
        console.info('Succeeded in binding dialog target.');
    }).catch((err)=>{
            console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
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
### bindDialogTarget<sup>9+</sup>

bindDialogTarget(requestInfo: dialogRequest.RequestInfo, 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                 |
| ----------- | ------------------------- | ---- | -------------------- |
| requestInfo | [dialogRequest.RequestInfo](js-apis-app-ability-dialogRequest.md#requestinfo) | Yes  | **RequestInfo** 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.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
import rpc from '@ohos.rpc';
import dialogRequest from '@ohos.app.ability.dialogRequest';
import window from '@ohos.window';

export default class ServiceExtAbility extends ServiceExtensionAbility {
    onCreate(want) {
        console.info('onCreate');
    }

    onRequest(want, startId) {
        console.info('onRequest');
        try {
            let requestInfo = dialogRequest.getRequestInfo(want)
            windowClass.bindDialogTarget(requestInfo, () => {
                console.info('Dialog Window Need Destroy.');
            }, (err) => {
                if (err.code) {
                    console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
                    return;
                }
                console.info('Succeeded in binding dialog target.');
            });
        } catch(err) {
            console.error('getRequestInfo err = ' + JSON.stringify(err))
        }
    }

    onConnect(want) {
        console.info('onConnect');
    }

    onDisconnect(want) {
        console.info('onDisconnect');
    }

    onDestroy() {
        console.info('onDestroy');
    }
}
```

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

bindDialogTarget(requestInfo: dialogRequest.RequestInfo, 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                 |
| ----------- | ------------------------- | ---- | -------------------- |
| requestInfo | [dialogRequest.RequestInfo](js-apis-app-ability-dialogRequest.md#requestinfo) | Yes  | **RequestInfo** 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.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
import rpc from '@ohos.rpc';
import dialogRequest from '@ohos.app.ability.dialogRequest';
import window from '@ohos.window';

export default class ServiceExtAbility extends ServiceExtensionAbility {
    onCreate(want) {
        console.info('onCreate');
    }

    onRequest(want, startId) {
        console.info('onRequest');
        try {
            let requestInfo = dialogRequest.getRequestInfo(want)
            let promise = windowClass.bindDialogTarget(requestInfo, () => {
                console.info('Dialog Window Need Destroy.');
            });
            promise.then(()=> {
                console.info('Succeeded in binding dialog target.');
            }).catch((err)=>{
                    console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
            });
        } catch(err) {
            console.error('getRequestInfo err = ' + JSON.stringify(err))
        }
    }

    onConnect(want) {
        console.info('onConnect');
    }

    onDisconnect(want) {
        console.info('onDisconnect');
    }

    onDestroy() {
        console.info('onDestroy');
    }
}
```

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
### isWindowSupportWideGamut<sup>9+</sup>

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

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

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

**Parameters**

| Name| Type| Mandatory| Description|
| -------- | ---------------------------- | -- | -------------------------------------------------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. The value **true** means that the wide-gamut color space is supported, and **false** means the opposite.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

**Example**

```js
windowClass.isWindowSupportWideGamut((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));
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
```

### isWindowSupportWideGamut<sup>9+</sup>

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

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

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

**Return value**

| Type| Description|
| ---------------------- | ------------------------------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means that the wide-gamut color space is supported, and **false** means the opposite.|

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

**Example**

```js
let promise = windowClass.isWindowSupportWideGamut();
3353
promise.then((data)=> {
3354
    console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
3355
}).catch((err)=>{
3356
    console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
3357 3358 3359
});
```

3360
### setWindowColorSpace<sup>9+</sup>
W
wusongqing 已提交
3361

3362
setWindowColorSpace(colorSpace:ColorSpace, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
3363

3364
Sets a color space for this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
3365 3366 3367

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

W
wusongqing 已提交
3368
**Parameters**
W
wusongqing 已提交
3369

3370 3371
| Name| Type| Mandatory| Description|
| ---------- | ------------------------- | -- | ----------- |
G
ge-yafang 已提交
3372
| colorSpace | [ColorSpace](#colorspace8) | Yes| Color space to set.|
3373 3374 3375 3376 3377 3378 3379 3380 3381
| callback   | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.  |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
W
wusongqing 已提交
3382

W
wusongqing 已提交
3383
**Example**
W
wusongqing 已提交
3384

3385
```js
3386 3387 3388 3389 3390 3391 3392 3393 3394 3395
try {
    windowClass.setWindowColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => {
        if (err.code) {
            console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in setting window colorspace.');
    });
} catch (exception) {
    console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
3396
}
3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410
```

### setWindowColorSpace<sup>9+</sup>

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

Sets a color space for this window. This API uses a promise to return the result.

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

**Parameters**

| Name| Type| Mandatory| Description|
| ---------- | ------------------------- | -- | ------------- |
G
ge-yafang 已提交
3411
| colorSpace | [ColorSpace](#colorspace8) | Yes| Color space to set.|
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

**Return value**

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

**Example**

```js
try {
    let promise = windowClass.setWindowColorSpace(window.ColorSpace.WIDE_GAMUT);
    promise.then(()=> {
        console.info('Succeeded in setting window colorspace.');
    }).catch((err)=>{
        console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
3439
}
3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453
```

### getWindowColorSpace<sup>9+</sup>

getWindowColorSpace(): ColorSpace

Obtains the color space of this window.

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

**Return value**

| Type| Description|
| ------------------------- | ------------- |
G
ge-yafang 已提交
3454
| [ColorSpace](#colorspace8) | Color space obtained.|
3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

**Example**

```js
let colorSpace = windowClass.getWindowColorSpace();
```

### setWindowBackgroundColor<sup>9+</sup>

setWindowBackgroundColor(color: string): void

Sets the background color for this window. In the stage model, this API must be used after [loadContent](#loadcontent9).

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

**Parameters**

| Name| Type| Mandatory| Description|
| ----- | ------ | -- | ----------------------------------------------------------------------- |
G
Gloria 已提交
3482
| color | string | Yes| Background color to set. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**.|
3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

**Example**

```js
let color = '#00ff33';
try {
    windowClass.setWindowBackgroundColor(color);
} catch (exception) {
    console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception));
3500
}
3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540
```

### setWindowBrightness<sup>9+</sup>

setWindowBrightness(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.                        |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
let brightness = 1;
try {
    windowClass.setWindowBrightness(brightness, (err) => {
        if (err.code) {
            console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in setting the brightness.');
    });
} catch (exception) {
    console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
3541
}
3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585
```

### setWindowBrightness<sup>9+</sup>

setWindowBrightness(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

**Parameters**

| Name| Type| Mandatory| Description|
| ---------- | ------ | -- | --------------------------------- |
| brightness | number | Yes| Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.|

**Return value**

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
let brightness = 1;
try {
    let promise = windowClass.setWindowBrightness(brightness);
    promise.then(()=> {
        console.info('Succeeded in setting the brightness.');
    }).catch((err)=>{
        console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
3586
}
3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615
```

### setWindowFocusable<sup>9+</sup>

setWindowFocusable(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

**Parameters**

| Name| Type| Mandatory| Description|
| ----------- | ------------------------- | -- | ------------------------------------------------------- |
| isFocusable | boolean                   | Yes| Whether the window can gain focus. The value **true** means that the window can gain focus, and **false** means the opposite.|
| callback    | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.                                              |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
3616
let isFocusable = true;
3617 3618 3619 3620 3621 3622 3623 3624 3625 3626
try {
    windowClass.setWindowFocusable(isFocusable, (err) => {
        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.');
    });
} catch (exception) {
    console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
3627
}
3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661
```

### setWindowFocusable<sup>9+</sup>

setWindowFocusable(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

**Parameters**

| Name| Type| Mandatory| Description|
| ----------- | ------- | -- | -------------------------------------------------------- |
| isFocusable | boolean | Yes| Whether the window can gain focus. The value **true** means that the window can gain focus, and **false** means the opposite. |

**Return value**

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
3662
let isFocusable = true;
3663 3664 3665 3666 3667 3668 3669 3670 3671
try {
    let promise = windowClass.setWindowFocusable(isFocusable);
    promise.then(()=> {
        console.info('Succeeded in setting the window to be focusable.');
    }).catch((err)=>{
        console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
3672
}
3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712
```

### setWindowKeepScreenOn<sup>9+</sup>

setWindowKeepScreenOn(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

**Parameters**

| Name| Type| Mandatory| Description|
| -------------- | ------------------------- | -- | ---------------------------------------------------- |
| isKeepScreenOn | boolean                   | Yes| Whether to keep the screen always on. The value **true** means to keep the screen always on, and **false** means the opposite. |
| callback       | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.                                           |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
let isKeepScreenOn = true;
try {
    windowClass.setWindowKeepScreenOn(isKeepScreenOn, (err) => {
        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.');
    });
} catch (exception) {
    console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
3713
}
3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757
```

### setWindowKeepScreenOn<sup>9+</sup>

setWindowKeepScreenOn(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. The value **true** means to keep the screen always on, and **false** means the opposite.|

**Return value**

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
let isKeepScreenOn = true;
try {
    let promise = windowClass.setWindowKeepScreenOn(isKeepScreenOn);
    promise.then(() => {
        console.info('Succeeded in setting the screen to be always on.');
    }).catch((err)=>{
        console.info('Failed to set the screen to be always on. Cause:  ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
3758
}
3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793
```

### setWakeUpScreen()<sup>9+</sup>

setWakeUpScreen(wakeUp: boolean): void

Wakes up the screen.

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

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

**Parameters**

| Name          | Type   | Mandatory| Description                        |
| ---------------- | ------- | ---- | ---------------------------- |
| wakeUp           | boolean | Yes  | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
let wakeUp = true;
try {
    windowClass.setWakeUpScreen(wakeUp);
} catch (exception) {
    console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception));
3794
}
3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835
```

### setWindowPrivacyMode<sup>9+</sup>

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

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.

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

**Required permissions**: ohos.permission.PRIVACY_WINDOW

**Parameters**

| Name| Type| Mandatory| Description|
| ------------- | ------------------------- | -- | ------------------------------------------------------ |
| isPrivacyMode | boolean                   | Yes| Whether the window is in privacy mode. The value **true** means that the window is in privacy mode, and **false** means the opposite. |
| callback      | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.                                             |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

**Example**

```js
let isPrivacyMode = true;
try {
    windowClass.setWindowPrivacyMode(isPrivacyMode, (err) => {
        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.');
    });
} catch (exception) {
    console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
3836
}
3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881
```

### setWindowPrivacyMode<sup>9+</sup>

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

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.

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

**Required permissions**: ohos.permission.PRIVACY_WINDOW

**Parameters**

| Name| Type| Mandatory| Description|
| ------------- | ------- | -- | ----------------------------------------------------- |
| isPrivacyMode | boolean | Yes| Whether the window is in privacy mode. The value **true** means that the window is in privacy mode, and **false** means the opposite.|

**Return value**

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

**Example**

```js
let isPrivacyMode = true;
try {
    let promise = windowClass.setWindowPrivacyMode(isPrivacyMode);
    promise.then(()=> {
        console.info('Succeeded in setting the window to privacy mode.');
    }).catch((err)=>{
        console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
3882
}
3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 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
```

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

```js
let isSkip = true;
try {
    windowClass.setSnapshotSkip(isSkip);
} catch (exception) {
    console.error('Failed to Skip. Cause: ' + JSON.stringify(exception));
};
```

### setWindowTouchable<sup>9+</sup>

setWindowTouchable(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

**Parameters**

| Name| Type| Mandatory| Description|
| ----------- | ------------------------- | -- | ----------------------------------------------- |
| isTouchable | boolean                   | Yes| Whether the window is touchable. The value **true** means that the window is touchable, and **false** means the opposite.|
| callback    | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.                                       |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
let isTouchable = true;
try {
    windowClass.setWindowTouchable(isTouchable, (err) => {
        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.');
    });
} catch (exception) {
    console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
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
```

### setWindowTouchable<sup>9+</sup>

setWindowTouchable(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

**Parameters**

| Name| Type| Mandatory| Description|
| ----------- | ------- | -- | ----------------------------------------------- |
| isTouchable | boolean | Yes| Whether the window is touchable. The value **true** means that the window is touchable, and **false** means the opposite.|

**Return value**

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
let isTouchable = true;
try {
    let promise = windowClass.setWindowTouchable(isTouchable);
    promise.then(()=> {
        console.info('Succeeded in setting the window to be touchable.');
    }).catch((err)=>{
        console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
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
```

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

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

**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. The value **true** means the window is forbidden to move in split-screen mode, and **false** means the opposite.|
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
let isForbidSplitMove = true;
try {
    windowClass.setForbidSplitMove(isForbidSplitMove, (err) => {
        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.');
    });
} catch (exception) {
    console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
4043
}
4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089
```

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

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

**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. The value **true** means the window is forbidden to move in split-screen mode, and **false** means the opposite.|

**Return value**

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |

**Example**

```js
let isForbidSplitMove = true;
try {
    let promise = windowClass.setForbidSplitMove(isForbidSplitMove);
    promise.then(()=> {
        console.info('Succeeded in forbidding window moving in split screen mode.');
    }).catch((err)=>{
        console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
4090
}
4091 4092 4093 4094
```

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

4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129
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. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

**Example**

```js
windowClass.snapshot((err, pixelMap) => {
    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());
    pixelMap.release(); // Release the memory in time after the PixelMap is used.
});
```

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

4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165
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. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |

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

### opacity<sup>9+</sup>

opacity(opacity: number): void

G
Gloria 已提交
4166
Sets the opacity for this window. This API can be used only when you [customize an animation to be played during the display or hiding of a system window](../../windowmanager/system-window-stage.md#customizing-an-animation-to-be-played-during-the-display-or-hiding-of-a-system-window).
4167 4168 4169 4170 4171 4172 4173

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

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

**Parameters**

G
Gloria 已提交
4174 4175 4176
| Name    | Type   | Mandatory | Description                                                  |
| ------- | ------ | --------- | ------------------------------------------------------------ |
| opacity | number | Yes       | Opacity to set. The value ranges from 0.0 to 1.0. The value **0.0** means completely transparent, and **1.0** means completely opaque. |
4177 4178 4179 4180 4181 4182 4183 4184

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
4185
| 1300004 | Unauthorized operation.        |
4186 4187 4188 4189 4190 4191 4192 4193

**Example**

```js
try {
    windowClass.opacity(0.5);
} catch (exception) {
    console.error('Failed to opacity. Cause: ' + JSON.stringify(exception));
4194
}
4195 4196 4197 4198 4199 4200
```

### scale<sup>9+</sup>

scale(scaleOptions: ScaleOptions): void

G
Gloria 已提交
4201
Sets the scale parameters for this window. This API can be used only when you [customize an animation to be played during the display or hiding of a system window](../../windowmanager/system-window-stage.md#customizing-an-animation-to-be-played-during-the-display-or-hiding-of-a-system-window).
4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
4220
| 1300004 | Unauthorized operation.        |
4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234

**Example**

```js
let obj : window.ScaleOptions = {
  x : 2.0,
  y : 1.0,
  pivotX : 0.5,
  pivotY : 0.5
};
try {
    windowClass.scale(obj);
} catch (exception) {
    console.error('Failed to scale. Cause: ' + JSON.stringify(exception));
4235
}
4236 4237 4238 4239 4240 4241
```

### rotate<sup>9+</sup>

rotate(rotateOptions: RotateOptions): void

G
Gloria 已提交
4242
Sets the rotation parameters for this window. This API can be used only when you [customize an animation to be played during the display or hiding of a system window](../../windowmanager/system-window-stage.md#customizing-an-animation-to-be-played-during-the-display-or-hiding-of-a-system-window).
4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
4261
| 1300004 | Unauthorized operation.        |
4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276

**Example**

```js
let obj : window.RotateOptions = {
  x : 1.0,
  y : 1.0,
  z : 45.0,
  pivotX : 0.5,
  pivotY : 0.5
};
try {
    windowClass.rotate(obj);
} catch (exception) {
    console.error('Failed to rotate. Cause: ' + JSON.stringify(exception));
4277
}
4278 4279 4280 4281 4282 4283
```

### translate<sup>9+</sup>

translate(translateOptions: TranslateOptions): void

G
Gloria 已提交
4284
Sets the translation parameters for this window. This API can be used only when you [customize an animation to be played during the display or hiding of a system window](../../windowmanager/system-window-stage.md#customizing-an-animation-to-be-played-during-the-display-or-hiding-of-a-system-window).
4285 4286 4287 4288 4289 4290 4291

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

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

**Parameters**

G
Gloria 已提交
4292 4293 4294
| Name             | Type                                   | Mandatory | Description                                 |
| ---------------- | -------------------------------------- | --------- | ------------------------------------------- |
| translateOptions | [TranslateOptions](#translateoptions9) | Yes       | Translation parameters. The unit is pixels. |
4295 4296 4297 4298 4299 4300 4301 4302

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
4303
| 1300004 | Unauthorized operation.        |
4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316

**Example**

```js
let obj : window.TranslateOptions = {
  x : 100.0,
  y : 0.0,
  z : 0.0
};
try {
    windowClass.translate(obj);
} catch (exception) {
    console.error('Failed to translate. Cause: ' + JSON.stringify(exception));
4317
}
4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342
```

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
4343
| 1300004 | Unauthorized operation.        |
4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359

**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 playback mode.
        onFinish: ()=> {
            context.completeTransition(true)
4360
        }
4361 4362 4363 4364 4365 4366 4367 4368 4369
      }, () => {
        let obj : window.TranslateOptions = {
          x : 100.0,
          y : 0.0,
          z : 0.0
        };
        toWindow.translate(obj); // Set the transition animation.
        console.info('toWindow translate end');
      }
4370
    );
4371
    console.info('complete transition end');
4372
};
4373 4374 4375 4376 4377 4378
windowClass.hideWithAnimation((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));
4379
});
4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404
```

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
4405
| 1300004 | Unauthorized operation.        |
4406 4407 4408 4409 4410 4411 4412 4413

**Example**

```js
try {
    windowClass.setBlur(4.0);
} catch (exception) {
    console.error('Failed to set blur. Cause: ' + JSON.stringify(exception));
4414
}
4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439
```

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
4440
| 1300004 | Unauthorized operation.        |
4441 4442 4443 4444 4445 4446 4447 4448

**Example**

```js
try {
    windowClass.setBackdropBlur(4.0);
} catch (exception) {
    console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception));
4449
}
4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474
```

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
4475
| 1300004 | Unauthorized operation.        |
4476 4477 4478 4479 4480 4481 4482 4483

**Example**

```js
try {
    windowClass.setBackdropBlurStyle(window.BlurStyle.THIN);
} catch (exception) {
    console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception));
4484
}
4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501
```

### 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 shadow. The value is greater than or equal to 0. The value **0** means that the shadow is disabled for the window borders. |
G
Gloria 已提交
4502
| color   | string | No        | Color of the shadow. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**. |
4503 4504 4505 4506 4507 4508 4509 4510 4511 4512
| 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.            |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
4513
| 1300004 | Unauthorized operation.        |
4514 4515 4516 4517 4518 4519 4520 4521

**Example**

```js
try {
    windowClass.setShadow(4.0, '#FF00FF00', 2, 3);
} catch (exception) {
    console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception));
4522
}
4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547
```

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
4548
| 1300004 | Unauthorized operation.        |
4549 4550 4551 4552 4553 4554 4555 4556

**Example**

```js
try {
    windowClass.setCornerRadius(4.0);
} catch (exception) {
    console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception));
4557
}
4558 4559
```

4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806
### raiseToAppTop<sup>10+</sup>

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

Raises the application subwindow to the top layer of the application. 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. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                                 |
| ------- | --------------------------------------------- |
| 1300002 | This window state is abnormal.                |
| 1300003 | This window manager service works abnormally. |
| 1300004 | Unauthorized operation.                       |
| 1300009 | The parent window is invalid.                 |

**Example**

```js
windowClass.raiseToAppTop((err) => {
    if (err.code) {
        console.error('Failed to raise the window to app top. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in raising the window to app top.');
});
```

### raiseToAppTop<sup>10+</sup>

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

Raises the application subwindow to the top layer of the application. 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. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                                 |
| ------- | --------------------------------------------- |
| 1300002 | This window state is abnormal.                |
| 1300003 | This window manager service works abnormally. |
| 1300004 | Unauthorized operation.                       |
| 1300009 | The parent window is invalid.                 |

**Example**

```js
let promise = windowClass.raiseToAppTop();
promise.then(()=> {
    console.info('Succeeded in raising the window to app top.');
}).catch((err)=>{
    console.error('Failed to raise the window to app top. Cause: ' + JSON.stringify(err));
});
```
### setAspectRatio<sup>10+</sup>

setAspectRatio(ratio: number): Promise&lt;void&gt;

Sets the aspect ratio of the window content layout. This API uses a promise to return the result.

This API is available only for the main window of the application. The aspect ratio will be saved permanently and takes effect even after the application is closed or the device is restarted.

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

**Parameters**

| Name  | Type   | Mandatory | Description                                                  |
| ----- | ------ | --------- | ------------------------------------------------------------ |
| ratio | number | Yes       | Aspect ratio of the window content layout except border decoration. The value must be greater than 0. |

**Return value**

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300004 | Unauthorized operation.        |

**Example**

```js
try {
    let ratio = 1.0;
    let promise = windowClass.setAspectRatio(ratio);
    promise.then(()=> {
        console.info('Succeeded in setting aspect ratio of window.');
    }).catch((err)=>{
        console.error('Failed to set the aspect ratio of window. Cause:' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set the aspect ratio of window. Cause: ' + JSON.stringify(exception));
}
```

### setAspectRatio<sup>10+</sup>

setAspectRatio(ratio: number, callback: AsyncCallback&lt;void&gt;): void

Sets the aspect ratio of the window content layout. This API uses an asynchronous callback to return the result.

This API is available only for the main window of the application. The aspect ratio will be saved permanently and takes effect even after the application is closed or the device is restarted.

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

**Parameters**

| Name     | Type                      | Mandatory | Description                                                  |
| -------- | ------------------------- | --------- | ------------------------------------------------------------ |
| ratio    | number                    | Yes       | Aspect ratio of the window content layout except border decoration. The value must be greater than 0. |
| callback | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result.                          |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300004 | Unauthorized operation.        |

**Example**

```js
try {
    let ratio = 1.0;
    windowClass.setAspectRatio(ratio, (err) => {
        if (err.code) {
            console.error('Failed to set the aspect ratio of window. Cause:' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in setting the aspect ratio of window.');
    });
} catch (exception) {
    console.error('Failed to set the aspect ratio of window. Cause: ' + JSON.stringify(exception));
}
```

### resetAspectRatio<sup>10+</sup>

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

Resets the aspect ratio of the window content layout. This API uses a promise to return the result.

This API is available only for the main window of the application. After this API is called, the persistently stored aspect ratio is cleared.

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

**Return value**

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300004 | Unauthorized operation.        |

**Example**

```js
try {
    let promise = windowClass.resetAspectRatio();
    promise.then(()=> {
        console.info('Succeeded in resetting aspect ratio of window.');
    }).catch((err)=>{
        console.error('Failed to reset the aspect ratio of window. Cause:' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to reset the aspect ratio of window. Cause: ' + JSON.stringify(exception));
}
```

### resetAspectRatio<sup>10+</sup>

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

Resets the aspect ratio of the window content layout. This API uses an asynchronous callback to return the result.

This API is available only for the main window of the application. After this API is called, the persistently stored aspect ratio is cleared.

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

**Parameters**

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300004 | Unauthorized operation.        |

**Example**

```js
try {
    windowClass.resetAspectRatio((err) => {
        if (err.code) {
            console.error('Failed to reset the aspect ratio of window. Cause:' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in resetting aspect ratio of window.');
    });
} catch (exception) {
    console.error('Failed to reset the aspect ratio of window. Cause: ' + JSON.stringify(exception));
}
```

G
Gloria 已提交
4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898
### setWaterMarkFlag<sup>10+</sup>

setWaterMarkFlag(enable: boolean): Promise&lt;void&gt;

Adds or deletes the watermark flag for this window. 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                                                  |
| ------ | ------- | --------- | ------------------------------------------------------------ |
| enable | boolean | Yes       | Whether to add or delete the watermark flag to the window. The value **true** means to add the watermark flag and **false** means to delete the watermark flag. |

**Return value**

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

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                                 |
| ------- | --------------------------------------------- |
| 1300002 | This window state is abnormal.                |
| 1300003 | This window manager service works abnormally. |
| 1300008 | The operation is on invalid display.          |

**Example**

```js
try {
    let enable = true;
    let promise = windowClass.setWaterMarkFlag(enable);
    promise.then(()=> {
        console.info('Succeeded in setting water mark flag of window.');
    }).catch((err)=>{
        console.error('Failed to set water mark flag of window. Cause:' + JSON.stringify(err));
    });
} catch (exception) {
    console.error('Failed to set water mark flag of window. Cause: ' + JSON.stringify(exception));
}
```

### setWaterMarkFlag<sup>10+</sup>

setWaterMarkFlag(enable: boolean, callback: AsyncCallback&lt;void&gt;): void

Adds or deletes the watermark flag for this window. 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                                                  |
| -------- | ------------------------- | --------- | ------------------------------------------------------------ |
| enable   | boolean                   | Yes       | Whether to add or delete the watermark flag to the window. The value **true** means to add the watermark flag and **false** means to delete the watermark flag. |
| callback | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result.                          |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                                 |
| ------- | --------------------------------------------- |
| 1300002 | This window state is abnormal.                |
| 1300003 | This window manager service works abnormally. |
| 1300008 | The operation is on invalid display.          |

**Example**

```js
try {
    let enable = true;
    windowClass.setWaterMarkFlag(enable, (err) => {
        if (err.code) {
            console.error('Failed to set water mark flag of window. Cause:' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in setting water mark flag of window.');
    });
} catch (exception) {
    console.error('Failed to set water mark flag of window. Cause: ' + JSON.stringify(exception));
}
```

4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925
### show<sup>(deprecated)</sup>

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

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

> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [showWindow()](#showwindow9) instead.

**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.show((err) => {
    if (err.code) {
        console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in showing the window.');
4926
});
4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954
```

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

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

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

> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [showWindow()](#showwindow9-1) instead.

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

**Return value**

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

**Example**

```js
let promise = windowClass.show();
promise.then(()=> {
    console.info('Succeeded in showing the window.');
}).catch((err)=>{
    console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
4955
});
4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984
```

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

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

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

> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [destroyWindow()](#destroywindow9) instead.

**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.destroy((err) => {
    if (err.code) {
        console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in destroying the window.');
4985
});
4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013
```

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

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

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

> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [destroyWindow()](#destroywindow9-1) instead.

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

**Return value**

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

**Example**

```js
let promise = windowClass.destroy();
promise.then(()=> {
    console.info('Succeeded in destroying the window.');
}).catch((err)=>{
    console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
5014
});
5015 5016 5017 5018 5019 5020 5021 5022
```

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

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

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

5023 5024
This operation is not supported in a window in full-screen mode.

5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [moveWindowTo()](#movewindowto9) instead.

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

**Parameters**

| 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. |
| callback | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result.                          |

**Example**

```js
windowClass.moveTo(300, 300, (err)=>{
    if (err.code) {
        console.error('Failed to move the window. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in moving the window.');
});
```

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

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

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

5057 5058
This operation is not supported in a window in full-screen mode.

5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [moveWindowTo()](#movewindowto9-1) instead.

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

**Parameters**

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

**Return value**

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

**Example**

```js
let promise = windowClass.moveTo(300, 300);
promise.then(()=> {
    console.info('Succeeded in moving the window.');
}).catch((err)=>{
    console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
5086
});
5087 5088 5089 5090 5091 5092 5093 5094
```

### resetSize<sup>(deprecated)</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.

5095 5096 5097 5098 5099 5100
The main window and subwindow have the following size limits: [320, 2560] in width and [240, 2560] in height, both in units of vp.

The system window has the following size limits: [0, 2560] in width and [0, 2560] in height, both in units of vp.

The new width and height you set must meet the limits.

5101 5102
This operation is not supported in a window in full-screen mode.

5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [resize()](#resize9) instead.

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

**Parameters**

| Name     | Type                      | Mandatory | Description                         |
| -------- | ------------------------- | --------- | ----------------------------------- |
| width    | number                    | Yes       | New width of the window, in px.     |
| height   | number                    | Yes       | New height of the window, in px.    |
| callback | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result. |

**Example**

```js
windowClass.resetSize(500, 1000, (err) => {
    if (err.code) {
        console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in changing the window size.');
});
```

### resetSize<sup>(deprecated)</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.

5135 5136 5137 5138 5139 5140
The main window and subwindow have the following size limits: [320, 2560] in width and [240, 2560] in height, both in units of vp.

The system window has the following size limits: [0, 2560] in width and [0, 2560] in height, both in units of vp.

The new width and height you set must meet the limits.

5141 5142
This operation is not supported in a window in full-screen mode.

5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [resize()](#resize9-1) instead.

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

**Parameters**

| Name   | Type   | Mandatory | Description                      |
| ------ | ------ | --------- | -------------------------------- |
| width  | number | Yes       | New width of the window, in px.  |
| height | number | Yes       | New height of the window, in px. |

**Return value**

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

**Example**

```js
let promise = windowClass.resetSize(500, 1000);
promise.then(()=> {
    console.info('Succeeded in changing the window size.');
}).catch((err)=>{
    console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
});
```

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

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.

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

> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9.

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

**Parameters**

| Name     | Type                       | Mandatory | Description                         |
| -------- | -------------------------- | --------- | ----------------------------------- |
| type     | [WindowType](#windowtype7) | Yes       | Window type.                        |
| callback | AsyncCallback&lt;void&gt;  | Yes       | Callback used to return the result. |

**Example**

```js
let type = window.WindowType.TYPE_APP;
windowClass.setWindowType(type, (err) => {
  if (err.code) {
      console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
      return;
  }
  console.info('Succeeded in setting the window type.');
});
```

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

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

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

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

> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9.

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

**Parameters**

| Name | Type                       | Mandatory | Description  |
| ---- | -------------------------- | --------- | ------------ |
| type | [WindowType](#windowtype7) | Yes       | Window type. |

**Return value**

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

**Example**

```js
let type = window.WindowType.TYPE_APP;
let promise = windowClass.setWindowType(type);
promise.then(()=> {
    console.info('Succeeded in setting the window type.');
}).catch((err)=>{
    console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
});
```

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

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

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

> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [getWindowProperties()](#getwindowproperties9) instead.

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

**Parameters**

| Name     | Type                                                       | Mandatory | Description                                    |
| -------- | ---------------------------------------------------------- | --------- | ---------------------------------------------- |
| callback | AsyncCallback&lt;[WindowProperties](#windowproperties)&gt; | Yes       | Callback used to return the window properties. |

**Example**

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

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

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

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

> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [getWindowProperties()](#getwindowproperties9) instead.

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

**Return value**

| Type                                                 | Description                                   |
| ---------------------------------------------------- | --------------------------------------------- |
| Promise&lt;[WindowProperties](#windowproperties)&gt; | Promise used to return the window properties. |

**Example**

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

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

getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt;): void

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

> **NOTE**
>
5312
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getWindowAvoidArea()](#getwindowavoidarea9) instead.
5313 5314 5315 5316 5317

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

**Parameters**

G
Gloria 已提交
5318 5319 5320 5321
| Name     | Type                                          | Mandatory | Description                       |
| -------- | --------------------------------------------- | --------- | --------------------------------- |
| type     | [AvoidAreaType](#avoidareatype7)              | Yes       | Type of the area.                 |
| callback | AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt; | Yes       | Callback used to return the area. |
5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343

**Example**

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

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

getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise&lt;[AvoidArea](#avoidarea7)&gt;

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

> **NOTE**
>
5344
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getWindowAvoidArea()](#getwindowavoidarea9) instead.
5345 5346 5347 5348 5349

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

**Parameters**

G
Gloria 已提交
5350 5351 5352
| Name | Type                             | Mandatory | Description       |
| ---- | -------------------------------- | --------- | ----------------- |
| type | [AvoidAreaType](#avoidareatype7) | Yes       | Type of the area. |
5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395

**Return value**

| Type                                    | Description                      |
| --------------------------------------- | -------------------------------- |
| Promise&lt;[AvoidArea](#avoidarea7)&gt; | Promise used to return the area. |

**Example**

```js
let type = window.AvoidAreaType.TYPE_SYSTEM;
let promise = windowClass.getAvoidArea(type);
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));
});
```

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

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.

> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowSystemBarEnable()](#setwindowsystembarenable9) instead.

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

**Parameters**

| Name         | Type                      | Mandatory | Description                                                  |
| ------------ | ------------------------- | --------- | ------------------------------------------------------------ |
| isFullScreen | boolean                   | Yes       | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden. The value **true** means to enable the full-screen mode, and **false** means the opposite. |
| callback     | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result.                          |

**Example**

```js
let isFullScreen = true;
windowClass.setFullScreen(isFullScreen, (err) => {
5396
    if (err.code) {
5397
        console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
5398 5399
        return;
    }
5400 5401
    console.info('Succeeded in enabling the full-screen mode.');
});
5402
```
W
wusongqing 已提交
5403

5404
### setFullScreen<sup>(deprecated)</sup>
W
wusongqing 已提交
5405

5406
setFullScreen(isFullScreen: boolean): Promise&lt;void&gt;
W
wusongqing 已提交
5407

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

> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowSystemBarEnable()](#setwindowsystembarenable9-1) instead.
W
wusongqing 已提交
5413 5414 5415

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

5416 5417 5418 5419 5420 5421
**Parameters**

| Name         | Type    | Mandatory | Description                                                  |
| ------------ | ------- | --------- | ------------------------------------------------------------ |
| isFullScreen | boolean | Yes       | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden. The value **true** means to enable the full-screen mode, and **false** means the opposite. |

W
wusongqing 已提交
5422
**Return value**
W
wusongqing 已提交
5423

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

W
wusongqing 已提交
5428
**Example**
W
wusongqing 已提交
5429

5430
```js
5431 5432 5433 5434
let isFullScreen = true;
let promise = windowClass.setFullScreen(isFullScreen);
promise.then(()=> {
    console.info('Succeeded in enabling the full-screen mode.');
5435
}).catch((err)=>{
5436
    console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
5437 5438
});
```
W
wusongqing 已提交
5439

5440
### setLayoutFullScreen<sup>(deprecated)</sup>
W
wusongqing 已提交
5441

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

G
Gloria 已提交
5444 5445 5446
Sets whether the window layout is immersive. This API uses an asynchronous callback to return the result.
An immersive layout means that the layout does not avoid the status bar and navigation bar, and components may overlap with them.
A non-immersive layout means that the layout avoids the status bar and navigation bar, and components do not overlap with them.
W
wusongqing 已提交
5447

5448 5449 5450
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9) instead.
W
wusongqing 已提交
5451 5452 5453

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

W
wusongqing 已提交
5454
**Parameters**
W
wusongqing 已提交
5455

5456 5457
| Name               | Type                      | Mandatory | Description                                                  |
| ------------------ | ------------------------- | --------- | ------------------------------------------------------------ |
G
Gloria 已提交
5458
| isLayoutFullScreen | boolean                   | Yes       | Whether the window layout is immersive. (The status bar and navigation bar of the immersive layout are still displayed.) The value **true** means that the window is immersive, and **false** means the opposite. |
5459
| callback           | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result.                          |
W
wusongqing 已提交
5460

W
wusongqing 已提交
5461
**Example**
W
wusongqing 已提交
5462

5463
```js
5464 5465
let isLayoutFullScreen= true;
windowClass.setLayoutFullScreen(isLayoutFullScreen, (err) => {
5466
    if (err.code) {
5467
        console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
5468 5469
        return;
    }
5470 5471
    console.info('Succeeded in setting the window layout to full-screen mode.');
});
5472
```
W
wusongqing 已提交
5473

5474
### setLayoutFullScreen<sup>(deprecated)</sup>
W
wusongqing 已提交
5475

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

G
Gloria 已提交
5478 5479 5480
Sets whether the window layout is immersive. This API uses a promise to return the result.
An immersive layout means that the layout does not avoid the status bar and navigation bar, and components may overlap with them.
A non-immersive layout means that the layout avoids the status bar and navigation bar, and components do not overlap with them.
W
wusongqing 已提交
5481

5482 5483 5484
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9-1) instead.
W
wusongqing 已提交
5485 5486 5487

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

W
wusongqing 已提交
5488
**Parameters**
W
wusongqing 已提交
5489

5490 5491
| Name               | Type    | Mandatory | Description                                                  |
| ------------------ | ------- | --------- | ------------------------------------------------------------ |
G
Gloria 已提交
5492
| isLayoutFullScreen | boolean | Yes       | Whether the window layout is immersive. (The status bar and navigation bar of the immersive layout are still displayed.) The value **true** means that the window is immersive, and **false** means the opposite. |
W
wusongqing 已提交
5493

W
wusongqing 已提交
5494
**Return value**
W
wusongqing 已提交
5495

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

W
wusongqing 已提交
5500
**Example**
W
wusongqing 已提交
5501

5502
```js
5503 5504 5505 5506
let isLayoutFullScreen = true;
let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen);
promise.then(()=> {
    console.info('Succeeded in setting the window layout to full-screen mode.');
5507
}).catch((err)=>{
5508
    console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
5509 5510
});
```
W
wusongqing 已提交
5511

5512
### setSystemBarEnable<sup>(deprecated)</sup>
W
wusongqing 已提交
5513

5514 5515 5516
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.
W
wusongqing 已提交
5517

5518 5519 5520
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowSystemBarEnable()](#setwindowsystembarenable9) instead.
W
wusongqing 已提交
5521 5522 5523

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

W
wusongqing 已提交
5524
**Parameters**
W
wusongqing 已提交
5525

5526 5527 5528 5529
| Name     | Type                          | Mandatory | Description                                                  |
| -------- | ----------------------------- | --------- | ------------------------------------------------------------ |
| names    | Array<'status'\|'navigation'> | 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 已提交
5530

W
wusongqing 已提交
5531
**Example**
W
wusongqing 已提交
5532

5533
```js
5534 5535 5536
// In this example, the status bar and navigation bar are not displayed.
let names = [];
windowClass.setSystemBarEnable(names, (err) => {
5537
    if (err.code) {
5538
        console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
5539 5540
        return;
    }
5541 5542
    console.info('Succeeded in setting the system bar to be invisible.');
});
5543
```
W
wusongqing 已提交
5544

5545
### setSystemBarEnable<sup>(deprecated)</sup>
W
wusongqing 已提交
5546

5547
setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt;
W
wusongqing 已提交
5548

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

> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowSystemBarEnable()](#setwindowsystembarenable9-1) instead.
W
wusongqing 已提交
5554 5555 5556

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

5557 5558
**Parameters**

5559 5560 5561
| Name  | Type                          | Mandatory | Description                                                  |
| ----- | ----------------------------- | --------- | ------------------------------------------------------------ |
| names | Array<'status'\|'navigation'> | 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. |
5562

W
wusongqing 已提交
5563
**Return value**
W
wusongqing 已提交
5564

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

W
wusongqing 已提交
5569
**Example**
W
wusongqing 已提交
5570

5571
```js
5572 5573 5574 5575 5576
// In this example, the status bar and navigation bar are not displayed.
let names = [];
let promise = windowClass.setSystemBarEnable(names);
promise.then(()=> {
    console.info('Succeeded in setting the system bar to be invisible.');
5577
}).catch((err)=>{
5578
    console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
5579 5580
});
```
W
wusongqing 已提交
5581

5582
### setSystemBarProperties<sup>(deprecated)</sup>
W
wusongqing 已提交
5583

5584 5585 5586
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.
W
wusongqing 已提交
5587

5588 5589 5590
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowSystemBarProperties()](#setwindowsystembarproperties9) instead.
W
wusongqing 已提交
5591 5592 5593

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

W
wusongqing 已提交
5594
**Parameters**
W
wusongqing 已提交
5595

5596 5597 5598 5599
| Name                | Type                                        | Mandatory | Description                                      |
| ------------------- | ------------------------------------------- | --------- | ------------------------------------------------ |
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes       | Properties of the status bar and navigation bar. |
| callback            | AsyncCallback&lt;void&gt;                   | Yes       | Callback used to return the result.              |
W
wusongqing 已提交
5600

W
wusongqing 已提交
5601
**Example**
W
wusongqing 已提交
5602

5603
```js
5604 5605 5606 5607 5608 5609 5610 5611
let SystemBarProperties={
    statusBarColor: '#ff00ff',
    navigationBarColor: '#00ff00',
    // The following properties are supported since API version 8.
    statusBarContentColor:'#ffffff',
    navigationBarContentColor:'#00ffff'
};
windowClass.setSystemBarProperties(SystemBarProperties, (err) => {
5612
    if (err.code) {
5613
        console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
5614 5615
        return;
    }
5616
    console.info('Succeeded in setting the system bar properties.');
5617 5618
});
```
W
wusongqing 已提交
5619

5620
### setSystemBarProperties<sup>(deprecated)</sup>
W
wusongqing 已提交
5621

5622 5623 5624
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.
W
wusongqing 已提交
5625

5626 5627 5628
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowSystemBarProperties()](#setwindowsystembarproperties9-1) instead.
W
wusongqing 已提交
5629 5630 5631

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

W
wusongqing 已提交
5632
**Parameters**
W
wusongqing 已提交
5633

5634 5635 5636
| Name                | Type                                        | Mandatory | Description                                      |
| ------------------- | ------------------------------------------- | --------- | ------------------------------------------------ |
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes       | Properties of the status bar and navigation bar. |
W
wusongqing 已提交
5637

W
wusongqing 已提交
5638
**Return value**
W
wusongqing 已提交
5639

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

W
wusongqing 已提交
5644
**Example**
W
wusongqing 已提交
5645

5646
```js
5647 5648 5649 5650 5651 5652 5653 5654 5655 5656
let SystemBarProperties={
    statusBarColor: '#ff00ff',
    navigationBarColor: '#00ff00',
    // The following properties are supported since API version 8.
    statusBarContentColor:'#ffffff',
    navigationBarContentColor:'#00ffff'
};
let promise = windowClass.setSystemBarProperties(SystemBarProperties);
promise.then(()=> {
    console.info('Succeeded in setting the system bar properties.');
5657
}).catch((err)=>{
5658
    console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
5659
});
5660 5661
```

5662
### loadContent<sup>(deprecated)</sup>
5663

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

5666 5667 5668 5669 5670
Loads content from a page to this window. This API uses an asynchronous callback to return the result.

> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setUIContent()](#setuicontent9) instead.
5671 5672 5673 5674 5675

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

**Parameters**

5676 5677 5678 5679
| Name     | Type                      | Mandatory | Description                                             |
| -------- | ------------------------- | --------- | ------------------------------------------------------- |
| path     | string                    | Yes       | Path of the page from which the content will be loaded. |
| callback | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result.                     |
5680 5681 5682 5683

**Example**

```js
5684 5685 5686 5687 5688 5689
windowClass.loadContent('pages/page2/page2', (err) => {
   if (err.code) {
         console.error('Failed to load the content. Cause:' + JSON.stringify(err));
         return;
   }
  console.info('Succeeded in loading the content.');
5690 5691
});
```
W
wusongqing 已提交
5692

5693
### loadContent<sup>(deprecated)</sup>
W
wusongqing 已提交
5694

5695
loadContent(path: string): Promise&lt;void&gt;
W
wusongqing 已提交
5696

5697 5698 5699 5700 5701
Loads content from a page to this window. This API uses a promise to return the result.

> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setUIContent()](#setuicontent9-1) instead.
W
wusongqing 已提交
5702 5703 5704

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

W
wusongqing 已提交
5705
**Parameters**
W
wusongqing 已提交
5706

5707 5708 5709
| Name | Type   | Mandatory | Description                                             |
| ---- | ------ | --------- | ------------------------------------------------------- |
| path | string | Yes       | Path of the page from which the content will be loaded. |
W
wusongqing 已提交
5710

W
wusongqing 已提交
5711
**Return value**
W
wusongqing 已提交
5712

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

W
wusongqing 已提交
5717
**Example**
W
wusongqing 已提交
5718

5719
```js
5720 5721 5722
let promise = windowClass.loadContent('pages/page2/page2');
promise.then(()=> {
    console.info('Succeeded in loading the content.');
5723
}).catch((err)=>{
5724
    console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
5725 5726
});
```
W
wusongqing 已提交
5727

5728
### isShowing<sup>(deprecated)</sup>
W
wusongqing 已提交
5729

5730
isShowing(callback: AsyncCallback&lt;boolean&gt;): void
W
wusongqing 已提交
5731

5732
Checks whether this window is displayed. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
5733

W
wusongqing 已提交
5734
> **NOTE**
5735
>
5736
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isWindowShowing()](#iswindowshowing9) instead.
W
wusongqing 已提交
5737 5738 5739 5740 5741

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

**Parameters**

5742 5743 5744
| Name     | Type                         | Mandatory | Description                                                  |
| -------- | ---------------------------- | --------- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | Yes       | Callback used to return the result. The value **true** means that the window is displayed, and **false** means the opposite. |
W
wusongqing 已提交
5745 5746 5747

**Example**

5748
```js
5749
windowClass.isShowing((err, data) => {
5750
    if (err.code) {
5751
        console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err));
5752 5753
        return;
    }
5754
    console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
5755 5756
});
```
W
wusongqing 已提交
5757

5758
### isShowing<sup>(deprecated)</sup>
W
wusongqing 已提交
5759

5760
isShowing(): Promise&lt;boolean&gt;
W
wusongqing 已提交
5761

5762
Checks whether this window is displayed. This API uses a promise to return the result.
W
wusongqing 已提交
5763

W
wusongqing 已提交
5764
> **NOTE**
5765
>
5766
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isWindowShowing()](#iswindowshowing9) instead.
W
wusongqing 已提交
5767 5768 5769 5770 5771

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

**Return value**

5772 5773 5774
| Type                   | Description                                                  |
| ---------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means that the window is displayed, and **false** means the opposite. |
W
wusongqing 已提交
5775 5776 5777

**Example**

5778
```js
5779
let promise = windowClass.isShowing();
5780
promise.then((data)=> {
5781
    console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
5782
}).catch((err)=>{
5783
    console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err));
5784 5785
});
```
W
wusongqing 已提交
5786

5787 5788 5789
### on('systemAvoidAreaChange')<sup>(deprecated)</sup>

on(type: 'systemAvoidAreaChange', callback: Callback&lt;AvoidArea&gt;): void
W
wusongqing 已提交
5790

5791
Enables listening for changes to the area where the window cannot be displayed.
W
wusongqing 已提交
5792

5793 5794 5795
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. Use [on('avoidAreaChange')](#onavoidareachange9) instead.
W
wusongqing 已提交
5796 5797 5798

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

W
wusongqing 已提交
5799
**Parameters**
W
wusongqing 已提交
5800

5801 5802 5803 5804
| 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 已提交
5805

W
wusongqing 已提交
5806
**Example**
W
wusongqing 已提交
5807

5808
```js
5809 5810
windowClass.on('systemAvoidAreaChange', (data) => {
    console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
5811 5812
});
```
W
wusongqing 已提交
5813

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

5816
off(type: 'systemAvoidAreaChange', callback?: Callback&lt;AvoidArea&gt;): void
W
wusongqing 已提交
5817

5818 5819 5820 5821 5822
Disables listening for changes to the area where the window cannot be displayed.

> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. Use [off('avoidAreaChange')](#offavoidareachange9) instead.
W
wusongqing 已提交
5823 5824 5825

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

W
wusongqing 已提交
5826
**Parameters**
W
wusongqing 已提交
5827

5828 5829 5830 5831
| 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 已提交
5832

W
wusongqing 已提交
5833
**Example**
W
wusongqing 已提交
5834

5835
```js
5836
windowClass.off('systemAvoidAreaChange');
5837
```
W
wusongqing 已提交
5838

5839
### isSupportWideGamut<sup>(deprecated)</sup>
W
wusongqing 已提交
5840

5841
isSupportWideGamut(callback: AsyncCallback&lt;boolean&gt;): void
W
wusongqing 已提交
5842

5843 5844 5845 5846 5847
Checks whether this window supports the wide-gamut color space. This API uses an asynchronous callback to return the result.

> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [isWindowSupportWideGamut()](#iswindowsupportwidegamut9) instead.
W
wusongqing 已提交
5848 5849 5850

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

W
wusongqing 已提交
5851
**Parameters**
W
wusongqing 已提交
5852

5853 5854 5855
| Name     | Type                         | Mandatory | Description                                                  |
| -------- | ---------------------------- | --------- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | Yes       | Callback used to return the result. The value **true** means that the wide-gamut color space is supported, and **false** means the opposite. |
5856 5857 5858 5859

**Example**

```js
5860
windowClass.isSupportWideGamut((err, data) => {
5861
    if (err.code) {
5862
        console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err));
5863 5864
        return;
    }
5865
    console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
5866
});
5867
```
5868

5869
### isSupportWideGamut<sup>(deprecated)</sup>
5870

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

5873
Checks whether this window supports the wide-gamut color space. This API uses a promise to return the result.
5874

5875 5876 5877
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [isWindowSupportWideGamut()](#iswindowsupportwidegamut9-1) instead.
5878

5879
**System capability**: SystemCapability.WindowManager.WindowManager.Core
5880 5881 5882

**Return value**

5883 5884 5885
| Type                   | Description                                                  |
| ---------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means that the wide-gamut color space is supported, and **false** means the opposite. |
W
wusongqing 已提交
5886

W
wusongqing 已提交
5887
**Example**
W
wusongqing 已提交
5888

5889
```js
5890 5891 5892
let promise = windowClass.isSupportWideGamut();
promise.then((data)=> {
    console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
5893
}).catch((err)=>{
5894
    console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
5895 5896
});
```
W
wusongqing 已提交
5897

5898
### setColorSpace<sup>(deprecated)</sup>
W
wusongqing 已提交
5899

5900
setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
5901

5902
Sets a color space for this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
5903

W
wusongqing 已提交
5904
> **NOTE**
5905
>
5906
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [setWindowColorSpace()](#setwindowcolorspace9) instead.
W
wusongqing 已提交
5907 5908 5909 5910 5911

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

**Parameters**

G
Gloria 已提交
5912 5913
| Name       | Type                       | Mandatory | Description                         |
| ---------- | -------------------------- | --------- | ----------------------------------- |
G
ge-yafang 已提交
5914
| colorSpace | [ColorSpace](#colorspace8) | Yes       | Color space to set.                 |
G
Gloria 已提交
5915
| callback   | AsyncCallback&lt;void&gt;  | Yes       | Callback used to return the result. |
W
wusongqing 已提交
5916 5917 5918

**Example**

5919
```js
5920
windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => {
5921
    if (err.code) {
5922
        console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err));
5923 5924
        return;
    }
5925
    console.info('Succeeded in setting window colorspace.');
5926
});
5927
```
W
wusongqing 已提交
5928

5929
### setColorSpace<sup>(deprecated)</sup>
W
wusongqing 已提交
5930

5931
setColorSpace(colorSpace:ColorSpace): Promise&lt;void&gt;
W
wusongqing 已提交
5932

5933
Sets a color space for this window. This API uses a promise to return the result.
W
wusongqing 已提交
5934

W
wusongqing 已提交
5935
> **NOTE**
5936
>
5937
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [setWindowColorSpace()](#setwindowcolorspace9-1) instead.
W
wusongqing 已提交
5938 5939 5940 5941 5942

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

**Parameters**

G
Gloria 已提交
5943 5944
| Name       | Type                       | Mandatory | Description         |
| ---------- | -------------------------- | --------- | ------------------- |
G
ge-yafang 已提交
5945
| colorSpace | [ColorSpace](#colorspace8) | Yes       | Color space to set. |
W
wusongqing 已提交
5946 5947 5948

**Return value**

5949 5950 5951
| Type                | Description                    |
| ------------------- | ------------------------------ |
| Promise&lt;void&gt; | Promise that returns no value. |
W
wusongqing 已提交
5952 5953 5954

**Example**

5955
```js
5956 5957 5958
let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT);
promise.then(()=> {
    console.info('Succeeded in setting window colorspace.');
5959
}).catch((err)=>{
5960
    console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
5961 5962
});
```
W
wusongqing 已提交
5963

5964
### getColorSpace<sup>(deprecated)</sup>
W
wusongqing 已提交
5965

5966
getColorSpace(callback: AsyncCallback&lt;ColorSpace&gt;): void
W
wusongqing 已提交
5967

5968 5969 5970 5971 5972
Obtains the color space of this window. This API uses an asynchronous callback to return the result.

> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getWindowColorSpace()](#getwindowcolorspace9) instead.
W
wusongqing 已提交
5973 5974 5975

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

W
wusongqing 已提交
5976
**Parameters**
W
wusongqing 已提交
5977

G
Gloria 已提交
5978 5979
| Name     | Type                                            | Mandatory | Description                                                  |
| -------- | ----------------------------------------------- | --------- | ------------------------------------------------------------ |
G
ge-yafang 已提交
5980
| callback | AsyncCallback&lt;[ColorSpace](#colorspace8)&gt; | Yes       | Callback used to return the result. When the color space is obtained successfully, **err** is **undefined**, and **data** is the current color space. |
W
wusongqing 已提交
5981

W
wusongqing 已提交
5982
**Example**
W
wusongqing 已提交
5983

5984
```js
5985
windowClass.getColorSpace((err, data) => {
5986
    if (err.code) {
5987
        console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err));
5988 5989
        return;
    }
5990
    console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data));
5991
});
5992
```
W
wusongqing 已提交
5993

5994
### getColorSpace<sup>(deprecated)</sup>
W
wusongqing 已提交
5995

5996
getColorSpace(): Promise&lt;ColorSpace&gt;
W
wusongqing 已提交
5997

5998
Obtains the color space of this window. This API uses a promise to return the result.
W
wusongqing 已提交
5999

6000 6001 6002
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getWindowColorSpace()](#getwindowcolorspace9) instead.
W
wusongqing 已提交
6003

6004
**System capability**: SystemCapability.WindowManager.WindowManager.Core
W
wusongqing 已提交
6005

W
wusongqing 已提交
6006
**Return value**
W
wusongqing 已提交
6007

G
Gloria 已提交
6008 6009
| Type                                      | Description                                     |
| ----------------------------------------- | ----------------------------------------------- |
G
ge-yafang 已提交
6010
| Promise&lt;[ColorSpace](#colorspace8)&gt; | Promise used to return the current color space. |
W
wusongqing 已提交
6011

W
wusongqing 已提交
6012
**Example**
W
wusongqing 已提交
6013

6014
```js
6015
let promise = windowClass.getColorSpace();
6016
promise.then((data)=> {
6017
    console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data));
6018
}).catch((err)=>{
6019
    console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err));
6020
});
6021 6022
```

6023
### setBackgroundColor<sup>(deprecated)</sup>
W
wusongqing 已提交
6024

6025
setBackgroundColor(color: string, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
6026

6027 6028 6029 6030 6031
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) or [setUIContent()](#setuicontent9).

> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowBackgroundColor()](#setwindowbackgroundcolor9) instead.
W
wusongqing 已提交
6032 6033 6034

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

W
wusongqing 已提交
6035
**Parameters**
W
wusongqing 已提交
6036

6037 6038
| Name     | Type                      | Mandatory | Description                                                  |
| -------- | ------------------------- | --------- | ------------------------------------------------------------ |
G
Gloria 已提交
6039
| color    | string                    | Yes       | Background color to set. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**. |
6040
| callback | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result.                          |
W
wusongqing 已提交
6041

W
wusongqing 已提交
6042
**Example**
W
wusongqing 已提交
6043

6044
```js
6045 6046
let color = '#00ff33';
windowClass.setBackgroundColor(color, (err) => {
6047
    if (err.code) {
6048
        console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
6049 6050
        return;
    }
6051
    console.info('Succeeded in setting the background color.');
6052 6053
});
```
W
wusongqing 已提交
6054

6055
### setBackgroundColor<sup>(deprecated)</sup>
W
wusongqing 已提交
6056

6057
setBackgroundColor(color: string): Promise&lt;void&gt;
W
wusongqing 已提交
6058

6059 6060 6061 6062 6063
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) or [setUIContent()](#setuicontent9).

> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowBackgroundColor()](#setwindowbackgroundcolor9) instead.
W
wusongqing 已提交
6064 6065 6066

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

W
wusongqing 已提交
6067
**Parameters**
W
wusongqing 已提交
6068

6069 6070
| Name  | Type   | Mandatory | Description                                                  |
| ----- | ------ | --------- | ------------------------------------------------------------ |
G
Gloria 已提交
6071
| color | string | Yes       | Background color to set. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**. |
W
wusongqing 已提交
6072

W
wusongqing 已提交
6073
**Return value**
W
wusongqing 已提交
6074

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

W
wusongqing 已提交
6079
**Example**
W
wusongqing 已提交
6080

6081
```js
6082 6083 6084 6085
let color = '#00ff33';
let promise = windowClass.setBackgroundColor(color);
promise.then(()=> {
    console.info('Succeeded in setting the background color.');
6086
}).catch((err)=>{
6087
    console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
6088 6089 6090
});
```

6091
### setBrightness<sup>(deprecated)</sup>
6092

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

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

6097 6098 6099
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowBrightness()](#setwindowbrightness9) instead.
6100 6101 6102 6103 6104

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

**Parameters**

6105 6106 6107 6108
| 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.                          |
6109 6110 6111 6112

**Example**

```js
6113 6114
let brightness = 1;
windowClass.setBrightness(brightness, (err) => {
6115
    if (err.code) {
6116
        console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
6117 6118
        return;
    }
6119
    console.info('Succeeded in setting the brightness.');
6120 6121 6122
});
```

6123
### setBrightness<sup>(deprecated)</sup>
6124

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

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

6129 6130 6131
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowBrightness()](#setwindowbrightness9-1) instead.
6132 6133 6134 6135 6136

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

**Parameters**

6137 6138 6139
| Name       | Type   | Mandatory | Description                                                  |
| ---------- | ------ | --------- | ------------------------------------------------------------ |
| brightness | number | Yes       | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest. |
6140 6141 6142

**Return value**

6143 6144 6145
| Type                | Description                    |
| ------------------- | ------------------------------ |
| Promise&lt;void&gt; | Promise that returns no value. |
6146 6147 6148 6149

**Example**

```js
6150 6151 6152 6153
let brightness = 1;
let promise = windowClass.setBrightness(brightness);
promise.then(()=> {
    console.info('Succeeded in setting the brightness.');
6154
}).catch((err)=>{
6155
    console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
6156 6157
});
```
W
wusongqing 已提交
6158

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

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

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

> **NOTE**
>
> This API cannot be used. This API is supported since API version 7 and deprecated since API version 9.
6168 6169 6170 6171 6172

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

**Parameters**

6173 6174 6175 6176
| Name           | Type                      | Mandatory | Description                                                  |
| -------------- | ------------------------- | --------- | ------------------------------------------------------------ |
| 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.                          |
6177 6178 6179 6180

**Example**

```js
6181
windowClass.setDimBehind(0.5, (err) => {
6182
    if (err.code) {
6183
        console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
6184 6185
        return;
    }
6186
    console.info('Succeeded in setting the dimness.');
6187 6188 6189
});
```

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

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

6194 6195 6196 6197 6198
Sets the dimness of the window that is not on top. This API uses a promise to return the result.

> **NOTE**
>
> This API cannot be used. This API is supported since API version 7 and deprecated since API version 9.
6199 6200 6201

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

6202 6203 6204 6205 6206 6207
**Parameters**

| Name           | Type   | Mandatory | Description                                                  |
| -------------- | ------ | --------- | ------------------------------------------------------------ |
| dimBehindValue | number | Yes       | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest. |

6208 6209
**Return value**

6210 6211 6212
| Type                | Description                    |
| ------------------- | ------------------------------ |
| Promise&lt;void&gt; | Promise that returns no value. |
6213 6214 6215 6216

**Example**

```js
6217 6218 6219
let promise = windowClass.setDimBehind(0.5);
promise.then(()=> {
    console.info('Succeeded in setting the dimness.');
6220
}).catch((err)=>{
6221
    console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
6222 6223 6224
});
```

6225
### setFocusable<sup>(deprecated)</sup>
6226

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

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

6231 6232 6233
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowFocusable()](#setwindowfocusable9) instead.
6234 6235 6236 6237 6238

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

**Parameters**

6239 6240 6241 6242
| Name        | Type                      | Mandatory | Description                                                  |
| ----------- | ------------------------- | --------- | ------------------------------------------------------------ |
| isFocusable | boolean                   | Yes       | Whether the window can gain focus. The value **true** means that the window can gain focus, and **false** means the opposite. |
| callback    | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result.                          |
6243 6244 6245 6246

**Example**

```js
6247 6248 6249 6250 6251 6252 6253 6254
let isFocusable= true;
windowClass.setFocusable(isFocusable, (err) => {
    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.');
});
6255 6256
```

6257
### setFocusable<sup>(deprecated)</sup>
6258

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

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

6263 6264 6265
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowFocusable()](#setwindowfocusable9-1) instead.
6266 6267 6268 6269 6270

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

**Parameters**

6271 6272 6273 6274 6275 6276 6277 6278 6279
| Name        | Type    | Mandatory | Description                                                  |
| ----------- | ------- | --------- | ------------------------------------------------------------ |
| isFocusable | boolean | Yes       | Whether the window can gain focus. The value **true** means that the window can gain focus, and **false** means the opposite. |

**Return value**

| Type                | Description                    |
| ------------------- | ------------------------------ |
| Promise&lt;void&gt; | Promise that returns no value. |
6280 6281 6282 6283

**Example**

```js
6284 6285 6286 6287 6288 6289 6290
let isFocusable= true;
let promise = windowClass.setFocusable(isFocusable);
promise.then(()=> {
    console.info('Succeeded in setting the window to be focusable.');
}).catch((err)=>{
    console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
});
6291 6292
```

6293
### setKeepScreenOn<sup>(deprecated)</sup>
6294

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

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

6299 6300 6301
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowKeepScreenOn()](#setwindowkeepscreenon9) instead.
6302 6303 6304 6305 6306

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

**Parameters**

6307 6308 6309 6310
| Name           | Type                      | Mandatory | Description                                                  |
| -------------- | ------------------------- | --------- | ------------------------------------------------------------ |
| isKeepScreenOn | boolean                   | Yes       | Whether to keep the screen always on. The value **true** means to keep the screen always on, and **false** means the opposite. |
| callback       | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result.                          |
6311 6312 6313 6314

**Example**

```js
6315 6316 6317 6318 6319 6320 6321 6322
let isKeepScreenOn = true;
windowClass.setKeepScreenOn(isKeepScreenOn, (err) => {
    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.');
});
6323 6324
```

6325
### setKeepScreenOn<sup>(deprecated)</sup>
6326

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

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

6331 6332 6333
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowKeepScreenOn()](#setwindowkeepscreenon9-1) instead.
6334 6335 6336 6337 6338

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

**Parameters**

6339 6340 6341 6342 6343 6344 6345 6346 6347
| Name           | Type    | Mandatory | Description                                                  |
| -------------- | ------- | --------- | ------------------------------------------------------------ |
| isKeepScreenOn | boolean | Yes       | Whether to keep the screen always on. The value **true** means to keep the screen always on, and **false** means the opposite. |

**Return value**

| Type                | Description                    |
| ------------------- | ------------------------------ |
| Promise&lt;void&gt; | Promise that returns no value. |
6348 6349 6350 6351

**Example**

```js
6352 6353 6354 6355 6356 6357 6358
let isKeepScreenOn = true;
let promise = windowClass.setKeepScreenOn(isKeepScreenOn);
promise.then(() => {
    console.info('Succeeded in setting the screen to be always on.');
}).catch((err)=>{
    console.info('Failed to set the screen to be always on. Cause:  ' + JSON.stringify(err));
});
6359 6360
```

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

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

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

6367 6368 6369
> **NOTE**
>
> This API cannot be used. This API is supported since API version 7 and deprecated since API version 9.
6370 6371 6372 6373 6374

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

**Parameters**

6375 6376 6377 6378
| Name      | Type                      | Mandatory | Description                                                  |
| --------- | ------------------------- | --------- | ------------------------------------------------------------ |
| touchable | boolean                   | Yes       | Whether the area outside the subwindow is touchable. The value **true** means the area outside the subwindow is touchable, and **false** means the opposite. |
| callback  | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result.                          |
6379 6380 6381 6382

**Example**

```js
6383 6384 6385 6386 6387 6388
windowClass.setOutsideTouchable(true, (err) => {
    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.');
6389
});
6390 6391
```

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

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

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

6398 6399 6400
> **NOTE**
>
> This API cannot be used. This API is supported since API version 7 and deprecated since API version 9.
6401 6402 6403 6404 6405

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

**Parameters**

6406 6407 6408 6409 6410 6411 6412 6413 6414
| Name      | Type    | Mandatory | Description                                                  |
| --------- | ------- | --------- | ------------------------------------------------------------ |
| touchable | boolean | Yes       | Whether the area outside the subwindow is touchable. The value **true** means the area outside the subwindow is touchable, and **false** means the opposite. |

**Return value**

| Type                | Description                    |
| ------------------- | ------------------------------ |
| Promise&lt;void&gt; | Promise that returns no value. |
6415 6416 6417 6418

**Example**

```js
6419 6420 6421 6422 6423 6424
let promise = windowClass.setOutsideTouchable(true);
promise.then(()=> {
    console.info('Succeeded in setting the area to be touchable.');
}).catch((err)=>{
    console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
});
6425 6426
```

6427
### setPrivacyMode<sup>(deprecated)</sup>
6428

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

6431
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.
6432

6433 6434 6435
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowPrivacyMode()](#setwindowprivacymode9) instead.
6436 6437 6438 6439 6440

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

**Parameters**

6441 6442 6443 6444
| Name          | Type                      | Mandatory | Description                                                  |
| ------------- | ------------------------- | --------- | ------------------------------------------------------------ |
| isPrivacyMode | boolean                   | Yes       | Whether the window is in privacy mode. The value **true** means that the window is in privacy mode, and **false** means the opposite. |
| callback      | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result.                          |
6445 6446 6447 6448

**Example**

```js
6449 6450 6451 6452 6453 6454 6455 6456
let isPrivacyMode = true;
windowClass.setPrivacyMode(isPrivacyMode, (err) => {
    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.');
});
6457 6458
```

6459
### setPrivacyMode<sup>(deprecated)</sup>
6460

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

6463
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.
6464

6465 6466 6467
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowPrivacyMode()](#setwindowprivacymode9-1) instead.
6468 6469 6470 6471 6472

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

**Parameters**

6473 6474 6475 6476 6477 6478 6479 6480 6481
| Name          | Type    | Mandatory | Description                                                  |
| ------------- | ------- | --------- | ------------------------------------------------------------ |
| isPrivacyMode | boolean | Yes       | Whether the window is in privacy mode. The value **true** means that the window is in privacy mode, and **false** means the opposite. |

**Return value**

| Type                | Description                    |
| ------------------- | ------------------------------ |
| Promise&lt;void&gt; | Promise that returns no value. |
6482 6483 6484 6485

**Example**

```js
6486 6487 6488 6489 6490 6491 6492
let isPrivacyMode = true;
let promise = windowClass.setPrivacyMode(isPrivacyMode);
promise.then(()=> {
    console.info('Succeeded in setting the window to privacy mode.');
}).catch((err)=>{
    console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
});
6493 6494
```

6495
### setTouchable<sup>(deprecated)</sup>
6496

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

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

6501 6502 6503
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowTouchable()](#setwindowtouchable9) instead.
6504 6505 6506 6507 6508

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

**Parameters**

6509 6510 6511 6512
| Name        | Type                      | Mandatory | Description                                                  |
| ----------- | ------------------------- | --------- | ------------------------------------------------------------ |
| isTouchable | boolean                   | Yes       | Whether the window is touchable. The value **true** means that the window is touchable, and **false** means the opposite. |
| callback    | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result.                          |
6513 6514 6515 6516

**Example**

```js
6517 6518 6519 6520 6521 6522 6523 6524
let isTouchable = true;
windowClass.setTouchable(isTouchable, (err) => {
    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.');
});
6525 6526
```

6527
### setTouchable<sup>(deprecated)</sup>
6528

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

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

6533 6534 6535
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowTouchable()](#setwindowtouchable9-1) instead.
6536 6537 6538

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

6539 6540 6541 6542 6543 6544
**Parameters**

| Name        | Type    | Mandatory | Description                                                  |
| ----------- | ------- | --------- | ------------------------------------------------------------ |
| isTouchable | boolean | Yes       | Whether the window is touchable. The value **true** means that the window is touchable, and **false** means the opposite. |

6545 6546
**Return value**

6547 6548 6549
| Type                | Description                    |
| ------------------- | ------------------------------ |
| Promise&lt;void&gt; | Promise that returns no value. |
6550 6551 6552 6553

**Example**

```js
6554 6555 6556 6557 6558 6559 6560
let isTouchable = true;
let promise = windowClass.setTouchable(isTouchable);
promise.then(()=> {
    console.info('Succeeded in setting the window to be touchable.');
}).catch((err)=>{
    console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
});
6561 6562
```

W
wusongqing 已提交
6563
## WindowStageEventType<sup>9+</sup>
W
wusongqing 已提交
6564 6565 6566

Describes the lifecycle of a window stage.

6567
**Model restriction**: This API can be used only in the stage model.
6568

W
wusongqing 已提交
6569 6570
**System capability**: SystemCapability.WindowManager.WindowManager.Core

6571 6572 6573 6574 6575 6576
| Name     | Value | Description                                    |
| -------- | ----- | ---------------------------------------------- |
| SHOWN    | 1     | The window stage is running in the foreground. |
| ACTIVE   | 2     | The window stage gains focus.                  |
| INACTIVE | 3     | The window stage loses focus.                  |
| HIDDEN   | 4     | The window stage is running in the background. |
W
wusongqing 已提交
6577 6578 6579

## WindowStage<sup>9+</sup>

6580 6581
Implements a window manager, which manages each basic window unit, that is, [Window](#window) instance.

6582
Before calling any of the following APIs, you must use [onWindowStageCreate()](js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate) to create a **WindowStage** instance.
6583 6584 6585 6586 6587 6588 6589

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

6590
**Model restriction**: This API can be used only in the stage model.
6591 6592 6593 6594 6595

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

**Parameters**

6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607
| Name     | Type                                   | Mandatory | Description                              |
| -------- | -------------------------------------- | --------- | ---------------------------------------- |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes       | Callback used to return the main window. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
6608 6609

**Example**
W
wusongqing 已提交
6610

6611
```ts
6612 6613 6614 6615
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
6616

6617 6618
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6619
        let windowClass = null;
6620 6621 6622 6623 6624 6625 6626 6627 6628
        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));
        });
    }
6629
};
6630
```
6631

W
wusongqing 已提交
6632 6633 6634 6635 6636 6637
### 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.

6638
**Model restriction**: This API can be used only in the stage model.
6639

W
wusongqing 已提交
6640 6641
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
6642
**Return value**
W
wusongqing 已提交
6643

6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655
| Type                             | Description                             |
| -------------------------------- | --------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the main window. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
6656

W
wusongqing 已提交
6657
**Example**
W
wusongqing 已提交
6658

6659
```ts
6660 6661 6662 6663
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
6664

6665 6666
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6667
        let windowClass = null;
6668
        let promise = windowStage.getMainWindow();
6669
        promise.then((data) => {
6670 6671
        windowClass = data;
            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
6672
        }).catch((err) => {
6673 6674 6675
            console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
        });
    }
6676
};
6677
```
6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706

### getMainWindowSync<sup>9+</sup>

getMainWindowSync(): Window

Obtains the main window of this window stage.

**Model restriction**: This API can be used only in the stage model.

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

**Return value**

| Type              | Description             |
| ----------------- | ----------------------- |
| [Window](#window) | return the main window. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |

**Example**

```ts
6707 6708 6709 6710
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
6711

6712 6713 6714 6715 6716 6717 6718 6719
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        try {
            let windowClass = windowStage.getMainWindowSync();
        } catch (exception) {
            console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception));
        };
    }
6720
};
6721 6722
```

6723
### createSubWindow<sup>9+</sup>
W
wusongqing 已提交
6724

6725
createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void
W
wusongqing 已提交
6726

6727
Creates a subwindow for this window stage. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
6728

6729
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
6730 6731 6732

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

W
wusongqing 已提交
6733
**Parameters**
W
wusongqing 已提交
6734

6735 6736
| Name     | Type                                   | Mandatory | Description                            |
| -------- | -------------------------------------- | --------- | -------------------------------------- |
6737
| name     | string                                 | Yes       | Name of the subwindow.                 |
6738 6739 6740 6741 6742 6743 6744 6745 6746 6747
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes       | Callback used to return the subwindow. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
6748

W
wusongqing 已提交
6749
**Example**
W
wusongqing 已提交
6750

6751
```ts
6752 6753 6754 6755
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
6756

6757 6758
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6759
        let windowClass = null;
6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772
        try {
            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);
            });
        } catch (exception) {
            console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
        };
6773
    }
6774
};
6775
```
W
wusongqing 已提交
6776 6777 6778 6779 6780 6781
### 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.

6782
**Model restriction**: This API can be used only in the stage model.
6783

W
wusongqing 已提交
6784
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
6785

W
wusongqing 已提交
6786
**Parameters**
W
wusongqing 已提交
6787

6788 6789
| Name | Type   | Mandatory | Description            |
| ---- | ------ | --------- | ---------------------- |
6790
| name | string | Yes       | Name of the subwindow. |
G
ge-yafang 已提交
6791

W
wusongqing 已提交
6792
**Return value**
W
wusongqing 已提交
6793

6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805
| Type                             | Description                           |
| -------------------------------- | ------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
G
ge-yafang 已提交
6806

W
wusongqing 已提交
6807
**Example**
W
wusongqing 已提交
6808

6809
```ts
6810 6811 6812 6813
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
6814

6815 6816
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6817
        let windowClass = null;
6818 6819
        try {
            let promise = windowStage.createSubWindow('mySubWindow');
6820
            promise.then((data) => {
6821 6822
                windowClass = data;
                console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
6823
            }).catch((err) => {
6824 6825 6826 6827 6828
                console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
            });
        } catch (exception) {
            console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
        };
6829
    }
6830
};
6831
```
6832

6833
### getSubWindow<sup>9+</sup>
W
wusongqing 已提交
6834

6835
getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void
W
wusongqing 已提交
6836

6837
Obtains all the subwindows of this window stage. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
6838

6839
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
6840 6841 6842

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

W
wusongqing 已提交
6843
**Parameters**
W
wusongqing 已提交
6844

6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855
| Name     | Type                                                | Mandatory | Description                                 |
| -------- | --------------------------------------------------- | --------- | ------------------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[Window](#window)&gt;&gt; | Yes       | Callback used to return all the subwindows. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
6856

W
wusongqing 已提交
6857
**Example**
W
wusongqing 已提交
6858

6859
```ts
6860 6861 6862 6863
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
6864

6865 6866
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6867
        let windowClass = null;
6868 6869 6870 6871 6872 6873 6874 6875 6876
        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));
        });
    }
6877
};
6878
```
W
wusongqing 已提交
6879 6880 6881 6882 6883 6884
### 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.

6885
**Model restriction**: This API can be used only in the stage model.
6886

W
wusongqing 已提交
6887
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
6888

W
wusongqing 已提交
6889
**Return value**
W
wusongqing 已提交
6890

6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901
| Type                                          | Description                                |
| --------------------------------------------- | ------------------------------------------ |
| Promise&lt;Array&lt;[Window](#window)&gt;&gt; | Promise used to return all the subwindows. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
6902

W
wusongqing 已提交
6903
**Example**
W
wusongqing 已提交
6904

6905
```ts
6906 6907 6908 6909
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
6910

6911 6912
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6913
        let windowClass = null;
6914
        let promise = windowStage.getSubWindow();
6915
        promise.then((data) => {
6916 6917
            windowClass = data;
            console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
6918
        }).catch((err) => {
6919 6920 6921
            console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
        })
    }
6922
};
6923 6924
```
### loadContent<sup>9+</sup>
W
wusongqing 已提交
6925

6926
loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
6927

6928
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 已提交
6929

6930
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
6931 6932

**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
6933

W
wusongqing 已提交
6934
**Parameters**
W
wusongqing 已提交
6935

G
Gloria 已提交
6936 6937 6938 6939 6940
| Name     | Type                                                    | Mandatory | Description                                                  |
| -------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
| path     | string                                                  | Yes       | Path of the page from which the content will be loaded.      |
| storage  | [LocalStorage](../../quick-start/arkts-localstorage.md) | Yes       | A storage unit, which provides storage for variable state properties and non-variable state properties of an application. |
| callback | AsyncCallback&lt;void&gt;                               | Yes       | Callback used to return the result.                          |
6941 6942 6943 6944 6945 6946 6947 6948 6949

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
6950

W
wusongqing 已提交
6951
**Example**
W
wusongqing 已提交
6952

6953
```ts
6954 6955 6956 6957
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
6958

6959
    storage : LocalStorage
6960 6961
    onWindowStageCreate(windowStage) {
        this.storage = new LocalStorage();
6962
        this.storage.setOrCreate('storageSimpleProp',121);
6963
        console.log('onWindowStageCreate');
6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974
        try {
            windowStage.loadContent('pages/page2',this.storage,(err) => {
                if (err.code) {
                    console.error('Failed to load the content. Cause:' + JSON.stringify(err));
                    return;
                }
                console.info('Succeeded in loading the content.');
            });
        } catch (exception) {
            console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
        };
6975
    }
6976
};
6977 6978 6979 6980 6981 6982 6983 6984
```

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

6985
**Model restriction**: This API can be used only in the stage model.
6986 6987 6988 6989 6990

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

**Parameters**

G
Gloria 已提交
6991 6992 6993 6994
| Name    | Type                                                    | Mandatory | Description                                                  |
| ------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------ |
| path    | string                                                  | Yes       | Path of the page from which the content will be loaded.      |
| storage | [LocalStorage](../../quick-start/arkts-localstorage.md) | No        | A storage unit, which provides storage for variable state properties and non-variable state properties of an application. |
6995 6996 6997

**Return value**

6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009
| Type                | Description                    |
| ------------------- | ------------------------------ |
| Promise&lt;void&gt; | Promise that returns no value. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
7010 7011 7012 7013

**Example**

```ts
7014 7015 7016 7017
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
7018

7019
    storage : LocalStorage
7020 7021
    onWindowStageCreate(windowStage) {
        this.storage = new LocalStorage();
7022
        this.storage.setOrCreate('storageSimpleProp',121);
7023
        console.log('onWindowStageCreate');
7024 7025
        try {
            let promise = windowStage.loadContent('pages/page2',this.storage);
7026
            promise.then(() => {
7027
                console.info('Succeeded in loading the content.');
7028
            }).catch((err) => {
7029 7030 7031 7032 7033
                console.error('Failed to load the content. Cause:' + JSON.stringify(err));
            });
        } catch (exception) {
            console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
        };
7034
    }
7035
};
7036
```
W
wusongqing 已提交
7037 7038 7039 7040 7041

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

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

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

7044
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
7045

7046
**System capability**: SystemCapability.WindowManager.WindowManager.Core
W
wusongqing 已提交
7047

W
wusongqing 已提交
7048
**Parameters**
W
wusongqing 已提交
7049

7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062
| Name     | Type                      | Mandatory | Description                                             |
| -------- | ------------------------- | --------- | ------------------------------------------------------- |
| path     | string                    | Yes       | Path of the page from which the content will be loaded. |
| callback | AsyncCallback&lt;void&gt; | Yes       | Callback used to return the result.                     |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
7063 7064 7065 7066

**Example**

```ts
7067 7068 7069 7070
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
7071

7072 7073
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084
        try {
            windowStage.loadContent('pages/page2', (err) => {
                if (err.code) {
                    console.error('Failed to load the content. Cause:' + JSON.stringify(err));
                    return;
                }
                console.info('Succeeded in loading the content.');
            });
        } catch (exception) {
            console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
        };
7085
    }
7086
};
7087
```
G
ge-yafang 已提交
7088

W
wusongqing 已提交
7089 7090 7091 7092 7093 7094
### on('windowStageEvent')<sup>9+</sup>

on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void

Enables listening for window stage lifecycle changes.

7095
**Model restriction**: This API can be used only in the stage model.
7096

W
wusongqing 已提交
7097
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
7098

W
wusongqing 已提交
7099
**Parameters**
W
wusongqing 已提交
7100

7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113
| Name     | Type                                                         | Mandatory | Description                                                  |
| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
| 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.    |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
7114

W
wusongqing 已提交
7115
**Example**
W
wusongqing 已提交
7116

7117
```ts
7118 7119 7120 7121
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
7122

7123 7124
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
7125 7126 7127 7128 7129 7130 7131 7132 7133
        try {
            windowStage.on('windowStageEvent', (data) => {
                console.info('Succeeded in enabling the listener for window stage event changes. Data: ' +
                    JSON.stringify(data));
            });
        } catch (exception) {
            console.error('Failed to enable the listener for window stage event changes. Cause:' +
                JSON.stringify(exception));
        };
7134
    }
7135
};
7136
```
W
wusongqing 已提交
7137 7138 7139 7140 7141 7142 7143

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

off(eventType: 'windowStageEvent', callback?: Callback&lt;WindowStageEventType&gt;): void

Disables listening for window stage lifecycle changes.

7144
**Model restriction**: This API can be used only in the stage model.
7145

W
wusongqing 已提交
7146
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
7147

W
wusongqing 已提交
7148
**Parameters**
W
wusongqing 已提交
7149

7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162
| Name     | Type                                                         | Mandatory | Description                                                  |
| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
| 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.    |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
G
ge-yafang 已提交
7163

W
wusongqing 已提交
7164
**Example**
W
wusongqing 已提交
7165

7166
```ts
7167 7168 7169 7170
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
7171

7172 7173
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
7174 7175 7176 7177 7178 7179
        try {
            windowStage.off('windowStageEvent');
        } catch (exception) {
            console.error('Failed to disable the listener for window stage event changes. Cause:' +
                JSON.stringify(exception));
        };
7180
    }
7181
};
7182 7183 7184 7185 7186 7187 7188
```

### disableWindowDecor()<sup>9+</sup>

disableWindowDecor(): void

Disables window decorators.
W
wusongqing 已提交
7189

7190
**Model restriction**: This API can be used only in the stage model.
7191

7192
**System API**: This is a system API.
7193 7194 7195

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

7196 7197 7198 7199 7200 7201 7202 7203 7204
**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |

7205 7206 7207
**Example**

```ts
7208 7209 7210 7211
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
7212

7213 7214 7215 7216
    onWindowStageCreate(windowStage) {
        console.log('disableWindowDecor');
        windowStage.disableWindowDecor();
    }
7217
};
7218 7219 7220
```

### setShowOnLockScreen()<sup>9+</sup>
W
wusongqing 已提交
7221 7222 7223 7224 7225

setShowOnLockScreen(showOnLockScreen: boolean): void

Sets whether to display the window of the application on the lock screen.

7226 7227 7228
**System API**: This is a system API.

**Model restriction**: This API can be used only in the stage model.
7229

W
wusongqing 已提交
7230 7231 7232 7233
**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245
| Name             | Type    | Mandatory | Description                                                  |
| ---------------- | ------- | --------- | ------------------------------------------------------------ |
| showOnLockScreen | boolean | Yes       | Whether to display the window on the lock screen. The value **true** means to display the window on the lock screen, and **false** means the opposite. |

**Error codes**

For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).

| ID      | Error Message                  |
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
7246 7247 7248 7249

**Example**

```ts
7250 7251 7252 7253
import UIAbility from '@ohos.app.ability.UIAbility';

export default class EntryAbility extends UIAbility {
    // ...
7254

W
wusongqing 已提交
7255 7256
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
7257 7258 7259 7260 7261
        try {
            windowStage.setShowOnLockScreen(true);
        } catch (exception) {
            console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception));
        };
W
wusongqing 已提交
7262
    }
7263
};
W
wusongqing 已提交
7264
```
7265 7266 7267 7268
## TransitionContext<sup>9+</sup>

Provides the context for the transition animation.

7269
### Attributes
7270

7271
**System API**: This is a system API.
7272 7273 7274

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

7275 7276 7277
| Name                  | Type              | Readable | Writable | Description                             |
| --------------------- | ----------------- | -------- | -------- | --------------------------------------- |
| toWindow<sup>9+</sup> | [Window](#window) | Yes      | Yes      | Target window to display the animation. |
7278 7279 7280 7281 7282

### completeTransition<sup>9+</sup>

completeTransition(isCompleted: boolean): void

7283 7284 7285
Completes the transition. This API can be called only after [animateTo()](../arkui-ts/ts-explicit-animation.md) is executed.

**System API**: This is a system API.
7286 7287 7288 7289 7290

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

**Parameters**

7291 7292 7293
| 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. |
7294 7295 7296 7297 7298 7299

**Example**

```js
let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => {
7300
	let toWindow = context.toWindow;
7301 7302 7303 7304 7305 7306
 	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.
7307
        playMode: PlayMode.Normal // Animation playback mode.
7308
      }, () => {
7309
        let obj : window.TranslateOptions = {
7310 7311 7312
          x : 100.0,
          y : 0.0,
          z : 0.0
7313
        };
7314 7315 7316
        toWindow.translate(obj);
        console.info('toWindow translate end');
      }
7317
    );
7318 7319 7320 7321 7322
    try {
        context.completeTransition(true)
    } catch (exception) {
        console.info('toWindow translate fail. Cause: ' + JSON.stringify(exception));
    }
7323
    console.info('complete transition end');
7324
};
7325 7326 7327 7328 7329 7330 7331 7332 7333 7334
```

## TransitionController<sup>9+</sup>

Implements the transition animation controller.

### animationForShown<sup>9+</sup>

animationForShown(context: TransitionContext): void

7335 7336 7337
Customizes the animation for the scenario when the window is shown.

**System API**: This is a system API.
7338 7339 7340 7341 7342

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

**Parameters**

7343 7344 7345
| Name    | Type                                     | Mandatory | Description                          |
| ------- | ---------------------------------------- | --------- | ------------------------------------ |
| context | [TransitionContext](#transitioncontext9) | Yes       | Context of the transition animation. |
7346 7347 7348 7349 7350 7351

**Example**

```js
let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => {
7352
	let toWindow = context.toWindow;
7353 7354 7355 7356 7357 7358
 	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.
7359 7360 7361
        playMode: PlayMode.Normal // Animation playback mode.
        onFinish: ()=> {
            context.completeTransition(true)
7362
        }
7363
      }, () => {
7364
        let obj : window.TranslateOptions = {
7365 7366 7367
          x : 100.0,
          y : 0.0,
          z : 0.0
7368
        };
7369 7370 7371
        toWindow.translate(obj);
        console.info('toWindow translate end');
      }
7372
    );
7373
    console.info('complete transition end');
7374
};
7375 7376 7377 7378 7379 7380
```

### animationForHidden<sup>9+</sup>

animationForHidden(context: TransitionContext): void

7381 7382 7383
Customizes the animation for the scenario when the window is hidden.

**System API**: This is a system API.
7384 7385 7386 7387 7388

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

**Parameters**

7389 7390 7391
| Name    | Type                                     | Mandatory | Description                          |
| ------- | ---------------------------------------- | --------- | ------------------------------------ |
| context | [TransitionContext](#transitioncontext9) | Yes       | Context of the transition animation. |
7392 7393 7394 7395 7396 7397

**Example**

```js
let controller = windowClass.getTransitionController();
controller.animationForHidden = (context : window.TransitionContext) => {
7398
	let toWindow = context.toWindow;
7399 7400 7401 7402 7403 7404
 	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.
7405 7406 7407
        playMode: PlayMode.Normal // Animation playback mode.
        onFinish: ()=> {
            context.completeTransition(true)
7408
        }
7409
      }, () => {
7410
        let obj : window.TranslateOptions = {
7411 7412 7413
          x : 100.0,
          y : 0.0,
          z : 0.0
7414
        };
7415 7416 7417 7418 7419
        toWindow.translate(obj);
        console.info('toWindow translate end');
      }
    )
    console.info('complete transition end');
7420
};
G
Gloria 已提交
7421 7422 7423
```

 <!--no_check-->