js-apis-window.md 241.1 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>

49
Defines the parameters for creating a subwindow or system window.
50 51 52

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

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

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
| Name      | Type                                           | Readable| Writable| Description                        |
| ---------- | --------------------------------------------------- | ---- | ---- | ---------------------------- |
G
Gloria 已提交
180
| displayId  | number                                              | Yes  | No  | ID of the current physical screen. The value must be an integer.            |
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              |
| ------ | -------- | ---- | ---- | ------------------ |
G
Gloria 已提交
191 192 193 194
| left   | number   | Yes  | Yes  | Left boundary of the rectangle, in pixels. The value must be an integer.|
| top    | number   | Yes  | Yes  | Top boundary of the rectangle, in pixels. The value must be an integer.|
| width  | number   | Yes  | Yes  | Width of the rectangle, in pixels. The value must be an integer.|
| height | number   | Yes  | Yes  | Height of the rectangle, in pixels. The value must be an integer.|
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      |
| ------ | -------- | ---- | ---- | ---------- |
G
Gloria 已提交
218 219
| width  | number   | Yes  | Yes  | Window width, in pixels. The value must be an integer.|
| height | number   | Yes  | Yes  | Window height, in pixels. The value must be an integer.|
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

G
Gloria 已提交
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
| Name                                 | Type                 | Readable| Writable| Description                                                                                                    |
| ------------------------------------- | ------------------------- | ---- | ---- |--------------------------------------------------------------------------------------------------------|
| 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 is a floating point number in the range [0.0, 1.0], and the value **1.0** means the brightest. If no value is passed, the brightness follows the system. In this case, the obtained brightness value is **-1**.                     |
| dimBehindValue<sup>(deprecated)</sup> | number                    | Yes  | Yes  | Dimness of the window that is not on top. The value is a floating point number in the range [0.0, 1.0], and the value **1.0** means the dimmest.<br>**NOTE**<br>This property is supported since API version 7 and deprecated since API version 9. |
| 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.      |
| 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**. The value must be an integer.                                                                                   |
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
## ScaleOptions<sup>9+</sup>

Describes the scale parameters.

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

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

G
Gloria 已提交
262 263 264 265 266 267
| Name  | Type| Readable| Writable| Description                                        |
| ------ | -------- | ---- | ---- |--------------------------------------------|
| x      | number   | No  | Yes  | Scale factor along the x-axis. The value is a floating point number, and the default value is **1.0**.                  |
| y      | number   | No  | Yes  | Scale factor along the y-axis. The value is a floating point number, and the default value is **1.0**.                  |
| pivotX | number   | No  | Yes  | X coordinate of the scale center. The value is a floating point number in the range [0.0, 1.0], and the default value is **0.5**.|
| pivotY | number   | No  | Yes  | Y coordinate of the scale center. The value is a floating point number in the range [0.0, 1.0], and the default value is **0.5**.|
268 269 270 271 272 273 274 275 276

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

Describes the rotation parameters.

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

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

G
Gloria 已提交
277 278 279 280 281 282 283
| Name  | Type| Readable| Writable| Description                                         |
| ------ | -------- | ---- | ---- |---------------------------------------------|
| x      | number   | No  | Yes  | Rotation angle around the x-axis. The value is a floating point number, and the default value is **0.0**.                  |
| y      | number   | No  | Yes  | Rotation angle around the y-axis. The value is a floating point number, and the default value is **0.0**.                  |
| z      | number   | No  | Yes  | Rotation angle around the z-axis. The value is a floating point number, and the default value is **0.0**.                  |
| pivotX | number   | No  | Yes  | X coordinate of the rotation center. The value is a floating point number in the range [0.0, 1.0], and the default value is **0.5**.|
| pivotY | number   | No  | Yes  | Y coordinate of the rotation center. The value is a floating point number in the range [0.0, 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                        |
| ---- | -------- | ---- | ---- | ---------------------------- |
G
Gloria 已提交
295 296 297
| x    | number   | No  | Yes  | Distance to translate along the x-axis. The value is a floating point number, and the default value is **0.0**.|
| y    | number   | No  | Yes  | Distance to translate along the y-axis. The value is a floating point number, and the default value is **0.0**.|
| z    | number   | No  | Yes  | Distance to translate along the z-axis. The value is a floating point number, and the default value is **0.0**.|
298

299
## window.createWindow<sup>9+</sup>
W
wusongqing 已提交
300

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

303
Creates a subwindow or system window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
304 305 306

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

W
wusongqing 已提交
307
**Parameters**
W
wusongqing 已提交
308

309 310
| Name| Type| Mandatory| Description|
| -------- | -------------------------------------- | -- | --------------------------------- |
311 312
| 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 已提交
313

314
**Error codes**
W
wusongqing 已提交
315

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

318 319
| ID| Error Message|
| ------- | -------------------------------- |
320
| 1300001 | Repeated operation. |
321
| 1300006 | This window context is abnormal. |
W
wusongqing 已提交
322

W
wusongqing 已提交
323
**Example**
W
wusongqing 已提交
324

325
```js
326
let windowClass = null;
327 328 329 330 331 332 333 334 335 336 337 338 339
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));
340
}
341
```
Z
zengyawen 已提交
342

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

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

347
Creates a subwindow or system window. This API uses a promise to return the result.
W
wusongqing 已提交
348 349

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

W
wusongqing 已提交
351
**Parameters**
E
ester.zhou 已提交
352

353 354
| Name| Type| Mandatory| Description|
| ------ | -------------------------------- | -- | ------------------ |
355
| config | [Configuration](#configuration9) | Yes| Parameters used for creating the window.|
W
wusongqing 已提交
356

W
wusongqing 已提交
357
**Return value**
E
ester.zhou 已提交
358

359 360
| Type| Description|
| -------------------------------- | ------------------------------------ |
361
| Promise&lt;[Window](#window)&gt; | Promise used to return the window created.|
E
ester.zhou 已提交
362

363
**Error codes**
W
wusongqing 已提交
364

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

367 368
| ID| Error Message|
| ------- | -------------------------------- |
369
| 1300001 | Repeated operation. |
370
| 1300006 | This window context is abnormal. |
W
wusongqing 已提交
371

W
wusongqing 已提交
372
**Example**
W
wusongqing 已提交
373

374
```js
375
let windowClass = null;
376 377 378 379 380 381 382 383 384 385 386
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));
387
}
388
```
E
ester.zhou 已提交
389

390
## window.findWindow<sup>9+</sup>
Z
zengyawen 已提交
391

392
findWindow(name: string): Window
Z
zengyawen 已提交
393

394
Finds a window based on the name.
Z
zengyawen 已提交
395

W
wusongqing 已提交
396
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
397

W
wusongqing 已提交
398
**Parameters**
W
wusongqing 已提交
399

W
wusongqing 已提交
400 401
| Name| Type  | Mandatory| Description    |
| ------ | ------ | ---- | -------- |
402
| name   | string | Yes  | Window ID.|
W
wusongqing 已提交
403

W
wusongqing 已提交
404
**Return value**
W
wusongqing 已提交
405

406 407 408
| Type| Description|
| ----------------- | ------------------- |
| [Window](#window) | Window found.|
W
wusongqing 已提交
409

W
wusongqing 已提交
410
**Example**
W
wusongqing 已提交
411

412
```js
413
let windowClass = null;
414
try {
415
    windowClass = window.findWindow('alertWindow');
416 417
} catch (exception) {
    console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception));
418
}
419
```
Z
zengyawen 已提交
420

421
## window.getLastWindow<sup>9+</sup>
W
wusongqing 已提交
422

423
getLastWindow(ctx: BaseContext, callback: AsyncCallback&lt;Window&gt;): void
W
wusongqing 已提交
424 425 426 427

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 已提交
428

W
wusongqing 已提交
429
**Parameters**
Z
zengyawen 已提交
430

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

436
**Error codes**
W
wusongqing 已提交
437

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

440 441 442 443
| ID| Error Message|
| ------- | -------------------------------- |
| 1300002 | This window state is abnormal.   |
| 1300006 | This window context is abnormal. |
W
wusongqing 已提交
444

W
wusongqing 已提交
445
**Example**
W
wusongqing 已提交
446

447
```js
448
let windowClass = null;
449 450 451 452 453 454 455 456 457 458 459
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));
460
}
461
```
W
wusongqing 已提交
462

463
## window.getLastWindow<sup>9+</sup>
W
wusongqing 已提交
464

465
getLastWindow(ctx: BaseContext): Promise&lt;Window&gt;
W
wusongqing 已提交
466 467 468 469 470

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 已提交
471
**Parameters**
W
wusongqing 已提交
472

473 474
| Name| Type| Mandatory| Description|
| ------ | ----------- | ---- | ------------------------------------------------------------ |
G
Gloria 已提交
475
| ctx    | [BaseContext](js-apis-inner-application-baseContext.md) | Yes  | Current application context.|
W
wusongqing 已提交
476

W
wusongqing 已提交
477
**Return value**
W
wusongqing 已提交
478

479 480
| Type| Description|
| -------------------------------- | ------------------------------------------- |
W
wusongqing 已提交
481
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
W
wusongqing 已提交
482

483 484 485 486 487 488 489 490 491
**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 已提交
492
**Example**
W
wusongqing 已提交
493

494
```js
495
let windowClass = null;
496 497 498 499 500 501 502 503 504 505
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));
506
}
507 508 509 510 511 512 513
```

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

514
**System API**: This is a system API.
515 516 517 518 519 520 521

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

**Parameters**

| Name  | Type                     | Mandatory| Description          |
| -------- | ------------------------- | ---- | -------------- |
G
Gloria 已提交
522
| id       | number                    | Yes  | ID of the [display](js-apis-display.md#display). The value must be an integer.|
523 524
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.    |

525 526 527 528 529 530 531 532
**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. |

533 534 535 536 537
**Example**

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

538
let displayClass = null;
539 540 541
try {
    displayClass = display.getDefaultDisplaySync();

542 543 544 545 546 547 548 549 550 551 552
    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));
    }
553
} catch (exception) {
554 555
    console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
556 557 558 559 560 561 562
```

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

563
**System API**: This is a system API.
564 565 566 567 568 569 570

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

**Parameters**

| Name  | Type                     | Mandatory| Description          |
| -------- | ------------------------- | ---- | -------------- |
G
Gloria 已提交
571
| id       | number                    | Yes  | ID of the [display](js-apis-display.md#display). The value must be an integer.|
572 573 574 575 576 577 578

**Return value**

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

579 580 581 582 583 584 585 586
**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. |

587 588 589 590 591
**Example**

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

592
let displayClass = null;
593 594 595
try {
    displayClass = display.getDefaultDisplaySync();

596 597 598 599 600 601 602 603 604 605
    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));
    }
606
} catch (exception) {
607 608
    console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
609 610 611 612 613 614 615
```

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

616
**System API**: This is a system API.
617 618 619 620 621 622 623 624 625

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

**Parameters**

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

626 627 628 629 630 631 632 633
**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. |

634 635 636
**Example**

```js
637
window.toggleShownStateForAllAppWindows((err) => {
638 639 640 641 642
    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.');
643
});
644 645 646 647 648 649 650
```

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

651
**System API**: This is a system API.
652 653 654 655 656 657 658 659 660

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

**Return value**

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

661 662 663 664 665 666 667 668
**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. |

669 670 671 672
**Example**

```js
let promise = window.toggleShownStateForAllAppWindows();
673 674
promise.then(()=> {
    console.info('Succeeded in toggling shown state for all app windows.');
675 676
}).catch((err)=>{
    console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
677
});
678 679 680 681 682 683 684
```

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

685
**System API**: This is a system API.
686 687 688 689 690 691 692 693 694 695

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

696
**Error codes**
697

698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716
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));
717
}
718 719 720 721 722 723 724
```

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

725
**System API**: This is a system API.
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740

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

741 742 743 744 745 746 747 748
**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. |

749 750 751
**Example**

```js
752 753 754 755 756 757 758 759 760
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));
761
}
762
```
W
wusongqing 已提交
763

764
## window.on('systemBarTintChange')<sup>8+</sup>
W
wusongqing 已提交
765 766 767

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

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

770
**System API**: This is a system API.
W
wusongqing 已提交
771 772 773

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

W
wusongqing 已提交
774
**Parameters**
W
wusongqing 已提交
775

776 777 778 779
| 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 已提交
780

W
wusongqing 已提交
781
**Example**
W
wusongqing 已提交
782

783
```js
784 785 786 787 788 789
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));
790
}
791
```
Z
zengyawen 已提交
792

793
## window.off('systemBarTintChange')<sup>8+</sup>
W
wusongqing 已提交
794 795

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

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

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

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

W
wusongqing 已提交
803
**Parameters**
Z
zengyawen 已提交
804

805 806 807 808
| 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 已提交
809

W
wusongqing 已提交
810
**Example**
Z
zengyawen 已提交
811

812
```js
813 814 815 816
try {
    window.off('systemBarTintChange');
} catch (exception) {
    console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
817
}
818
```
W
wusongqing 已提交
819

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

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

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

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

830
**Model restriction**: This API can be used only in the FA model.
W
wusongqing 已提交
831 832 833

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

W
wusongqing 已提交
834
**Parameters**
W
wusongqing 已提交
835

836 837 838 839 840
| 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 已提交
841

W
wusongqing 已提交
842
**Example**
W
wusongqing 已提交
843

844
```js
845 846 847 848
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));
849 850
        return;
    }
851 852 853
    windowClass = data;
    console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
});
854
```
W
wusongqing 已提交
855

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

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

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

862
> **NOTE**
863
> 
864 865 866
> 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 已提交
867 868 869

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

870 871 872 873 874 875 876
**Parameters**

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

W
wusongqing 已提交
877
**Return value**
W
wusongqing 已提交
878

879 880 881
| Type                            | Description                                   |
| -------------------------------- | --------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
W
wusongqing 已提交
882

W
wusongqing 已提交
883
**Example**
W
wusongqing 已提交
884

885
```js
886 887
let windowClass = null;
let promise = window.create('first', window.WindowType.TYPE_APP);
888
promise.then((data)=> {
889 890
    windowClass = data;
    console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
891
}).catch((err)=>{
892 893
    console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
});
894
```
W
wusongqing 已提交
895

896
## window.create<sup>(deprecated)</sup>
897

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

G
Gloria 已提交
900
Creates a system window. This API uses an asynchronous callback to return the result.
901 902

> **NOTE**
903
> 
904
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createWindow()](#windowcreatewindow9) instead.
905 906 907 908 909

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

**Parameters**

G
Gloria 已提交
910 911 912 913 914 915
| 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.|
916 917 918 919

**Example**

```js
920 921
let windowClass = null;
window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
922
    if (err.code) {
923
        console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
924 925
        return;
    }
926 927 928 929
    windowClass = data;
    console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data));
    windowClass.resetSize(500, 1000);
});
930 931
```

932
## window.create<sup>(deprecated)</sup>
933

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

G
Gloria 已提交
936
Creates a system window. This API uses a promise to return the result.
937 938

> **NOTE**
939
> 
940
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createWindow()](#windowcreatewindow9-1) instead.
941 942 943

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

944 945 946 947
**Parameters**

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

952 953
**Return value**

954 955 956
| Type                            | Description                                   |
| -------------------------------- | --------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
957 958 959 960

**Example**

```js
961 962
let windowClass = null;
let promise = window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT);
963
promise.then((data)=> {
964 965
    windowClass = data;
    console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
966
}).catch((err)=>{
967 968
    console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
});
969 970
```

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

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

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

> **NOTE**
978
> 
979
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [findWindow()](#windowfindwindow9) instead.
W
wusongqing 已提交
980 981 982

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

W
wusongqing 已提交
983
**Parameters**
W
wusongqing 已提交
984

985 986 987 988
| 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 已提交
989

W
wusongqing 已提交
990
**Example**
W
wusongqing 已提交
991

992
```js
993 994
let windowClass = null;
window.find('alertWindow', (err, data) => {
995
    if (err.code) {
996
        console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
997 998
        return;
    }
999 1000 1001
    windowClass = data;
    console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
});
1002
```
W
wusongqing 已提交
1003

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

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

1008 1009 1010
Finds a window based on the ID. This API uses a promise to return the result.

> **NOTE**
1011
> 
1012
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [findWindow()](#windowfindwindow9) instead.
W
wusongqing 已提交
1013 1014 1015

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

1016 1017 1018 1019 1020 1021
**Parameters**

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

W
wusongqing 已提交
1022
**Return value**
W
wusongqing 已提交
1023

1024 1025 1026
| Type                            | Description                                 |
| -------------------------------- | ------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the window found.|
W
wusongqing 已提交
1027

W
wusongqing 已提交
1028
**Example**
W
wusongqing 已提交
1029

1030
```js
1031 1032
let windowClass = null;
let promise = window.find('alertWindow');
1033
promise.then((data)=> {
1034 1035
    windowClass = data;
    console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
1036
}).catch((err)=>{
1037 1038
    console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
});
1039
```
W
wusongqing 已提交
1040

1041
## window.getTopWindow<sup>(deprecated)</sup>
1042

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

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

1047
> **NOTE**
1048
> 
1049 1050 1051
> 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.
1052 1053 1054 1055 1056

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

**Parameters**

1057 1058 1059
| Name  | Type                                  | Mandatory| Description                                        |
| -------- | -------------------------------------- | ---- | -------------------------------------------- |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the top window obtained.|
1060 1061 1062 1063

**Example**

```js
1064 1065
let windowClass = null;
window.getTopWindow((err, data) => {
1066
    if (err.code) {
1067
        console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
1068 1069
        return;
    }
1070 1071 1072
    windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
});
1073 1074
```

1075
## window.getTopWindow<sup>(deprecated)</sup>
1076

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

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

1081
> **NOTE**
1082
> 
1083 1084 1085
> 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.
1086 1087 1088 1089 1090

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

**Return value**

1091 1092 1093
| Type                            | Description                                           |
| -------------------------------- | ----------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
1094 1095 1096 1097

**Example**

```js
1098 1099
let windowClass = null;
let promise = window.getTopWindow();
1100
promise.then((data)=> {
1101 1102
    windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
1103
}).catch((err)=>{
1104
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
1105
});
1106 1107
```

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

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

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

> **NOTE**
1115
> 
1116
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getLastWindow()](#windowgetlastwindow9) instead.
W
wusongqing 已提交
1117 1118 1119

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

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

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

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

1129
```js
1130 1131
let windowClass = null;
window.getTopWindow(this.context, (err, data) => {
1132
    if (err.code) {
1133
        console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
1134 1135
        return;
    }
1136 1137 1138
    windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
});
1139
```
W
wusongqing 已提交
1140

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

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

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

> **NOTE**
1148
> 
1149
> 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 已提交
1150 1151 1152

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

1153 1154 1155 1156
**Parameters**

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

W
wusongqing 已提交
1159
**Return value**
W
wusongqing 已提交
1160

1161 1162 1163
| Type                            | Description                                           |
| -------------------------------- | ----------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
W
wusongqing 已提交
1164

W
wusongqing 已提交
1165
**Example**
W
wusongqing 已提交
1166

1167
```js
1168 1169
let windowClass = null;
let promise = window.getTopWindow(this.context);
1170
promise.then((data)=> {
1171 1172
 	windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
1173
}).catch((err)=>{
1174
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
1175
});
1176
```
W
wusongqing 已提交
1177

1178
## Window
W
wusongqing 已提交
1179

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

1182 1183 1184 1185 1186 1187 1188 1189 1190
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 已提交
1191 1192 1193

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

W
wusongqing 已提交
1194
**Parameters**
W
wusongqing 已提交
1195

1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206
| 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 已提交
1207

W
wusongqing 已提交
1208
**Example**
W
wusongqing 已提交
1209

1210
```js
1211
windowClass.hide((err) => {
1212
    if (err.code) {
1213
        console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
1214 1215
        return;
    }
1216 1217
    console.info('Succeeded in hiding the window.');
});
1218
```
W
wusongqing 已提交
1219

1220
### hide<sup>7+</sup>
W
wusongqing 已提交
1221

1222
hide(): Promise&lt;void&gt;
W
wusongqing 已提交
1223

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

1226
**System API**: This is a system API.
W
wusongqing 已提交
1227

1228
**System capability**: SystemCapability.WindowManager.WindowManager.Core
W
wusongqing 已提交
1229

W
wusongqing 已提交
1230
**Return value**
W
wusongqing 已提交
1231

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

1236 1237 1238 1239 1240 1241 1242 1243
**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 已提交
1244
**Example**
W
wusongqing 已提交
1245

1246
```js
1247 1248 1249
let promise = windowClass.hide();
promise.then(()=> {
    console.info('Succeeded in hiding the window.');
1250
}).catch((err)=>{
1251
    console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
1252
});
1253
```
W
wusongqing 已提交
1254

1255
### hideWithAnimation<sup>9+</sup>
W
wusongqing 已提交
1256

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

1259 1260 1261
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 已提交
1262 1263 1264

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

W
wusongqing 已提交
1265
**Parameters**
W
wusongqing 已提交
1266

1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279
| 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 已提交
1280

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

1283
```js
1284
windowClass.hideWithAnimation((err) => {
1285
    if (err.code) {
1286
        console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
1287 1288
        return;
    }
1289
    console.info('Succeeded in hiding the window with animation.');
1290
});
1291
```
W
wusongqing 已提交
1292

1293
### hideWithAnimation<sup>9+</sup>
W
wusongqing 已提交
1294

1295
hideWithAnimation(): Promise&lt;void&gt;
W
wusongqing 已提交
1296

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

1299
**System API**: This is a system API.
W
wusongqing 已提交
1300

1301
**System capability**: SystemCapability.WindowManager.WindowManager.Core
W
wusongqing 已提交
1302

W
wusongqing 已提交
1303
**Return value**
W
wusongqing 已提交
1304

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

1309 1310 1311 1312 1313 1314 1315 1316 1317 1318
**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 已提交
1319
**Example**
W
wusongqing 已提交
1320

1321
```js
1322 1323
let promise = windowClass.hideWithAnimation();
promise.then(()=> {
1324
    console.info('Succeeded in hiding the window with animation.');
1325
}).catch((err)=>{
1326
    console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
1327
});
1328
```
W
wusongqing 已提交
1329

1330
### showWindow<sup>9+</sup>
W
wusongqing 已提交
1331

1332
showWindow(callback: AsyncCallback&lt;void&gt;): void
1333

1334
Shows this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1335 1336 1337

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

W
wusongqing 已提交
1338
**Parameters**
W
wusongqing 已提交
1339

1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350
| 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 已提交
1351

W
wusongqing 已提交
1352
**Example**
W
wusongqing 已提交
1353

1354
```js
1355 1356 1357 1358 1359 1360
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.');
1361 1362
});
```
W
wusongqing 已提交
1363

1364
### showWindow<sup>9+</sup>
W
wusongqing 已提交
1365

1366
showWindow(): Promise&lt;void&gt;
1367

1368
Shows this window. This API uses a promise to return the result.
W
wusongqing 已提交
1369 1370 1371

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

W
wusongqing 已提交
1372
**Return value**
W
wusongqing 已提交
1373

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

1378 1379 1380 1381 1382 1383 1384 1385
**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 已提交
1386
**Example**
W
wusongqing 已提交
1387

1388
```js
1389 1390 1391
let promise = windowClass.showWindow();
promise.then(()=> {
    console.info('Succeeded in showing the window.');
1392
}).catch((err)=>{
1393
    console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
1394 1395
});
```
W
wusongqing 已提交
1396

1397
### showWithAnimation<sup>9+</sup>
W
wusongqing 已提交
1398

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

1401 1402 1403
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 已提交
1404 1405 1406

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

W
wusongqing 已提交
1407
**Parameters**
W
wusongqing 已提交
1408

1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421
| 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 已提交
1422

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

1425
```js
1426
windowClass.showWithAnimation((err) => {
1427
    if (err.code) {
1428
        console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
1429 1430
        return;
    }
1431
    console.info('Succeeded in showing the window with animation.');
1432
});
1433
```
W
wusongqing 已提交
1434

1435 1436 1437
### showWithAnimation<sup>9+</sup>

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

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

1441
**System API**: This is a system API.
W
wusongqing 已提交
1442 1443 1444

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

W
wusongqing 已提交
1445
**Return value**
W
wusongqing 已提交
1446

1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459
| 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 已提交
1460

W
wusongqing 已提交
1461
**Example**
W
wusongqing 已提交
1462

1463
```js
1464 1465 1466
let promise = windowClass.showWithAnimation();
promise.then(()=> {
    console.info('Succeeded in showing the window with animation.');
1467
}).catch((err)=>{
1468
    console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
1469
});
1470
```
W
wusongqing 已提交
1471

1472
### destroyWindow<sup>9+</sup>
W
wusongqing 已提交
1473

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

1476
Destroys this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1477 1478 1479

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

W
wusongqing 已提交
1480
**Parameters**
W
wusongqing 已提交
1481

1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493
| 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 已提交
1494

W
wusongqing 已提交
1495
**Example**
W
wusongqing 已提交
1496

1497
```js
1498
windowClass.destroyWindow((err) => {
1499
    if (err.code) {
1500
        console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
1501 1502
        return;
    }
1503
    console.info('Succeeded in destroying the window.');
1504
});
1505
```
W
wusongqing 已提交
1506

1507
### destroyWindow<sup>9+</sup>
W
wusongqing 已提交
1508

1509
destroyWindow(): Promise&lt;void&gt;
W
wusongqing 已提交
1510

1511
Destroys this window. This API uses a promise to return the result.
W
wusongqing 已提交
1512 1513 1514

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

1515 1516 1517 1518 1519
**Return value**

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

1521
**Error codes**
W
wusongqing 已提交
1522

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

1525 1526 1527 1528
| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
W
wusongqing 已提交
1529

W
wusongqing 已提交
1530
**Example**
W
wusongqing 已提交
1531

1532
```js
1533 1534 1535
let promise = windowClass.destroyWindow();
promise.then(()=> {
    console.info('Succeeded in destroying the window.');
1536
}).catch((err)=>{
1537
    console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
1538
});
1539
```
W
wusongqing 已提交
1540

1541
### moveWindowTo<sup>9+</sup>
W
wusongqing 已提交
1542

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

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

1547 1548
This operation is not supported in a window in full-screen mode.

W
wusongqing 已提交
1549 1550
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1551
**Parameters**
W
wusongqing 已提交
1552

1553 1554
| Name| Type| Mandatory| Description|
| -------- | ------------------------- | -- | --------------------------------------------- |
G
Gloria 已提交
1555 1556
| 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. The value must be an integer.|
| y        | number                    | Yes| Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards. The value must be an integer.|
1557 1558 1559 1560 1561 1562 1563 1564 1565 1566
| 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 已提交
1567

W
wusongqing 已提交
1568
**Example**
W
wusongqing 已提交
1569

1570
```js
1571 1572 1573 1574 1575 1576 1577 1578 1579 1580
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));
1581
}
1582
```
W
wusongqing 已提交
1583

1584
### moveWindowTo<sup>9+</sup>
W
wusongqing 已提交
1585

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

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

1590 1591
This operation is not supported in a window in full-screen mode.

W
wusongqing 已提交
1592 1593
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1594
**Parameters**
W
wusongqing 已提交
1595

1596 1597
| Name| Type| Mandatory| Description|
| -- | ----- | -- | --------------------------------------------- |
G
Gloria 已提交
1598 1599
| 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. The value must be an integer.|
| y | number | Yes| Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards. The value must be an integer.|
W
wusongqing 已提交
1600

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

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

1607 1608 1609 1610 1611 1612 1613 1614 1615
**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 已提交
1616
**Example**
W
wusongqing 已提交
1617

1618
```js
1619 1620 1621 1622 1623 1624 1625 1626 1627
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));
1628
}
1629
```
W
wusongqing 已提交
1630

1631
### resize<sup>9+</sup>
W
wusongqing 已提交
1632

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

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

1637 1638 1639 1640 1641 1642
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.

1643 1644
This operation is not supported in a window in full-screen mode.

W
wusongqing 已提交
1645 1646
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1647
**Parameters**
W
wusongqing 已提交
1648

1649 1650
| Name| Type| Mandatory| Description|
| -------- | ------------------------- | -- | ------------------------ |
G
Gloria 已提交
1651 1652
| width    | number                    | Yes| New width of the window, in px. The value must be an integer.|
| height   | number                    | Yes| New height of the window, in px. The value must be an integer.|
1653
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.               |
W
wusongqing 已提交
1654

1655
**Error codes**
W
wusongqing 已提交
1656

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

1659 1660 1661 1662
| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
W
wusongqing 已提交
1663

1664
**Example**
W
wusongqing 已提交
1665

1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676
```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));
1677
}
1678 1679 1680 1681 1682 1683 1684
```

### 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 已提交
1685

1686 1687 1688 1689 1690 1691
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.

1692 1693
This operation is not supported in a window in full-screen mode.

W
wusongqing 已提交
1694 1695
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
1696
**Parameters**
W
wusongqing 已提交
1697

1698 1699
| Name| Type| Mandatory| Description|
| ------ | ------ | -- | ------------------------ |
G
Gloria 已提交
1700 1701
| width  | number | Yes| New width of the window, in px. The value must be an integer.|
| height | number | Yes| New height of the window, in px. The value must be an integer.|
W
wusongqing 已提交
1702

W
wusongqing 已提交
1703
**Return value**
W
wusongqing 已提交
1704

1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729
| 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));
1730
}
1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772
```

### 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));
1773
}
1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811
```

### 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 {
1812
    let promise = windowClass.setWindowMode(mode);
1813 1814 1815 1816 1817 1818 1819
    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));
1820
}
1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851
```

### 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));
1852
}
1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866
```

### 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 已提交
1867
| type | [AvoidAreaType](#avoidareatype7) | Yes| Type of the area.|
1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890

**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));
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 1928 1929 1930 1931
```

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

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

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

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

**Parameters**

| Name| Type| Mandatory| Description|
| ------------------ | ------------------------- | -- | --------- |
| isLayoutFullScreen | boolean                   | Yes| Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed. The value **true** means to enable the full-screen mode for the window layout, 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 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));
1932
}
1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952
```

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

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

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

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

**Parameters**

| Name| Type| Mandatory| Description|
| ------------------ | ------- | -- | ------------------------------------------------------------------------------------------------ |
| isLayoutFullScreen | boolean | Yes| Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed. The value **true** means to enable the full-screen mode for the window layout, and **false** means the opposite.|

**Return value**

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

1955 1956 1957 1958 1959 1960 1961 1962 1963
**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 已提交
1964
**Example**
W
wusongqing 已提交
1965

1966
```js
1967
let isLayoutFullScreen = true;
1968 1969 1970 1971 1972 1973 1974 1975 1976
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));
1977
}
1978
```
W
wusongqing 已提交
1979

1980
### setWindowSystemBarEnable<sup>9+</sup>
W
wusongqing 已提交
1981

1982
setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
1983 1984 1985 1986 1987

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 已提交
1988
**Parameters**
W
wusongqing 已提交
1989

1990
| Name| Type| Mandatory| Description|
1991
| -------- | ---------------------------- | -- | --------- |
1992
| 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.|
1993 1994 1995 1996 1997 1998 1999 2000 2001 2002
| 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 已提交
2003

W
wusongqing 已提交
2004
**Example**
W
wusongqing 已提交
2005

2006
```js
2007
// In this example, the status bar and navigation bar are not displayed.
2008
let names = [];
2009 2010 2011 2012 2013 2014 2015 2016 2017 2018
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));
2019
}
2020
```
W
wusongqing 已提交
2021

2022
### setWindowSystemBarEnable<sup>9+</sup>
W
wusongqing 已提交
2023

2024
setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt;
W
wusongqing 已提交
2025 2026 2027 2028 2029

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 已提交
2030
**Parameters**
W
wusongqing 已提交
2031

2032
| Name| Type | Mandatory| Description|
2033 2034
| ----- | ---------------------------- | -- | --------------------------------- |
| 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 已提交
2035

W
wusongqing 已提交
2036
**Return value**
W
wusongqing 已提交
2037

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

2042 2043 2044 2045 2046 2047 2048 2049 2050
**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 已提交
2051
**Example**
W
wusongqing 已提交
2052

2053
```js
2054
// In this example, the status bar and navigation bar are not displayed.
2055
let names = [];
2056 2057 2058 2059 2060 2061 2062 2063 2064
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));
2065
}
2066
```
W
wusongqing 已提交
2067

2068
### setWindowSystemBarProperties<sup>9+</sup>
W
wusongqing 已提交
2069

2070
setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
2071 2072 2073 2074 2075

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 已提交
2076
**Parameters**
W
wusongqing 已提交
2077

2078 2079
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
W
wusongqing 已提交
2080
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
2081 2082
| callback            | AsyncCallback&lt;void&gt;                   | Yes  | Callback used to return the result.            |

2083 2084 2085 2086 2087 2088 2089 2090 2091
**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. |

2092 2093 2094
**Example**

```js
2095
let SystemBarProperties = {
2096 2097 2098 2099 2100 2101
    statusBarColor: '#ff00ff',
    navigationBarColor: '#00ff00',
    // The following properties are supported since API version 8.
    statusBarContentColor:'#ffffff',
    navigationBarContentColor:'#00ffff'
};
2102 2103 2104 2105 2106 2107 2108 2109 2110 2111
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));
2112
}
2113
```
W
wusongqing 已提交
2114

2115
### setWindowSystemBarProperties<sup>9+</sup>
W
wusongqing 已提交
2116

2117
setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise&lt;void&gt;
W
wusongqing 已提交
2118 2119 2120 2121 2122

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 已提交
2123
**Parameters**
W
wusongqing 已提交
2124

2125 2126
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
W
wusongqing 已提交
2127
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
W
wusongqing 已提交
2128

W
wusongqing 已提交
2129
**Return value**
W
wusongqing 已提交
2130

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

2135 2136 2137 2138 2139 2140 2141 2142 2143
**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. |

2144
**Example**
W
wusongqing 已提交
2145

2146
```js
2147
let SystemBarProperties = {
2148 2149 2150 2151 2152 2153
    statusBarColor: '#ff00ff',
    navigationBarColor: '#00ff00',
    // The following properties are supported since API version 8.
    statusBarContentColor:'#ffffff',
    navigationBarContentColor:'#00ffff'
};
2154 2155 2156 2157 2158 2159 2160 2161 2162
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));
2163
}
2164
```
W
wusongqing 已提交
2165

2166 2167 2168 2169 2170
### 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 已提交
2171 2172 2173

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

W
wusongqing 已提交
2174
**Parameters**
W
wusongqing 已提交
2175

2176 2177 2178 2179 2180
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
| Orientation         | [Orientation](#orientation9)                | Yes  | Orientation to set.        |
| callback            | AsyncCallback&lt;void&gt;                   | Yes  | Callback used to return the result.            |

2181 2182 2183 2184 2185 2186 2187 2188
**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. |

2189 2190 2191
**Example**

```js
2192
let orientation = window.Orientation.AUTO_ROTATION;
2193 2194 2195 2196 2197 2198 2199 2200 2201 2202
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));
2203
}
2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225
```

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

2226 2227 2228 2229 2230 2231 2232 2233
**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. |

2234 2235 2236
**Example**

```js
2237
let orientation = window.Orientation.AUTO_ROTATION;
2238 2239 2240 2241 2242 2243 2244 2245 2246
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));
2247
}
2248 2249
```

2250
### setUIContent<sup>9+</sup>
2251

2252
setUIContent(path: string, callback: AsyncCallback&lt;void&gt;): void
2253 2254 2255 2256 2257 2258 2259

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

2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272
| 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 已提交
2273

W
wusongqing 已提交
2274
**Example**
W
wusongqing 已提交
2275

2276
```js
2277 2278 2279 2280 2281 2282 2283 2284 2285 2286
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));
2287
}
2288
```
W
wusongqing 已提交
2289

2290
### setUIContent<sup>9+</sup>
W
wusongqing 已提交
2291

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

2294
Loads content from a page to this window. This API uses a promise to return the result.
W
wusongqing 已提交
2295 2296 2297

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

W
wusongqing 已提交
2298
**Parameters**
W
wusongqing 已提交
2299

2300 2301 2302
| Name| Type| Mandatory| Description|
| ---- | ------ | -- | ------------------ |
| path | string | Yes| Path of the page from which the content will be loaded.|
G
ge-yafang 已提交
2303

W
wusongqing 已提交
2304
**Return value**
W
wusongqing 已提交
2305

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

2310 2311 2312 2313 2314 2315 2316 2317 2318
**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 已提交
2319
**Example**
W
wusongqing 已提交
2320

2321
```js
2322 2323 2324 2325 2326 2327 2328 2329 2330
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));
2331
}
2332
```
2333

2334 2335 2336 2337 2338 2339
### 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.

2340
**Model restriction**: This API can be used only in the stage model.
2341 2342 2343 2344 2345 2346 2347 2348

**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 已提交
2349
| 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.|
2350 2351
| callback | AsyncCallback&lt;void&gt;                       | Yes  | Callback used to return the result.                                                  |

2352 2353 2354 2355 2356 2357 2358 2359 2360
**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. |

2361 2362 2363
**Example**

```ts
2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376
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));
2377
}
2378 2379 2380 2381 2382
```

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

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

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

2386
**Model restriction**: This API can be used only in the stage model.
2387 2388 2389 2390 2391 2392 2393 2394

**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 已提交
2395
| 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.|
2396 2397 2398 2399 2400 2401 2402

**Return value**

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

2403
**Error codes**
W
wusongqing 已提交
2404

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

2407 2408 2409 2410
| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal.               |
| 1300003 | This window manager service works abnormally. |
W
wusongqing 已提交
2411

W
wusongqing 已提交
2412
**Example**
W
wusongqing 已提交
2413

2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426
```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));
2427
}
2428
```
W
wusongqing 已提交
2429

2430
### isWindowShowing<sup>9+</sup>
W
wusongqing 已提交
2431

2432
isWindowShowing(): boolean
W
wusongqing 已提交
2433

2434
Checks whether this window is displayed.
W
wusongqing 已提交
2435 2436 2437

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

W
wusongqing 已提交
2438
**Return value**
W
wusongqing 已提交
2439

2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450
| 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 已提交
2451

W
wusongqing 已提交
2452
**Example**
W
wusongqing 已提交
2453

2454
```js
2455 2456
try {
    let data = windowClass.isWindowShowing();
2457
    console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
2458 2459
} catch (exception) {
    console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception));
2460
}
2461
```
W
wusongqing 已提交
2462 2463 2464 2465 2466 2467 2468 2469 2470

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

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

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

2480
```js
2481 2482 2483 2484 2485 2486
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));
2487
}
2488
```
W
wusongqing 已提交
2489 2490 2491

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

2492
off(type: 'windowSizeChange', callback?: Callback&lt;Size&gt;): void
W
wusongqing 已提交
2493 2494 2495 2496 2497

Disables listening for window size changes.

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

W
wusongqing 已提交
2498
**Parameters**
W
wusongqing 已提交
2499

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

W
wusongqing 已提交
2505
**Example**
W
wusongqing 已提交
2506

2507
```js
2508 2509 2510 2511
try {
    windowClass.off('windowSizeChange');
} catch (exception) {
    console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception));
2512
}
2513 2514 2515 2516
```

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

2517
on(type: 'avoidAreaChange', callback: Callback&lt;{AvoidAreaType, AvoidArea}&gt;): void
2518 2519 2520 2521 2522 2523 2524 2525 2526

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

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

**Parameters**

| Name  | Type                                                              | Mandatory| Description                                  |
| -------- |------------------------------------------------------------------| ---- |--------------------------------------|
2527
| 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.|
2528 2529 2530 2531 2532
| callback | Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt; | Yes  | Callback used to return the area and area type.|

**Example**

```js
2533 2534 2535 2536 2537 2538 2539
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));
2540
}
2541 2542 2543 2544
```

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

2545
off(type: 'avoidAreaChange', callback?: Callback&lt;{AvoidAreaType, AvoidArea}&gt;): void
2546 2547 2548 2549 2550 2551 2552 2553 2554

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

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

**Parameters**

| Name  | Type                                                                         | Mandatory | Description                                |
| -------- |-----------------------------------------------------------------------------|-----|------------------------------------|
2555
| 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.|
2556 2557 2558 2559 2560
| callback | Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt; | No  | Callback used to return the area and area type.|

**Example**

```js
2561 2562 2563 2564
try {
    windowClass.off('avoidAreaChange');
} catch (exception) {
    console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
2565
}
2566
```
W
wusongqing 已提交
2567 2568 2569 2570 2571 2572 2573 2574 2575

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

G
Gloria 已提交
2578 2579
| Name  | Type               | Mandatory| Description                                       |
| -------- | ------------------- | ---- |-------------------------------------------|
2580
| type     | string              | Yes  | Event type. The value is fixed at **'keyboardHeightChange'**, indicating the keyboard height change event.|
G
Gloria 已提交
2581
| callback | Callback&lt;number&gt; | Yes  | Callback used to return the current keyboard height, which is an integer.                   |
W
wusongqing 已提交
2582

W
wusongqing 已提交
2583
**Example**
W
wusongqing 已提交
2584

2585
```js
2586 2587 2588 2589 2590 2591
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));
2592
}
2593
```
W
wusongqing 已提交
2594 2595 2596 2597 2598 2599 2600 2601 2602

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

W
wusongqing 已提交
2605 2606
| Name  | Type                  | Mandatory| Description                                                        |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
2607
| type     | string                 | Yes  | Event type. The value is fixed at **'keyboardHeightChange'**, indicating the keyboard height change event.|
G
Gloria 已提交
2608
| callback | Callback&lt;number&gt; | No  | Callback used to return the current keyboard height, which is an integer.                              |
2609 2610 2611 2612

**Example**

```js
2613 2614 2615 2616
try {
    windowClass.off('keyboardHeightChange');
} catch (exception) {
    console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
2617
}
2618 2619 2620 2621 2622 2623 2624
```

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

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

Enables listening for click events outside this window.
2625 2626

**System API**: This is a system API.
2627 2628 2629 2630 2631 2632 2633

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

**Parameters**

| Name  | Type               | Mandatory| Description                                                        |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
2634 2635
| 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.                              |
2636 2637 2638 2639

**Example**

```js
2640 2641 2642 2643 2644 2645
try {
    windowClass.on('touchOutside', () => {
        console.info('touch outside');
    });
} catch (exception) {
    console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
2646
}
2647 2648 2649 2650 2651 2652 2653
```

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

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

Disables listening for click events outside this window.
2654 2655

**System API**: This is a system API.
2656 2657 2658 2659 2660 2661 2662

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

**Parameters**

| Name  | Type                  | Mandatory| Description                                                        |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
2663
| type     | string                 | Yes  | Event type. The value is fixed at **'touchOutside'**, indicating the click event outside this window.|
G
Gloria 已提交
2664
| callback | Callback&lt;void&gt; | No  | Callback used to return the click event outside this window.                              |
W
wusongqing 已提交
2665

W
wusongqing 已提交
2666
**Example**
W
wusongqing 已提交
2667

2668
```js
2669 2670 2671 2672
try {
    windowClass.off('touchOutside');
} catch (exception) {
    console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
2673
}
2674
```
W
wusongqing 已提交
2675

2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687
### 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                                                        |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
2688
| type     | string              | Yes  | Event type. The value is fixed at **'screenshot'**, indicating the screenshot event.|
2689 2690 2691 2692 2693
| callback | Callback&lt;void&gt; | Yes  | Callback invoked when a screenshot event occurs.                              |

**Example**

```js
2694 2695 2696 2697 2698 2699
try {
    windowClass.on('screenshot', () => {
        console.info('screenshot happened');
    });
} catch (exception) {
    console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
2700
}
2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714
```

### 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                                                        |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
2715
| type     | string                 | Yes  | Event type. The value is fixed at **'screenshot'**, indicating the screenshot event.|
2716 2717 2718 2719 2720
| callback | Callback&lt;void&gt; | No  | Callback invoked when a screenshot event occurs.|

**Example**

```js
2721
let callback = () => {
2722
    console.info('screenshot happened');
2723 2724 2725 2726 2727
};
try {
    windowClass.on('screenshot', callback);
} catch (exception) {
    console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
2728
}
2729 2730 2731 2732 2733 2734
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));
2735
}
2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755
```

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

2756 2757 2758 2759 2760 2761 2762 2763 2764
**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. |

2765 2766 2767
**Example**

```js
2768 2769
import rpc from '@ohos.rpc';

2770 2771
class MyDeathRecipient {
    onRemoteDied() {
2772
        console.log('server died');
2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788
    }
}
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;
    }
}
2789

2790
let token = new TestRemoteObject('testObject');
2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802
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));
2803
}
2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828
```

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

2829 2830 2831 2832 2833 2834 2835 2836 2837
**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. |

2838 2839 2840
**Example**

```js
2841 2842
import rpc from '@ohos.rpc';

2843 2844
class MyDeathRecipient {
    onRemoteDied() {
2845
        console.log('server died');
2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861
    }
}
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;
    }
}
2862

2863
let token = new TestRemoteObject('testObject');
2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874
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));
2875
}
2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908
```

### 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));
2909
});
2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937
```

### 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();
2938
promise.then((data)=> {
2939
    console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
2940
}).catch((err)=>{
2941
    console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
2942 2943 2944
});
```

2945
### setWindowColorSpace<sup>9+</sup>
W
wusongqing 已提交
2946

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

2949
Sets a color space for this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2950 2951 2952

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

W
wusongqing 已提交
2953
**Parameters**
W
wusongqing 已提交
2954

2955 2956
| Name| Type| Mandatory| Description|
| ---------- | ------------------------- | -- | ----------- |
G
ge-yafang 已提交
2957
| colorSpace | [ColorSpace](#colorspace8) | Yes| Color space to set.|
2958 2959 2960 2961 2962 2963 2964 2965 2966
| 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 已提交
2967

W
wusongqing 已提交
2968
**Example**
W
wusongqing 已提交
2969

2970
```js
2971 2972 2973 2974 2975 2976 2977 2978 2979 2980
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));
2981
}
2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995
```

### 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 已提交
2996
| colorSpace | [ColorSpace](#colorspace8) | Yes| Color space to set.|
2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023

**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));
3024
}
3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038
```

### 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 已提交
3039
| [ColorSpace](#colorspace8) | Color space obtained.|
3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058

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

3059
Sets the background color for this window. In the stage model, this API must be used after the call of [loadContent](#loadcontent9) or [setUIContent()](#setuicontent9) takes effect.
3060 3061 3062 3063 3064 3065 3066

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

**Parameters**

| Name| Type| Mandatory| Description|
| ----- | ------ | -- | ----------------------------------------------------------------------- |
G
Gloria 已提交
3067
| 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**.|
3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084

**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));
3085
}
3086 3087 3088 3089 3090 3091 3092 3093
```

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

3094 3095
When the screen brightness setting for the window takes effect, Control Panel cannot adjust the system screen brightness. It can do so only after the window screen brightness is restored to the default value.

3096 3097 3098 3099
**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

G
Gloria 已提交
3100 3101 3102 3103
| Name| Type| Mandatory| Description                                       |
| ---------- | ------------------------- | -- |-------------------------------------------|
| brightness | number                    | Yes| Brightness to set. The value is a floating point number in the range [0.0, 1.0], and the value **1.0** means the brightest.|
| callback   | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.                                    |
3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127

**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));
3128
}
3129 3130 3131 3132 3133 3134 3135 3136
```

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

3137 3138
When the screen brightness setting for the window takes effect, Control Panel cannot adjust the system screen brightness. It can do so only after the window screen brightness is restored to the default value.

3139 3140 3141 3142
**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

G
Gloria 已提交
3143 3144 3145
| Name| Type| Mandatory| Description                                    |
| ---------- | ------ | -- |----------------------------------------|
| brightness | number | Yes| Brightness to set. The value is a floating point number in the range [0.0, 1.0], and the value **1.0** means the brightest.|
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

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

### 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
3205
let isFocusable = true;
3206 3207 3208 3209 3210 3211 3212 3213 3214 3215
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));
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
```

### 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
3251
let isFocusable = true;
3252 3253 3254 3255 3256 3257 3258 3259 3260
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));
3261
}
3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301
```

### 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));
3302
}
3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346
```

### 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));
3347
}
3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382
```

### 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));
3383
}
3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424
```

### 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));
3425
}
3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470
```

### 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));
3471
}
3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 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 3541 3542 3543
```

### 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));
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 3586 3587 3588
```

### 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));
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 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631
```

### 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));
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 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678
```

### 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));
3679
}
3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691
```

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

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

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

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

**Parameters**

G
Gloria 已提交
3692 3693 3694
| Name     | Type                     | Mandatory| Description                |
| ----------- | ------------------------- | ---- | -------------------- |
| callback    | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Yes  | Callback used to return the result. |
3695 3696 3697 3698 3699

**Error codes**

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

G
Gloria 已提交
3700
| ID| Error Message|
3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726
| ------- | ------------------------------ |
| 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>

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

G
Gloria 已提交
3727 3728 3729
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Promise used to return the window screenshot.|
3730 3731 3732 3733 3734

**Error codes**

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

G
Gloria 已提交
3735
| ID| Error Message|
3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754
| ------- | ------------------------------ |
| 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 已提交
3755
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).
3756 3757 3758 3759 3760 3761 3762

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

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

**Parameters**

G
Gloria 已提交
3763 3764 3765
| Name | Type  | Mandatory| Description                                                |
| ------- | ------ | ---- |----------------------------------------------------|
| opacity | number | Yes  | Opacity. The value is a floating point number in the range [0.0, 1.0]. The value **0.0** means completely transparent, and **1.0** means completely opaque.|
3766 3767 3768 3769 3770

**Error codes**

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

G
Gloria 已提交
3771
| ID| Error Message|
3772 3773
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
G
Gloria 已提交
3774
| 1300004 | Unauthorized operation.  |
3775 3776 3777 3778 3779 3780 3781 3782

**Example**

```js
try {
    windowClass.opacity(0.5);
} catch (exception) {
    console.error('Failed to opacity. Cause: ' + JSON.stringify(exception));
3783
}
3784 3785 3786 3787 3788 3789
```

### scale<sup>9+</sup>

scale(scaleOptions: ScaleOptions): void

G
Gloria 已提交
3790
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).
3791 3792 3793 3794 3795 3796 3797

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

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

**Parameters**

G
Gloria 已提交
3798 3799 3800
| Name      | Type                          | Mandatory| Description      |
| ------------ | ------------------------------ | ---- | ---------- |
| scaleOptions | [ScaleOptions](#scaleoptions9) | Yes  | Scale parameters to set.|
3801 3802 3803 3804 3805

**Error codes**

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

G
Gloria 已提交
3806
| ID| Error Message|
3807 3808
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
G
Gloria 已提交
3809
| 1300004 | Unauthorized operation.  |
3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823

**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));
3824
}
3825 3826 3827 3828 3829 3830
```

### rotate<sup>9+</sup>

rotate(rotateOptions: RotateOptions): void

G
Gloria 已提交
3831
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).
3832 3833 3834 3835 3836 3837 3838

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

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

**Parameters**

G
Gloria 已提交
3839 3840 3841
| Name       | Type                            | Mandatory| Description      |
| ------------- | -------------------------------- | ---- | ---------- |
| rotateOptions | [RotateOptions](#rotateoptions9) | Yes  | Rotation parameters to set.|
3842 3843 3844 3845 3846

**Error codes**

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

G
Gloria 已提交
3847
| ID| Error Message|
3848 3849
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
G
Gloria 已提交
3850
| 1300004 | Unauthorized operation.  |
3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865

**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));
3866
}
3867 3868 3869 3870 3871 3872
```

### translate<sup>9+</sup>

translate(translateOptions: TranslateOptions): void

G
Gloria 已提交
3873
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).
3874 3875 3876 3877 3878 3879 3880

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

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

**Parameters**

G
Gloria 已提交
3881 3882 3883
| Name          | Type                                  | Mandatory| Description                |
| ---------------- | -------------------------------------- | ---- | -------------------- |
| translateOptions | [TranslateOptions](#translateoptions9) | Yes  | Translation parameters. The unit is pixels.|
3884 3885 3886 3887 3888

**Error codes**

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

G
Gloria 已提交
3889
| ID| Error Message|
3890 3891
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
G
Gloria 已提交
3892
| 1300004 | Unauthorized operation.  |
3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905

**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));
3906
}
3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920
```

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

G
Gloria 已提交
3921 3922 3923
| Type                                          | Description            |
| ---------------------------------------------- | ---------------- |
| [TransitionController](#transitioncontroller9) | Transition animation controller.|
3924 3925 3926 3927 3928

**Error codes**

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

G
Gloria 已提交
3929
| ID| Error Message|
3930 3931
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
G
Gloria 已提交
3932
| 1300004 | Unauthorized operation.  |
3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958

**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)
        }    
      }, () => {
        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');
      }
3959
    );
3960
    console.info('complete transition end');
3961
};
3962 3963 3964 3965 3966 3967
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));
3968
});
3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982
```

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

G
Gloria 已提交
3983 3984 3985
| Name| Type  | Mandatory| Description                                              |
| ------ | ------ | ---- |--------------------------------------------------|
| radius | number | Yes  | Radius of the blur. The value is a floating point number greater than or equal to 0.0, and the value **0.0** means that the blur is disabled for the window.|
3986 3987 3988 3989 3990

**Error codes**

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

G
Gloria 已提交
3991
| ID| Error Message|
3992 3993
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
G
Gloria 已提交
3994
| 1300004 | Unauthorized operation.  |
3995 3996 3997 3998 3999 4000 4001 4002

**Example**

```js
try {
    windowClass.setBlur(4.0);
} catch (exception) {
    console.error('Failed to set blur. Cause: ' + JSON.stringify(exception));
4003
}
4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017
```

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

G
Gloria 已提交
4018 4019 4020
| Name| Type  | Mandatory| Description                                                   |
| ------ | ------ | ---- |-------------------------------------------------------|
| radius | number | Yes  | Radius of the blur. The value is a floating point number greater than or equal to 0.0, and the value **0.0** means that the blur is disabled for the background of the window.|
4021 4022 4023 4024 4025

**Error codes**

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

G
Gloria 已提交
4026
| ID| Error Message|
4027 4028
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
G
Gloria 已提交
4029
| 1300004 | Unauthorized operation.  |
4030 4031 4032 4033 4034 4035 4036 4037

**Example**

```js
try {
    windowClass.setBackdropBlur(4.0);
} catch (exception) {
    console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception));
4038
}
4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052
```

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

G
Gloria 已提交
4053 4054 4055
| Name   | Type     | Mandatory| Description                  |
| --------- | --------- | ---- | ---------------------- |
| blurStyle | [BlurStyle](#blurstyle9) | Yes  | Blur style to set for the background of the window.|
4056 4057 4058 4059 4060

**Error codes**

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

G
Gloria 已提交
4061
| ID| Error Message|
4062 4063
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
G
Gloria 已提交
4064
| 1300004 | Unauthorized operation.  |
4065 4066 4067 4068 4069 4070 4071 4072

**Example**

```js
try {
    windowClass.setBackdropBlurStyle(window.BlurStyle.THIN);
} catch (exception) {
    console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception));
4073
}
4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087
```

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

G
Gloria 已提交
4088 4089 4090
| Name | Type  | Mandatory| Description                                                         |
| ------- | ------ | ---- |-------------------------------------------------------------|
| radius  | number | Yes  | Radius of the shadow. The value is a floating point number greater than or equal to 0.0, and the value **0.0** means that the shadow is disabled for the window borders.    |
G
Gloria 已提交
4091
| 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**.|
G
Gloria 已提交
4092 4093
| offsetX | number | No  | Offset of the shadow along the x-axis, in pixels. The value is a floating point number.                             |
| offsetY | number | No  | Offset of the shadow along the y-axis, in pixels. The value is a floating point number.                             |
4094 4095 4096 4097 4098

**Error codes**

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

G
Gloria 已提交
4099
| ID| Error Message|
4100 4101
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
G
Gloria 已提交
4102
| 1300004 | Unauthorized operation.  |
4103 4104 4105 4106 4107 4108 4109 4110

**Example**

```js
try {
    windowClass.setShadow(4.0, '#FF00FF00', 2, 3);
} catch (exception) {
    console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception));
4111
}
4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125
```

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

G
Gloria 已提交
4126 4127 4128
| Name     | Type   | Mandatory| Description                                                |
| ----------- | ------- | ---- |----------------------------------------------------|
| radius | number | Yes  | Radius of the rounded corners. The value is a floating point number greater than or equal to 0.0. The value **0.0** means that the window does not use rounded corners.|
4129 4130 4131 4132 4133

**Error codes**

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

G
Gloria 已提交
4134
| ID| Error Message|
4135 4136
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
G
Gloria 已提交
4137
| 1300004 | Unauthorized operation.  |
4138 4139 4140 4141 4142 4143 4144 4145

**Example**

```js
try {
    windowClass.setCornerRadius(4.0);
} catch (exception) {
    console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception));
4146
}
4147 4148 4149 4150 4151 4152 4153 4154 4155
```

### 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**
G
Gloria 已提交
4156
> 
4157 4158 4159 4160 4161 4162
> 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**

G
Gloria 已提交
4163 4164 4165
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
4166 4167 4168 4169 4170 4171 4172 4173 4174 4175

**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.');
4176
});
4177 4178 4179 4180 4181 4182 4183 4184 4185
```

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

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

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

> **NOTE**
G
Gloria 已提交
4186
> 
4187 4188 4189 4190 4191 4192
> 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**

G
Gloria 已提交
4193 4194 4195
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
4196 4197 4198 4199 4200 4201 4202 4203 4204

**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));
4205
});
4206 4207 4208 4209 4210 4211 4212 4213 4214
```

### 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**
G
Gloria 已提交
4215
> 
4216 4217 4218 4219 4220 4221
> 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**

G
Gloria 已提交
4222 4223 4224
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
4225 4226 4227 4228 4229 4230 4231 4232 4233 4234

**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.');
4235
});
4236 4237 4238 4239 4240 4241 4242 4243 4244
```

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

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

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

> **NOTE**
G
Gloria 已提交
4245
> 
4246 4247 4248 4249 4250 4251
> 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**

G
Gloria 已提交
4252 4253 4254
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
4255 4256 4257 4258 4259 4260 4261 4262 4263

**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));
4264
});
4265 4266 4267 4268 4269 4270 4271 4272
```

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

4273 4274
This operation is not supported in a window in full-screen mode.

4275
> **NOTE**
G
Gloria 已提交
4276
> 
4277 4278 4279 4280 4281 4282
> 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**

G
Gloria 已提交
4283 4284
| Name  | Type                     | Mandatory| Description                                             |
| -------- | ------------------------- | ---- | ------------------------------------------------- |
G
Gloria 已提交
4285 4286
| 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. The value must be an integer.|
| y        | number                    | Yes  | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards. The value must be an integer.|
G
Gloria 已提交
4287
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                       |
4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306

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

4307 4308
This operation is not supported in a window in full-screen mode.

4309
> **NOTE**
G
Gloria 已提交
4310
> 
4311 4312 4313 4314 4315 4316
> 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**

G
Gloria 已提交
4317 4318
| Name| Type  | Mandatory| Description                                             |
| ------ | ------ | ---- | ------------------------------------------------- |
G
Gloria 已提交
4319 4320
| 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. The value must be an integer.|
| y      | number | Yes  | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards. The value must be an integer.|
4321 4322 4323

**Return value**

G
Gloria 已提交
4324 4325 4326
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
4327 4328 4329 4330 4331 4332 4333 4334 4335

**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));
4336
});
4337 4338 4339 4340 4341 4342 4343 4344
```

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

4345 4346 4347 4348 4349 4350
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.

4351 4352
This operation is not supported in a window in full-screen mode.

4353
> **NOTE**
G
Gloria 已提交
4354
> 
4355 4356 4357 4358 4359 4360
> 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**

G
Gloria 已提交
4361 4362
| Name  | Type                     | Mandatory| Description                      |
| -------- | ------------------------- | ---- | -------------------------- |
G
Gloria 已提交
4363 4364
| width    | number                    | Yes  | New width of the window, in px. The value must be an integer.|
| height   | number                    | Yes  | New height of the window, in px. The value must be an integer.|
G
Gloria 已提交
4365
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                |
4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384

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

4385 4386 4387 4388 4389 4390
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.

4391 4392
This operation is not supported in a window in full-screen mode.

4393
> **NOTE**
G
Gloria 已提交
4394
> 
4395 4396 4397 4398 4399 4400
> 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**

G
Gloria 已提交
4401 4402
| Name| Type  | Mandatory| Description                      |
| ------ | ------ | ---- | -------------------------- |
G
Gloria 已提交
4403 4404
| width  | number | Yes  | New width of the window, in px. The value must be an integer.|
| height | number | Yes  | New height of the window, in px. The value must be an integer.|
4405 4406 4407

**Return value**

G
Gloria 已提交
4408 4409 4410
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431

**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**
G
Gloria 已提交
4432
> 
4433 4434 4435 4436 4437 4438
> This API is supported since API version 7 and deprecated since API version 9.

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

**Parameters**

G
Gloria 已提交
4439 4440 4441 4442
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| type     | [WindowType](#windowtype7) | Yes  | Window type.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465

**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**
G
Gloria 已提交
4466
> 
4467 4468 4469 4470 4471 4472
> This API is supported since API version 7 and deprecated since API version 9.

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

**Parameters**

G
Gloria 已提交
4473 4474 4475
| Name| Type                     | Mandatory| Description      |
| ------ | ------------------------- | ---- | ---------- |
| type   | [WindowType](#windowtype7) | Yes  | Window type.|
4476 4477 4478

**Return value**

G
Gloria 已提交
4479 4480 4481
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501

**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**
G
Gloria 已提交
4502
> 
4503 4504 4505 4506 4507 4508
> 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**

G
Gloria 已提交
4509 4510 4511
| Name  | Type                                                      | Mandatory| Description                        |
| -------- | ---------------------------------------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;[WindowProperties](#windowproperties)&gt; | Yes  | Callback used to return the window properties.|
4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531

**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**
G
Gloria 已提交
4532
> 
4533 4534 4535 4536 4537 4538
> 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**

G
Gloria 已提交
4539 4540 4541
| Type                                                | Description                           |
| ---------------------------------------------------- | ------------------------------- |
| Promise&lt;[WindowProperties](#windowproperties)&gt; | Promise used to return the window properties.|
4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560

**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**
G
Gloria 已提交
4561
> 
4562
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getWindowAvoidArea()](#getwindowavoidarea9) instead.
4563 4564 4565 4566 4567

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

**Parameters**

G
Gloria 已提交
4568 4569 4570 4571
| 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.                            |
4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592

**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**
G
Gloria 已提交
4593
> 
4594
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getWindowAvoidArea()](#getwindowavoidarea9) instead.
4595 4596 4597 4598 4599

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

**Parameters**

G
Gloria 已提交
4600 4601 4602
| Name| Type                              | Mandatory| Description                                                        |
| ------ |----------------------------------| ---- | ------------------------------------------------------------ |
| type   | [AvoidAreaType](#avoidareatype7) | Yes  | Type of the area.|
4603 4604 4605

**Return value**

G
Gloria 已提交
4606 4607 4608
| Type                                     | Description                               |
|-----------------------------------------| ----------------------------------- |
| Promise&lt;[AvoidArea](#avoidarea7)&gt; | Promise used to return the area.|
4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628

**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**
G
Gloria 已提交
4629
> 
4630 4631 4632 4633 4634 4635
> 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**

G
Gloria 已提交
4636 4637 4638 4639
| 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.                                    |
4640 4641 4642 4643 4644 4645

**Example**

```js
let isFullScreen = true;
windowClass.setFullScreen(isFullScreen, (err) => {
4646
    if (err.code) {
4647
        console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
4648 4649
        return;
    }
4650 4651
    console.info('Succeeded in enabling the full-screen mode.');
});
4652
```
W
wusongqing 已提交
4653

4654
### setFullScreen<sup>(deprecated)</sup>
W
wusongqing 已提交
4655

4656
setFullScreen(isFullScreen: boolean): Promise&lt;void&gt;
W
wusongqing 已提交
4657

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

> **NOTE**
G
Gloria 已提交
4661
> 
4662
> 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 已提交
4663 4664 4665

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

4666 4667
**Parameters**

G
Gloria 已提交
4668 4669 4670
| 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.|
4671

W
wusongqing 已提交
4672
**Return value**
W
wusongqing 已提交
4673

G
Gloria 已提交
4674 4675 4676
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
4677

W
wusongqing 已提交
4678
**Example**
W
wusongqing 已提交
4679

4680
```js
4681 4682 4683 4684
let isFullScreen = true;
let promise = windowClass.setFullScreen(isFullScreen);
promise.then(()=> {
    console.info('Succeeded in enabling the full-screen mode.');
4685
}).catch((err)=>{
4686
    console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
4687 4688
});
```
W
wusongqing 已提交
4689

4690
### setLayoutFullScreen<sup>(deprecated)</sup>
W
wusongqing 已提交
4691

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

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

4696
> **NOTE**
G
Gloria 已提交
4697
> 
4698
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9) instead.
W
wusongqing 已提交
4699 4700 4701

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

W
wusongqing 已提交
4702
**Parameters**
W
wusongqing 已提交
4703

G
Gloria 已提交
4704 4705 4706 4707
| Name            | Type                     | Mandatory| Description                                                        |
| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ |
| isLayoutFullScreen | boolean                   | Yes  | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed. The value **true** means to enable the full-screen mode for the window layout, and **false** means the opposite.|
| callback           | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                                  |
W
wusongqing 已提交
4708

W
wusongqing 已提交
4709
**Example**
W
wusongqing 已提交
4710

4711
```js
4712 4713
let isLayoutFullScreen= true;
windowClass.setLayoutFullScreen(isLayoutFullScreen, (err) => {
4714
    if (err.code) {
4715
        console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
4716 4717
        return;
    }
4718 4719
    console.info('Succeeded in setting the window layout to full-screen mode.');
});
4720
```
W
wusongqing 已提交
4721

4722
### setLayoutFullScreen<sup>(deprecated)</sup>
W
wusongqing 已提交
4723

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

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

4728
> **NOTE**
G
Gloria 已提交
4729
> 
4730
> 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 已提交
4731 4732 4733

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

W
wusongqing 已提交
4734
**Parameters**
W
wusongqing 已提交
4735

G
Gloria 已提交
4736 4737 4738
| Name            | Type   | Mandatory| Description                                                        |
| ------------------ | ------- | ---- | ------------------------------------------------------------ |
| isLayoutFullScreen | boolean | Yes  | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed. The value **true** means to enable the full-screen mode for the window layout, and **false** means the opposite.|
W
wusongqing 已提交
4739

W
wusongqing 已提交
4740
**Return value**
W
wusongqing 已提交
4741

G
Gloria 已提交
4742 4743 4744
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
4745

W
wusongqing 已提交
4746
**Example**
W
wusongqing 已提交
4747

4748
```js
4749 4750 4751 4752
let isLayoutFullScreen = true;
let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen);
promise.then(()=> {
    console.info('Succeeded in setting the window layout to full-screen mode.');
4753
}).catch((err)=>{
4754
    console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
4755 4756
});
```
W
wusongqing 已提交
4757

4758
### setSystemBarEnable<sup>(deprecated)</sup>
W
wusongqing 已提交
4759

4760 4761 4762
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 已提交
4763

4764
> **NOTE**
G
Gloria 已提交
4765
> 
4766
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowSystemBarEnable()](#setwindowsystembarenable9) instead.
W
wusongqing 已提交
4767 4768 4769

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

W
wusongqing 已提交
4770
**Parameters**
W
wusongqing 已提交
4771

G
Gloria 已提交
4772 4773 4774 4775
| 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 已提交
4776

W
wusongqing 已提交
4777
**Example**
W
wusongqing 已提交
4778

4779
```js
4780 4781 4782
// In this example, the status bar and navigation bar are not displayed.
let names = [];
windowClass.setSystemBarEnable(names, (err) => {
4783
    if (err.code) {
4784
        console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
4785 4786
        return;
    }
4787 4788
    console.info('Succeeded in setting the system bar to be invisible.');
});
4789
```
W
wusongqing 已提交
4790

4791
### setSystemBarEnable<sup>(deprecated)</sup>
W
wusongqing 已提交
4792

4793
setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt;
W
wusongqing 已提交
4794

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

> **NOTE**
G
Gloria 已提交
4798
> 
4799
> 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 已提交
4800 4801 4802

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

4803 4804
**Parameters**

G
Gloria 已提交
4805 4806 4807
| 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.|
4808

W
wusongqing 已提交
4809
**Return value**
W
wusongqing 已提交
4810

G
Gloria 已提交
4811 4812 4813
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
4814

W
wusongqing 已提交
4815
**Example**
W
wusongqing 已提交
4816

4817
```js
4818 4819 4820 4821 4822
// 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.');
4823
}).catch((err)=>{
4824
    console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
4825 4826
});
```
W
wusongqing 已提交
4827

4828
### setSystemBarProperties<sup>(deprecated)</sup>
W
wusongqing 已提交
4829

4830 4831 4832
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 已提交
4833

4834
> **NOTE**
G
Gloria 已提交
4835
> 
4836
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowSystemBarProperties()](#setwindowsystembarproperties9) instead.
W
wusongqing 已提交
4837 4838 4839

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

W
wusongqing 已提交
4840
**Parameters**
W
wusongqing 已提交
4841

G
Gloria 已提交
4842 4843 4844 4845
| 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 已提交
4846

W
wusongqing 已提交
4847
**Example**
W
wusongqing 已提交
4848

4849
```js
4850 4851 4852 4853 4854 4855 4856 4857
let SystemBarProperties={
    statusBarColor: '#ff00ff',
    navigationBarColor: '#00ff00',
    // The following properties are supported since API version 8.
    statusBarContentColor:'#ffffff',
    navigationBarContentColor:'#00ffff'
};
windowClass.setSystemBarProperties(SystemBarProperties, (err) => {
4858
    if (err.code) {
4859
        console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
4860 4861
        return;
    }
4862
    console.info('Succeeded in setting the system bar properties.');
4863 4864
});
```
W
wusongqing 已提交
4865

4866
### setSystemBarProperties<sup>(deprecated)</sup>
W
wusongqing 已提交
4867

4868 4869 4870
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 已提交
4871

4872
> **NOTE**
G
Gloria 已提交
4873
> 
4874
> 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 已提交
4875 4876 4877

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

W
wusongqing 已提交
4878
**Parameters**
W
wusongqing 已提交
4879

G
Gloria 已提交
4880 4881 4882
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
W
wusongqing 已提交
4883

W
wusongqing 已提交
4884
**Return value**
W
wusongqing 已提交
4885

G
Gloria 已提交
4886 4887 4888
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
4889

W
wusongqing 已提交
4890
**Example**
W
wusongqing 已提交
4891

4892
```js
4893 4894 4895 4896 4897 4898 4899 4900 4901 4902
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.');
4903
}).catch((err)=>{
4904
    console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
4905
});
4906 4907
```

4908
### loadContent<sup>(deprecated)</sup>
4909

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

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

> **NOTE**
G
Gloria 已提交
4915
> 
4916
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setUIContent()](#setuicontent9) instead.
4917 4918 4919 4920 4921

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

**Parameters**

G
Gloria 已提交
4922 4923 4924 4925
| 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.          |
4926 4927 4928 4929

**Example**

```js
4930 4931 4932 4933 4934 4935
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.');
4936 4937
});
```
W
wusongqing 已提交
4938

4939
### loadContent<sup>(deprecated)</sup>
W
wusongqing 已提交
4940

4941
loadContent(path: string): Promise&lt;void&gt;
W
wusongqing 已提交
4942

4943 4944 4945
Loads content from a page to this window. This API uses a promise to return the result.

> **NOTE**
G
Gloria 已提交
4946
> 
4947
> 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 已提交
4948 4949 4950

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

W
wusongqing 已提交
4951
**Parameters**
W
wusongqing 已提交
4952

G
Gloria 已提交
4953 4954 4955
| Name| Type  | Mandatory| Description                |
| ------ | ------ | ---- | -------------------- |
| path   | string | Yes  | Path of the page from which the content will be loaded.|
W
wusongqing 已提交
4956

W
wusongqing 已提交
4957
**Return value**
W
wusongqing 已提交
4958

G
Gloria 已提交
4959 4960 4961
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
4962

W
wusongqing 已提交
4963
**Example**
W
wusongqing 已提交
4964

4965
```js
4966 4967 4968
let promise = windowClass.loadContent('pages/page2/page2');
promise.then(()=> {
    console.info('Succeeded in loading the content.');
4969
}).catch((err)=>{
4970
    console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
4971 4972
});
```
W
wusongqing 已提交
4973

4974
### isShowing<sup>(deprecated)</sup>
W
wusongqing 已提交
4975

4976
isShowing(callback: AsyncCallback&lt;boolean&gt;): void
W
wusongqing 已提交
4977

4978
Checks whether this window is displayed. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
4979

W
wusongqing 已提交
4980
> **NOTE**
G
Gloria 已提交
4981
> 
4982
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isWindowShowing()](#iswindowshowing9) instead.
W
wusongqing 已提交
4983 4984 4985 4986 4987

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

**Parameters**

G
Gloria 已提交
4988 4989 4990
| 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 已提交
4991 4992 4993

**Example**

4994
```js
4995
windowClass.isShowing((err, data) => {
4996
    if (err.code) {
4997
        console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err));
4998 4999
        return;
    }
5000
    console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
5001 5002
});
```
W
wusongqing 已提交
5003

5004
### isShowing<sup>(deprecated)</sup>
W
wusongqing 已提交
5005

5006
isShowing(): Promise&lt;boolean&gt;
W
wusongqing 已提交
5007

5008
Checks whether this window is displayed. This API uses a promise to return the result.
W
wusongqing 已提交
5009

W
wusongqing 已提交
5010
> **NOTE**
G
Gloria 已提交
5011
> 
5012
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isWindowShowing()](#iswindowshowing9) instead.
W
wusongqing 已提交
5013 5014 5015 5016 5017

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

**Return value**

G
Gloria 已提交
5018
| Type                  | Description                                                        |
5019
| ---------------------- | ------------------------------------------------------------ |
G
Gloria 已提交
5020
| 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 已提交
5021 5022 5023

**Example**

5024
```js
5025
let promise = windowClass.isShowing();
5026
promise.then((data)=> {
5027
    console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
5028
}).catch((err)=>{
5029
    console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err));
5030 5031
});
```
W
wusongqing 已提交
5032

5033 5034 5035
### on('systemAvoidAreaChange')<sup>(deprecated)</sup>

on(type: 'systemAvoidAreaChange', callback: Callback&lt;AvoidArea&gt;): void
W
wusongqing 已提交
5036

5037
Enables listening for changes to the area where the window cannot be displayed.
W
wusongqing 已提交
5038

5039
> **NOTE**
G
Gloria 已提交
5040
> 
5041
> This API is supported since API version 7 and deprecated since API version 9. Use [on('avoidAreaChange')](#onavoidareachange9) instead.
W
wusongqing 已提交
5042 5043 5044

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

W
wusongqing 已提交
5045
**Parameters**
W
wusongqing 已提交
5046

G
Gloria 已提交
5047 5048 5049 5050
| 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 已提交
5051

W
wusongqing 已提交
5052
**Example**
W
wusongqing 已提交
5053

5054
```js
5055 5056
windowClass.on('systemAvoidAreaChange', (data) => {
    console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
5057 5058
});
```
W
wusongqing 已提交
5059

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

5062
off(type: 'systemAvoidAreaChange', callback?: Callback&lt;AvoidArea&gt;): void
W
wusongqing 已提交
5063

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

> **NOTE**
G
Gloria 已提交
5067
> 
5068
> This API is supported since API version 7 and deprecated since API version 9. Use [off('avoidAreaChange')](#offavoidareachange9) instead.
W
wusongqing 已提交
5069 5070 5071

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

W
wusongqing 已提交
5072
**Parameters**
W
wusongqing 已提交
5073

G
Gloria 已提交
5074 5075 5076 5077
| 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 已提交
5078

W
wusongqing 已提交
5079
**Example**
W
wusongqing 已提交
5080

5081
```js
5082
windowClass.off('systemAvoidAreaChange');
5083
```
W
wusongqing 已提交
5084

5085
### isSupportWideGamut<sup>(deprecated)</sup>
W
wusongqing 已提交
5086

5087
isSupportWideGamut(callback: AsyncCallback&lt;boolean&gt;): void
W
wusongqing 已提交
5088

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

> **NOTE**
G
Gloria 已提交
5092
> 
5093
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [isWindowSupportWideGamut()](#iswindowsupportwidegamut9) instead.
W
wusongqing 已提交
5094 5095 5096

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

W
wusongqing 已提交
5097
**Parameters**
W
wusongqing 已提交
5098

G
Gloria 已提交
5099 5100 5101
| 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.|
5102 5103 5104 5105

**Example**

```js
5106
windowClass.isSupportWideGamut((err, data) => {
5107
    if (err.code) {
5108
        console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err));
5109 5110
        return;
    }
5111
    console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
5112
});
5113
```
5114

5115
### isSupportWideGamut<sup>(deprecated)</sup>
5116

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

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

5121
> **NOTE**
G
Gloria 已提交
5122
> 
5123
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [isWindowSupportWideGamut()](#iswindowsupportwidegamut9-1) instead.
5124

5125
**System capability**: SystemCapability.WindowManager.WindowManager.Core
5126 5127 5128

**Return value**

G
Gloria 已提交
5129
| Type                  | Description                                                        |
5130
| ---------------------- | ------------------------------------------------------------ |
G
Gloria 已提交
5131
| 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 已提交
5132

W
wusongqing 已提交
5133
**Example**
W
wusongqing 已提交
5134

5135
```js
5136 5137 5138
let promise = windowClass.isSupportWideGamut();
promise.then((data)=> {
    console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
5139
}).catch((err)=>{
5140
    console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
5141 5142
});
```
W
wusongqing 已提交
5143

5144
### setColorSpace<sup>(deprecated)</sup>
W
wusongqing 已提交
5145

5146
setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
5147

5148
Sets a color space for this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
5149

W
wusongqing 已提交
5150
> **NOTE**
G
Gloria 已提交
5151
> 
5152
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [setWindowColorSpace()](#setwindowcolorspace9) instead.
W
wusongqing 已提交
5153 5154 5155 5156 5157

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

**Parameters**

G
Gloria 已提交
5158 5159 5160 5161
| Name    | Type                     | Mandatory| Description        |
| ---------- | ------------------------- | ---- | ------------ |
| colorSpace | [ColorSpace](#colorspace8) | Yes  | Color space to set.|
| callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.  |
W
wusongqing 已提交
5162 5163 5164

**Example**

5165
```js
5166
windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => {
5167
    if (err.code) {
5168
        console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err));
5169 5170
        return;
    }
5171
    console.info('Succeeded in setting window colorspace.');
5172
});
5173
```
W
wusongqing 已提交
5174

5175
### setColorSpace<sup>(deprecated)</sup>
W
wusongqing 已提交
5176

5177
setColorSpace(colorSpace:ColorSpace): Promise&lt;void&gt;
W
wusongqing 已提交
5178

5179
Sets a color space for this window. This API uses a promise to return the result.
W
wusongqing 已提交
5180

W
wusongqing 已提交
5181
> **NOTE**
G
Gloria 已提交
5182
> 
5183
> 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 已提交
5184 5185 5186 5187 5188

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

**Parameters**

G
Gloria 已提交
5189 5190 5191
| Name    | Type                     | Mandatory| Description          |
| ---------- | ------------------------- | ---- | -------------- |
| colorSpace | [ColorSpace](#colorspace8) | Yes  | Color space to set.|
W
wusongqing 已提交
5192 5193 5194

**Return value**

G
Gloria 已提交
5195 5196 5197
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
5198 5199 5200

**Example**

5201
```js
5202 5203 5204
let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT);
promise.then(()=> {
    console.info('Succeeded in setting window colorspace.');
5205
}).catch((err)=>{
5206
    console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
5207 5208
});
```
W
wusongqing 已提交
5209

5210
### getColorSpace<sup>(deprecated)</sup>
W
wusongqing 已提交
5211

5212
getColorSpace(callback: AsyncCallback&lt;ColorSpace&gt;): void
W
wusongqing 已提交
5213

5214 5215 5216
Obtains the color space of this window. This API uses an asynchronous callback to return the result.

> **NOTE**
G
Gloria 已提交
5217
> 
5218
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getWindowColorSpace()](#getwindowcolorspace9) instead.
W
wusongqing 已提交
5219 5220 5221

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

W
wusongqing 已提交
5222
**Parameters**
W
wusongqing 已提交
5223

G
Gloria 已提交
5224 5225 5226
| Name  | Type                                          | Mandatory| Description                                                      |
| -------- | ---------------------------------------------- | ---- | ---------------------------------------------------------- |
| 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 已提交
5227

W
wusongqing 已提交
5228
**Example**
W
wusongqing 已提交
5229

5230
```js
5231
windowClass.getColorSpace((err, data) => {
5232
    if (err.code) {
5233
        console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err));
5234 5235
        return;
    }
5236
    console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data));
5237
});
5238
```
W
wusongqing 已提交
5239

5240
### getColorSpace<sup>(deprecated)</sup>
W
wusongqing 已提交
5241

5242
getColorSpace(): Promise&lt;ColorSpace&gt;
W
wusongqing 已提交
5243

5244
Obtains the color space of this window. This API uses a promise to return the result.
W
wusongqing 已提交
5245

5246
> **NOTE**
G
Gloria 已提交
5247
> 
5248
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getWindowColorSpace()](#getwindowcolorspace9) instead.
W
wusongqing 已提交
5249

5250
**System capability**: SystemCapability.WindowManager.WindowManager.Core
W
wusongqing 已提交
5251

W
wusongqing 已提交
5252
**Return value**
W
wusongqing 已提交
5253

G
Gloria 已提交
5254 5255 5256
| Type                                    | Description                           |
| ---------------------------------------- | ------------------------------- |
| Promise&lt;[ColorSpace](#colorspace8)&gt; | Promise used to return the current color space.|
W
wusongqing 已提交
5257

W
wusongqing 已提交
5258
**Example**
W
wusongqing 已提交
5259

5260
```js
5261
let promise = windowClass.getColorSpace();
5262
promise.then((data)=> {
5263
    console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data));
5264
}).catch((err)=>{
5265
    console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err));
5266
});
5267 5268
```

5269
### setBackgroundColor<sup>(deprecated)</sup>
W
wusongqing 已提交
5270

5271
setBackgroundColor(color: string, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
5272

5273
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 the call of [loadContent](#loadcontent9) or [setUIContent()](#setuicontent9) takes effect.
5274 5275

> **NOTE**
G
Gloria 已提交
5276
> 
5277
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowBackgroundColor()](#setwindowbackgroundcolor9) instead.
W
wusongqing 已提交
5278 5279 5280

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

W
wusongqing 已提交
5281
**Parameters**
W
wusongqing 已提交
5282

G
Gloria 已提交
5283 5284 5285 5286
| Name  | Type                     | Mandatory| Description                                                        |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| 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**.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                                  |
W
wusongqing 已提交
5287

W
wusongqing 已提交
5288
**Example**
W
wusongqing 已提交
5289

5290
```js
5291 5292
let color = '#00ff33';
windowClass.setBackgroundColor(color, (err) => {
5293
    if (err.code) {
5294
        console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
5295 5296
        return;
    }
5297
    console.info('Succeeded in setting the background color.');
5298 5299
});
```
W
wusongqing 已提交
5300

5301
### setBackgroundColor<sup>(deprecated)</sup>
W
wusongqing 已提交
5302

5303
setBackgroundColor(color: string): Promise&lt;void&gt;
W
wusongqing 已提交
5304

5305
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 the call of [loadContent](#loadcontent9) or [setUIContent()](#setuicontent9) takes effect.
5306 5307

> **NOTE**
G
Gloria 已提交
5308
> 
5309
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowBackgroundColor()](#setwindowbackgroundcolor9) instead.
W
wusongqing 已提交
5310 5311 5312

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

W
wusongqing 已提交
5313
**Parameters**
W
wusongqing 已提交
5314

G
Gloria 已提交
5315 5316 5317
| Name| Type  | Mandatory| Description                                                        |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| 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 已提交
5318

W
wusongqing 已提交
5319
**Return value**
W
wusongqing 已提交
5320

G
Gloria 已提交
5321 5322 5323
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
5324

W
wusongqing 已提交
5325
**Example**
W
wusongqing 已提交
5326

5327
```js
5328 5329 5330 5331
let color = '#00ff33';
let promise = windowClass.setBackgroundColor(color);
promise.then(()=> {
    console.info('Succeeded in setting the background color.');
5332
}).catch((err)=>{
5333
    console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
5334 5335 5336
});
```

5337
### setBrightness<sup>(deprecated)</sup>
5338

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

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

5343 5344
When the screen brightness setting for the window takes effect, Control Panel cannot adjust the system screen brightness. It can do so only after the window screen brightness is restored to the default value.

5345
> **NOTE**
G
Gloria 已提交
5346
> 
5347
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowBrightness()](#setwindowbrightness9) instead.
5348 5349 5350 5351 5352

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

**Parameters**

G
Gloria 已提交
5353 5354 5355 5356
| Name    | Type                     | Mandatory| Description                                   |
| ---------- | ------------------------- | ---- |---------------------------------------|
| brightness | number                    | Yes  | Brightness to set. The value is a floating point number in the range [0.0, 1.0], and the value **1.0** means the brightest.|
| callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                |
5357 5358 5359 5360

**Example**

```js
5361 5362
let brightness = 1;
windowClass.setBrightness(brightness, (err) => {
5363
    if (err.code) {
5364
        console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
5365 5366
        return;
    }
5367
    console.info('Succeeded in setting the brightness.');
5368 5369 5370
});
```

5371
### setBrightness<sup>(deprecated)</sup>
5372

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

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

5377 5378
When the screen brightness setting for the window takes effect, Control Panel cannot adjust the system screen brightness. It can do so only after the window screen brightness is restored to the default value.

5379
> **NOTE**
G
Gloria 已提交
5380
> 
5381
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowBrightness()](#setwindowbrightness9-1) instead.
5382 5383 5384 5385 5386

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

**Parameters**

G
Gloria 已提交
5387 5388 5389
| Name    | Type  | Mandatory| Description                                      |
| ---------- | ------ | ---- |------------------------------------------|
| brightness | number | Yes  | Brightness to set. The value is a floating point number in the range [0.0, 1.0], and the value **1.0** means the brightest.|
5390 5391 5392

**Return value**

G
Gloria 已提交
5393 5394 5395
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
5396 5397 5398 5399

**Example**

```js
5400 5401 5402 5403
let brightness = 1;
let promise = windowClass.setBrightness(brightness);
promise.then(()=> {
    console.info('Succeeded in setting the brightness.');
5404
}).catch((err)=>{
5405
    console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
5406 5407
});
```
W
wusongqing 已提交
5408

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

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

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

> **NOTE**
G
Gloria 已提交
5416
> 
5417
> This API cannot be used. This API is supported since API version 7 and deprecated since API version 9.
5418 5419 5420 5421 5422

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

**Parameters**

G
Gloria 已提交
5423 5424 5425 5426
| Name        | Type                     | Mandatory| Description                                    |
| -------------- | ------------------------- | ---- |----------------------------------------|
| dimBehindValue | number                    | Yes  | Dimness of the window to set. The value range is [0.0, 1.0], and the value **1.0** means the dimmest.|
| callback       | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                 |
5427 5428 5429 5430

**Example**

```js
5431
windowClass.setDimBehind(0.5, (err) => {
5432
    if (err.code) {
5433
        console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
5434 5435
        return;
    }
5436
    console.info('Succeeded in setting the dimness.');
5437 5438 5439
});
```

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

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

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

> **NOTE**
G
Gloria 已提交
5447
> 
5448
> This API cannot be used. This API is supported since API version 7 and deprecated since API version 9.
5449 5450 5451

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

5452 5453
**Parameters**

G
Gloria 已提交
5454 5455 5456
| 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.|
5457

5458 5459
**Return value**

G
Gloria 已提交
5460 5461 5462
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
5463 5464 5465 5466

**Example**

```js
5467 5468 5469
let promise = windowClass.setDimBehind(0.5);
promise.then(()=> {
    console.info('Succeeded in setting the dimness.');
5470
}).catch((err)=>{
5471
    console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
5472 5473 5474
});
```

5475
### setFocusable<sup>(deprecated)</sup>
5476

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

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

5481
> **NOTE**
G
Gloria 已提交
5482
> 
5483
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowFocusable()](#setwindowfocusable9) instead.
5484 5485 5486 5487 5488

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

**Parameters**

G
Gloria 已提交
5489 5490 5491 5492
| 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.                  |
5493 5494 5495 5496

**Example**

```js
5497 5498 5499 5500 5501 5502 5503 5504
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.');
});
5505 5506
```

5507
### setFocusable<sup>(deprecated)</sup>
5508

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

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

5513
> **NOTE**
G
Gloria 已提交
5514
> 
5515
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowFocusable()](#setwindowfocusable9-1) instead.
5516 5517 5518 5519 5520

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

**Parameters**

G
Gloria 已提交
5521 5522 5523
| 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.|
5524 5525 5526

**Return value**

G
Gloria 已提交
5527 5528 5529
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
5530 5531 5532 5533

**Example**

```js
5534 5535 5536 5537 5538 5539 5540
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));
});
5541 5542
```

5543
### setKeepScreenOn<sup>(deprecated)</sup>
5544

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

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

5549
> **NOTE**
G
Gloria 已提交
5550
> 
5551
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowKeepScreenOn()](#setwindowkeepscreenon9) instead.
5552 5553 5554 5555 5556

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

**Parameters**

G
Gloria 已提交
5557 5558 5559 5560
| 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.              |
5561 5562 5563 5564

**Example**

```js
5565 5566 5567 5568 5569 5570 5571 5572
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.');
});
5573 5574
```

5575
### setKeepScreenOn<sup>(deprecated)</sup>
5576

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

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

5581
> **NOTE**
G
Gloria 已提交
5582
> 
5583
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowKeepScreenOn()](#setwindowkeepscreenon9-1) instead.
5584 5585 5586 5587 5588

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

**Parameters**

G
Gloria 已提交
5589 5590 5591
| 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.|
5592 5593 5594

**Return value**

G
Gloria 已提交
5595 5596 5597
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
5598 5599 5600 5601

**Example**

```js
5602 5603 5604 5605 5606 5607 5608
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));
});
5609 5610
```

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

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

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

5617
> **NOTE**
G
Gloria 已提交
5618
> 
5619
> This API cannot be used. This API is supported since API version 7 and deprecated since API version 9.
5620 5621 5622 5623 5624

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

**Parameters**

G
Gloria 已提交
5625 5626 5627 5628
| 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.      |
5629 5630 5631 5632

**Example**

```js
5633 5634 5635 5636 5637 5638
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.');
5639
});
5640 5641
```

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

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

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

5648
> **NOTE**
G
Gloria 已提交
5649
> 
5650
> This API cannot be used. This API is supported since API version 7 and deprecated since API version 9.
5651 5652 5653 5654 5655

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

**Parameters**

G
Gloria 已提交
5656 5657 5658
| 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.|
5659 5660 5661

**Return value**

G
Gloria 已提交
5662 5663 5664
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
5665 5666 5667 5668

**Example**

```js
5669 5670 5671 5672 5673 5674
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));
});
5675 5676
```

5677
### setPrivacyMode<sup>(deprecated)</sup>
5678

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

5681
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.
5682

5683
> **NOTE**
G
Gloria 已提交
5684
> 
5685
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowPrivacyMode()](#setwindowprivacymode9) instead.
5686 5687 5688 5689 5690

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

**Parameters**

G
Gloria 已提交
5691 5692 5693 5694
| 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.          |
5695 5696 5697 5698

**Example**

```js
5699 5700 5701 5702 5703 5704 5705 5706
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.');
});
5707 5708
```

5709
### setPrivacyMode<sup>(deprecated)</sup>
5710

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

5713
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.
5714

5715
> **NOTE**
G
Gloria 已提交
5716
> 
5717
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowPrivacyMode()](#setwindowprivacymode9-1) instead.
5718 5719 5720 5721 5722

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

**Parameters**

G
Gloria 已提交
5723 5724 5725
| 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.|
5726 5727 5728

**Return value**

G
Gloria 已提交
5729 5730 5731
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
5732 5733 5734 5735

**Example**

```js
5736 5737 5738 5739 5740 5741 5742
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));
});
5743 5744
```

5745
### setTouchable<sup>(deprecated)</sup>
5746

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

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

5751
> **NOTE**
G
Gloria 已提交
5752
> 
5753
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowTouchable()](#setwindowtouchable9) instead.
5754 5755 5756 5757 5758

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

**Parameters**

G
Gloria 已提交
5759 5760 5761 5762
| 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.          |
5763 5764 5765 5766

**Example**

```js
5767 5768 5769 5770 5771 5772 5773 5774
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.');
});
5775 5776
```

5777
### setTouchable<sup>(deprecated)</sup>
5778

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

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

5783
> **NOTE**
G
Gloria 已提交
5784
> 
5785
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowTouchable()](#setwindowtouchable9-1) instead.
5786 5787 5788

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

5789 5790
**Parameters**

G
Gloria 已提交
5791 5792 5793
| 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.|
5794

5795 5796
**Return value**

G
Gloria 已提交
5797 5798 5799
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
5800 5801 5802 5803

**Example**

```js
5804 5805 5806 5807 5808 5809 5810
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));
});
5811 5812
```

W
wusongqing 已提交
5813
## WindowStageEventType<sup>9+</sup>
W
wusongqing 已提交
5814 5815 5816

Describes the lifecycle of a window stage.

5817
**Model restriction**: This API can be used only in the stage model.
5818

W
wusongqing 已提交
5819 5820
**System capability**: SystemCapability.WindowManager.WindowManager.Core

G
Gloria 已提交
5821 5822 5823 5824 5825 5826
| 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 已提交
5827 5828 5829

## WindowStage<sup>9+</sup>

5830 5831
Implements a window manager, which manages each basic window unit, that is, [Window](#window) instance.

G
Gloria 已提交
5832
Before calling any of the following APIs, you must use [onWindowStageCreate()](js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate) to create a **WindowStage** instance.
5833 5834 5835 5836 5837 5838 5839

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

5840
**Model restriction**: This API can be used only in the stage model.
5841 5842 5843 5844 5845

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

**Parameters**

G
Gloria 已提交
5846 5847 5848
| Name  | Type                                  | Mandatory| Description                                         |
| -------- | -------------------------------------- | ---- | --------------------------------------------- |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the main window.|
5849 5850 5851 5852 5853

**Error codes**

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

G
Gloria 已提交
5854
| ID| Error Message|
5855 5856 5857
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
5858 5859

**Example**
W
wusongqing 已提交
5860

5861
```ts
G
Gloria 已提交
5862
import UIAbility from '@ohos.app.ability.UIAbility';
5863

G
Gloria 已提交
5864
class myAbility extends UIAbility {
5865 5866
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
5867
        let windowClass = null;
5868 5869 5870 5871 5872 5873 5874 5875 5876
        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));
        });
    }
5877
};
5878
```
5879

W
wusongqing 已提交
5880 5881 5882 5883 5884 5885
### 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.

5886
**Model restriction**: This API can be used only in the stage model.
5887

W
wusongqing 已提交
5888 5889
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
5890
**Return value**
W
wusongqing 已提交
5891

G
Gloria 已提交
5892 5893 5894
| Type                            | Description                                            |
| -------------------------------- | ------------------------------------------------ |
| Promise&lt;[Window](#window)&gt; | Promise used to return the main window.|
5895 5896 5897 5898 5899

**Error codes**

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

G
Gloria 已提交
5900
| ID| Error Message|
5901 5902 5903
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
5904

W
wusongqing 已提交
5905
**Example**
W
wusongqing 已提交
5906

5907
```ts
G
Gloria 已提交
5908
import UIAbility from '@ohos.app.ability.UIAbility';
5909

G
Gloria 已提交
5910
class myAbility extends UIAbility {
5911 5912
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
5913
        let windowClass = null;
5914
        let promise = windowStage.getMainWindow();
5915
        promise.then((data) => {
5916 5917
        windowClass = data;
            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
5918
        }).catch((err) => {
5919 5920 5921
            console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
        });
    }
5922
};
5923
```
5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936

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

G
Gloria 已提交
5937 5938 5939
| Type| Description|
| ----------------- | --------------------------------- |
| [Window](#window) | return the main window.|
5940 5941 5942 5943 5944

**Error codes**

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

G
Gloria 已提交
5945
| ID| Error Message|
5946 5947 5948 5949 5950 5951 5952
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |

**Example**

```ts
G
Gloria 已提交
5953
import UIAbility from '@ohos.app.ability.UIAbility';
5954

G
Gloria 已提交
5955
class myAbility extends UIAbility {
5956 5957 5958 5959 5960 5961 5962 5963
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        try {
            let windowClass = windowStage.getMainWindowSync();
        } catch (exception) {
            console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception));
        };
    }
5964
};
5965 5966
```

5967
### createSubWindow<sup>9+</sup>
W
wusongqing 已提交
5968

5969
createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void
W
wusongqing 已提交
5970

5971
Creates a subwindow for this window stage. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
5972

5973
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
5974 5975 5976

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

W
wusongqing 已提交
5977
**Parameters**
W
wusongqing 已提交
5978

G
Gloria 已提交
5979 5980 5981 5982
| Name  | Type                                  | Mandatory| Description                                         |
| -------- | -------------------------------------- | ---- | --------------------------------------------- |
| name     | string                                 | Yes  | Name of the subwindow.                               |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the subwindow.|
5983 5984 5985 5986 5987

**Error codes**

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

G
Gloria 已提交
5988
| ID| Error Message|
5989 5990 5991
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
5992

W
wusongqing 已提交
5993
**Example**
W
wusongqing 已提交
5994

5995
```ts
G
Gloria 已提交
5996
import UIAbility from '@ohos.app.ability.UIAbility';
5997

G
Gloria 已提交
5998
class myAbility extends UIAbility {
5999 6000
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6001
        let windowClass = null;
6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014
        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));
        };
6015
    }
6016
};
6017
```
W
wusongqing 已提交
6018 6019 6020 6021 6022 6023
### 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.

6024
**Model restriction**: This API can be used only in the stage model.
6025

W
wusongqing 已提交
6026
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
6027

W
wusongqing 已提交
6028
**Parameters**
W
wusongqing 已提交
6029

G
Gloria 已提交
6030 6031 6032
| Name| Type  | Mandatory| Description          |
| ------ | ------ | ---- | -------------- |
| name   | string | Yes  | Name of the subwindow.|
G
ge-yafang 已提交
6033

W
wusongqing 已提交
6034
**Return value**
W
wusongqing 已提交
6035

G
Gloria 已提交
6036 6037 6038
| Type                            | Description                                            |
| -------------------------------- | ------------------------------------------------ |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow.|
6039 6040 6041 6042 6043

**Error codes**

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

G
Gloria 已提交
6044
| ID| Error Message|
6045 6046 6047
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
G
ge-yafang 已提交
6048

W
wusongqing 已提交
6049
**Example**
W
wusongqing 已提交
6050

6051
```ts
G
Gloria 已提交
6052
import UIAbility from '@ohos.app.ability.UIAbility';
6053

G
Gloria 已提交
6054
class myAbility extends UIAbility {
6055 6056
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6057
        let windowClass = null;
6058 6059
        try {
            let promise = windowStage.createSubWindow('mySubWindow');
6060
            promise.then((data) => {
6061 6062
                windowClass = data;
                console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
6063
            }).catch((err) => {
6064 6065 6066 6067 6068
                console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
            });
        } catch (exception) {
            console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
        };
6069
    }
6070
};
6071
```
6072

6073
### getSubWindow<sup>9+</sup>
W
wusongqing 已提交
6074

6075
getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void
W
wusongqing 已提交
6076

6077
Obtains all the subwindows of this window stage. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
6078

6079
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
6080 6081 6082

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

W
wusongqing 已提交
6083
**Parameters**
W
wusongqing 已提交
6084

G
Gloria 已提交
6085 6086 6087
| Name  | Type                                               | Mandatory| Description                                             |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[Window](#window)&gt;&gt; | Yes  | Callback used to return all the subwindows.|
6088 6089 6090 6091 6092

**Error codes**

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

G
Gloria 已提交
6093
| ID| Error Message|
6094 6095
| ------- | ------------------------------ |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
6096

W
wusongqing 已提交
6097
**Example**
W
wusongqing 已提交
6098

6099
```ts
G
Gloria 已提交
6100
import UIAbility from '@ohos.app.ability.UIAbility';
6101

G
Gloria 已提交
6102
class myAbility extends UIAbility {
6103 6104
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6105
        let windowClass = null;
6106 6107 6108 6109 6110 6111 6112 6113 6114
        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));
        });
    }
6115
};
6116
```
W
wusongqing 已提交
6117 6118 6119 6120 6121 6122
### 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.

6123
**Model restriction**: This API can be used only in the stage model.
6124

W
wusongqing 已提交
6125
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
6126

W
wusongqing 已提交
6127
**Return value**
W
wusongqing 已提交
6128

G
Gloria 已提交
6129 6130 6131
| Type                                         | Description                                                |
| --------------------------------------------- | ---------------------------------------------------- |
| Promise&lt;Array&lt;[Window](#window)&gt;&gt; | Promise used to return all the subwindows.|
6132 6133 6134 6135 6136

**Error codes**

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

G
Gloria 已提交
6137
| ID| Error Message|
6138 6139
| ------- | ------------------------------ |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
6140

W
wusongqing 已提交
6141
**Example**
W
wusongqing 已提交
6142

6143
```ts
G
Gloria 已提交
6144
import UIAbility from '@ohos.app.ability.UIAbility';
6145

G
Gloria 已提交
6146
class myAbility extends UIAbility {
6147 6148
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6149
        let windowClass = null;
6150
        let promise = windowStage.getSubWindow();
6151
        promise.then((data) => {
6152 6153
            windowClass = data;
            console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
6154
        }).catch((err) => {
6155 6156 6157
            console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
        })
    }
6158
};
6159 6160
```
### loadContent<sup>9+</sup>
W
wusongqing 已提交
6161

6162
loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
6163

6164
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 已提交
6165

6166
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
6167 6168

**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
6169

W
wusongqing 已提交
6170
**Parameters**
W
wusongqing 已提交
6171

G
Gloria 已提交
6172 6173 6174 6175 6176
| 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.                                                  |
6177 6178 6179 6180 6181

**Error codes**

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

G
Gloria 已提交
6182
| ID| Error Message|
6183 6184 6185
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
6186

W
wusongqing 已提交
6187
**Example**
W
wusongqing 已提交
6188

6189
```ts
G
Gloria 已提交
6190
import UIAbility from '@ohos.app.ability.UIAbility';
6191

G
Gloria 已提交
6192
class myAbility extends UIAbility {
6193
    storage : LocalStorage
6194 6195
    onWindowStageCreate(windowStage) {
        this.storage = new LocalStorage();
6196
        this.storage.setOrCreate('storageSimpleProp',121);
6197
        console.log('onWindowStageCreate');
6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208
        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));
        };
6209
    }
6210
};
6211 6212 6213 6214 6215 6216 6217 6218
```

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

6219
**Model restriction**: This API can be used only in the stage model.
6220 6221 6222 6223 6224

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

**Parameters**

G
Gloria 已提交
6225 6226 6227 6228
| 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.|
6229 6230 6231

**Return value**

G
Gloria 已提交
6232 6233 6234
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
6235 6236 6237 6238 6239

**Error codes**

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

G
Gloria 已提交
6240
| ID| Error Message|
6241 6242 6243
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
6244 6245 6246 6247

**Example**

```ts
G
Gloria 已提交
6248
import UIAbility from '@ohos.app.ability.UIAbility';
6249

G
Gloria 已提交
6250
class myAbility extends UIAbility {
6251
    storage : LocalStorage
6252 6253
    onWindowStageCreate(windowStage) {
        this.storage = new LocalStorage();
6254
        this.storage.setOrCreate('storageSimpleProp',121);
6255
        console.log('onWindowStageCreate');
6256 6257
        try {
            let promise = windowStage.loadContent('pages/page2',this.storage);
6258
            promise.then(() => {
6259
                console.info('Succeeded in loading the content.');
6260
            }).catch((err) => {
6261 6262 6263 6264 6265
                console.error('Failed to load the content. Cause:' + JSON.stringify(err));
            });
        } catch (exception) {
            console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
        };
6266
    }
6267
};
6268
```
W
wusongqing 已提交
6269 6270 6271 6272 6273

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

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

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

6276
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
6277

6278
**System capability**: SystemCapability.WindowManager.WindowManager.Core
W
wusongqing 已提交
6279

W
wusongqing 已提交
6280
**Parameters**
W
wusongqing 已提交
6281

G
Gloria 已提交
6282 6283 6284 6285
| 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.          |
6286 6287 6288 6289 6290

**Error codes**

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

G
Gloria 已提交
6291
| ID| Error Message|
6292 6293 6294
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
6295 6296 6297 6298

**Example**

```ts
G
Gloria 已提交
6299
import UIAbility from '@ohos.app.ability.UIAbility';
6300

G
Gloria 已提交
6301
class myAbility extends UIAbility {
6302 6303
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314
        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));
        };
6315
    }
6316
};
6317
```
G
ge-yafang 已提交
6318

W
wusongqing 已提交
6319 6320 6321 6322 6323 6324
### on('windowStageEvent')<sup>9+</sup>

on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void

Enables listening for window stage lifecycle changes.

6325
**Model restriction**: This API can be used only in the stage model.
6326

W
wusongqing 已提交
6327
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
6328

W
wusongqing 已提交
6329
**Parameters**
W
wusongqing 已提交
6330

G
Gloria 已提交
6331 6332 6333 6334
| 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.               |
6335 6336 6337 6338 6339

**Error codes**

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

G
Gloria 已提交
6340
| ID| Error Message|
6341 6342 6343
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
6344

W
wusongqing 已提交
6345
**Example**
W
wusongqing 已提交
6346

6347
```ts
G
Gloria 已提交
6348
import UIAbility from '@ohos.app.ability.UIAbility';
6349

G
Gloria 已提交
6350
class myAbility extends UIAbility {
6351 6352
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6353 6354 6355 6356 6357 6358 6359 6360 6361
        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));
        };
6362
    }
6363
};
6364
```
W
wusongqing 已提交
6365 6366 6367 6368 6369 6370 6371

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

off(eventType: 'windowStageEvent', callback?: Callback&lt;WindowStageEventType&gt;): void

Disables listening for window stage lifecycle changes.

6372
**Model restriction**: This API can be used only in the stage model.
6373

W
wusongqing 已提交
6374
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
6375

W
wusongqing 已提交
6376
**Parameters**
W
wusongqing 已提交
6377

G
Gloria 已提交
6378 6379 6380 6381
| 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.               |
6382 6383 6384 6385 6386

**Error codes**

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

G
Gloria 已提交
6387
| ID| Error Message|
6388 6389 6390
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
G
ge-yafang 已提交
6391

W
wusongqing 已提交
6392
**Example**
W
wusongqing 已提交
6393

6394
```ts
G
Gloria 已提交
6395
import UIAbility from '@ohos.app.ability.UIAbility';
6396

G
Gloria 已提交
6397
class myAbility extends UIAbility {
6398 6399
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6400 6401 6402 6403 6404 6405
        try {
            windowStage.off('windowStageEvent');
        } catch (exception) {
            console.error('Failed to disable the listener for window stage event changes. Cause:' +
                JSON.stringify(exception));
        };
6406
    }
6407
};
6408 6409 6410 6411 6412 6413 6414
```

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

disableWindowDecor(): void

Disables window decorators.
W
wusongqing 已提交
6415

6416
**Model restriction**: This API can be used only in the stage model.
6417

6418
**System API**: This is a system API.
6419 6420 6421

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

6422 6423 6424 6425
**Error codes**

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

G
Gloria 已提交
6426
| ID| Error Message|
6427 6428 6429 6430
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |

6431 6432 6433
**Example**

```ts
G
Gloria 已提交
6434
import UIAbility from '@ohos.app.ability.UIAbility';
6435

G
Gloria 已提交
6436
class myAbility extends UIAbility {
6437 6438 6439 6440
    onWindowStageCreate(windowStage) {
        console.log('disableWindowDecor');
        windowStage.disableWindowDecor();
    }
6441
};
6442 6443 6444
```

### setShowOnLockScreen()<sup>9+</sup>
W
wusongqing 已提交
6445 6446 6447 6448 6449

setShowOnLockScreen(showOnLockScreen: boolean): void

Sets whether to display the window of the application on the lock screen.

6450 6451 6452
**System API**: This is a system API.

**Model restriction**: This API can be used only in the stage model.
6453

W
wusongqing 已提交
6454 6455 6456 6457
**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

G
Gloria 已提交
6458 6459 6460
| 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.|
6461 6462 6463 6464 6465

**Error codes**

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

G
Gloria 已提交
6466
| ID| Error Message|
6467 6468 6469
| ------- | ------------------------------ |
| 1300002 | This window state is abnormal. |
| 1300005 | This window stage is abnormal. |
W
wusongqing 已提交
6470 6471 6472 6473

**Example**

```ts
G
Gloria 已提交
6474
import UIAbility from '@ohos.app.ability.UIAbility';
6475

G
Gloria 已提交
6476
class myAbility extends UIAbility {
W
wusongqing 已提交
6477 6478
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
6479 6480 6481 6482 6483
        try {
            windowStage.setShowOnLockScreen(true);
        } catch (exception) {
            console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception));
        };
W
wusongqing 已提交
6484
    }
6485
};
W
wusongqing 已提交
6486
```
6487 6488 6489 6490
## TransitionContext<sup>9+</sup>

Provides the context for the transition animation.

6491
### Attributes
6492

6493
**System API**: This is a system API.
6494 6495 6496

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

G
Gloria 已提交
6497 6498 6499
| Name                 | Type         | Readable| Writable| Description            |
| --------------------- | ----------------- | ---- | ---- | ---------------- |
| toWindow<sup>9+</sup> | [Window](#window) | Yes  | Yes  | Target window to display the animation.|
6500 6501 6502 6503 6504

### completeTransition<sup>9+</sup>

completeTransition(isCompleted: boolean): void

6505 6506 6507
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.
6508 6509 6510 6511 6512

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

**Parameters**

G
Gloria 已提交
6513 6514 6515
| 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.|
6516 6517 6518 6519 6520 6521

**Example**

```js
let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => {
6522
	let toWindow = context.toWindow;
6523 6524 6525 6526 6527 6528
 	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.
6529
        playMode: PlayMode.Normal // Animation playback mode.
6530
      }, () => {
6531
        let obj : window.TranslateOptions = {
6532 6533 6534
          x : 100.0,
          y : 0.0,
          z : 0.0
6535
        };
6536 6537 6538
        toWindow.translate(obj);
        console.info('toWindow translate end');
      }
6539
    );
6540 6541 6542 6543 6544
    try {
        context.completeTransition(true)
    } catch (exception) {
        console.info('toWindow translate fail. Cause: ' + JSON.stringify(exception));
    }
6545
    console.info('complete transition end');
6546
};
6547 6548 6549 6550 6551 6552 6553 6554 6555 6556
```

## TransitionController<sup>9+</sup>

Implements the transition animation controller.

### animationForShown<sup>9+</sup>

animationForShown(context: TransitionContext): void

6557 6558 6559
Customizes the animation for the scenario when the window is shown.

**System API**: This is a system API.
6560 6561 6562 6563 6564

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

**Parameters**

G
Gloria 已提交
6565 6566 6567
| Name | Type                                    | Mandatory| Description                |
| ------- | ---------------------------------------- | ---- | -------------------- |
| context | [TransitionContext](#transitioncontext9) | Yes  | Context of the transition animation.|
6568 6569 6570 6571 6572 6573

**Example**

```js
let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => {
6574
	let toWindow = context.toWindow;
6575 6576 6577 6578 6579 6580
 	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.
6581 6582 6583 6584
        playMode: PlayMode.Normal // Animation playback mode.
        onFinish: ()=> {
            context.completeTransition(true)
        }  
6585
      }, () => {
6586
        let obj : window.TranslateOptions = {
6587 6588 6589
          x : 100.0,
          y : 0.0,
          z : 0.0
6590
        };
6591 6592 6593
        toWindow.translate(obj);
        console.info('toWindow translate end');
      }
6594
    );
6595
    console.info('complete transition end');
6596
};
6597 6598 6599 6600 6601 6602
```

### animationForHidden<sup>9+</sup>

animationForHidden(context: TransitionContext): void

6603 6604 6605
Customizes the animation for the scenario when the window is hidden.

**System API**: This is a system API.
6606 6607 6608 6609 6610

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

**Parameters**

G
Gloria 已提交
6611 6612 6613
| Name | Type                                    | Mandatory| Description                |
| ------- | ---------------------------------------- | ---- | -------------------- |
| context | [TransitionContext](#transitioncontext9) | Yes  | Context of the transition animation.|
6614 6615 6616 6617 6618 6619

**Example**

```js
let controller = windowClass.getTransitionController();
controller.animationForHidden = (context : window.TransitionContext) => {
6620
	let toWindow = context.toWindow;
6621 6622 6623 6624 6625 6626
 	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.
6627 6628 6629 6630
        playMode: PlayMode.Normal // Animation playback mode.
        onFinish: ()=> {
            context.completeTransition(true)
        }  
6631
      }, () => {
6632
        let obj : window.TranslateOptions = {
6633 6634 6635
          x : 100.0,
          y : 0.0,
          z : 0.0
6636
        };
6637 6638 6639 6640 6641
        toWindow.translate(obj);
        console.info('toWindow translate end');
      }
    )
    console.info('complete transition end');
6642
};
G
Gloria 已提交
6643
```