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

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

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

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

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

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

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

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

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

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

26
| Name             | Value| Description              |
W
wusongqing 已提交
27
| ----------------- | ------ | ------------------ |
28
| TYPE_APP          | 0      | Application subwindow. This type 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. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_STATUS_BAR<sup>9+</sup>   | 3      | Status bar. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_PANEL<sup>9+</sup>        | 4      | Notification panel. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_KEYGUARD<sup>9+</sup>     | 5      | Lock screen. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_VOLUME_OVERLAY<sup>9+</sup> | 6      | Volume bar. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_NAVIGATION_BAR<sup>9+</sup> | 7      | Navigation bar. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_FLOAT<sup>9+</sup> | 8      | Floating window. This type can be used only in the stage model.<br>**Required permissions**: ohos.permission.SYSTEM_FLOAT_WINDOW|
| TYPE_WALLPAPER<sup>9+</sup> | 9      | Wallpaper. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_DESKTOP<sup>9+</sup> | 10      | Home screen. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_LAUNCHER_RECENT<sup>9+</sup> | 11      | Recent tasks screen. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_LAUNCHER_DOCK<sup>9+</sup> | 12      | Dock bar on the home screen. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_VOICE_INTERACTION<sup>9+</sup> | 13      | Voice assistant. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_POINTER<sup>9+</sup> | 14      | Mouse. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
Z
zengyawen 已提交
43

W
wusongqing 已提交
44
## AvoidAreaType<sup>7+</sup>
W
wusongqing 已提交
45 46 47 48 49

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

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

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

W
wusongqing 已提交
57
## WindowMode<sup>7+</sup>
W
wusongqing 已提交
58

59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
Enumerates the window modes.

This is a system API and cannot be called by third-party applications.

**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 已提交
76 77 78 79 80

This is a system API and cannot be called by third-party applications.

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

81 82 83 84
| Name      | Value  | Description                         |
| ---------- | ---- | ----------------------------- |
| WINDOW_LAYOUT_MODE_CASCADE  | 0    | Cascade mode.      |
| WINDOW_LAYOUT_MODE_TILE | 1    | Tile mode.            |
W
wusongqing 已提交
85

W
wusongqing 已提交
86
## SystemBarProperties
Z
zengyawen 已提交
87 88 89

Describes the properties of the status bar and navigation bar.

W
wusongqing 已提交
90 91
**System capability**: SystemCapability.WindowManager.WindowManager.Core

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

101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
## 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.  |
| PORTAIT_INVERTED                      | 3    | Reverse portrait.  |
| 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.|

W
wusongqing 已提交
122
## SystemBarRegionTint<sup>8+</sup>
W
wusongqing 已提交
123 124 125 126 127 128 129

Describes the callback for a single system bar.

This is a system API and cannot be called by third-party applications.

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

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

W
wusongqing 已提交
138
## SystemBarTintState<sup>8+</sup>
W
wusongqing 已提交
139 140 141 142 143 144 145

Describes the callback for the current system bar.

This is a system API and cannot be called by third-party applications.

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

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

W
wusongqing 已提交
151
## Rect<sup>7+</sup>
Z
zengyawen 已提交
152

W
wusongqing 已提交
153
Describes the rectangular area of the window.
Z
zengyawen 已提交
154

W
wusongqing 已提交
155 156
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
157 158 159 160 161 162
| Name  | Type| Readable| Writable| Description              |
| ------ | -------- | ---- | ---- | ------------------ |
| left   | number   | Yes  | Yes  | Left boundary of the rectangle.|
| top    | number   | Yes  | Yes  | Top boundary of the rectangle.|
| width  | number   | Yes  | Yes  | Width of the rectangle.  |
| height | number   | Yes  | Yes  | Height of the rectangle.  |
W
wusongqing 已提交
163

W
wusongqing 已提交
164
## AvoidArea<sup>7+</sup>
Z
zengyawen 已提交
165 166 167

Describes the area where the window cannot be displayed.

W
wusongqing 已提交
168 169
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
170 171
| Name      | Type     | Readable| Writable| Description              |
| ---------- | ------------- | ---- | ---- | ------------------ |
172
| visible<sup>9+</sup>    | boolean       | Yes  | Yes  | Whether the area is visible.|
W
wusongqing 已提交
173 174 175 176
| leftRect   | [Rect](#rect) | Yes  | Yes  | Rectangle on the left of the screen.|
| topRect    | [Rect](#rect) | Yes  | Yes  | Rectangle at the top of the screen.|
| rightRect  | [Rect](#rect) | Yes  | Yes  | Rectangle on the right of the screen.|
| bottomRect | [Rect](#rect) | Yes  | Yes  | Rectangle at the bottom of the screen.|
W
wusongqing 已提交
177

W
wusongqing 已提交
178
## Size<sup>7+</sup>
Z
zengyawen 已提交
179 180 181

Describes the window size.

W
wusongqing 已提交
182 183
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
184 185 186 187
| Name  | Type| Readable| Writable| Description      |
| ------ | -------- | ---- | ---- | ---------- |
| width  | number   | Yes  | Yes  | Window width.|
| height | number   | Yes  | Yes  | Window height.|
W
wusongqing 已提交
188

W
wusongqing 已提交
189
## WindowProperties
Z
zengyawen 已提交
190 191 192

Describes the window properties.

W
wusongqing 已提交
193
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
194

W
wusongqing 已提交
195 196 197 198
| Name                           | Type                 | Readable| Writable| Description                                        |
| ------------------------------- | ------------------------- | ---- | ---- | -------------------------------------------- |
| windowRect<sup>7+</sup>         | [Rect](#rect)             | Yes  | Yes  | Window size.                                  |
| type<sup>7+</sup>               | [WindowType](#windowtype) | Yes  | Yes  | Window type.                                  |
199 200 201 202 203 204 205 206 207 208
| isFullScreen                    | boolean                   | Yes  | Yes  | Whether the window is displayed in full screen mode. The default value is `false`.                     |
| isLayoutFullScreen<sup>7+</sup> | boolean                   | Yes  | Yes  | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is `false`.             |
| focusable<sup>7+</sup>          | boolean                   | Yes  | No  | Whether the window can gain focus. The default value is `true`.                |
| touchable<sup>7+</sup>          | boolean                   | Yes  | No  | Whether the window is touchable. The default value is `true`.                |
| brightness                      | number                    | Yes  | Yes  | Screen brightness. The value ranges from 0 to 1. The value `1` indicates the maximum brightness. |
| dimBehindValue<sup>(deprecated)</sup>     | number                    | Yes  | Yes  | Dimness of the window that is not on top. The value ranges from 0 to 1. The value `1` indicates the maximum dimness.<br>**NOTE**<br>This attribute is deprecated since API version 9.<br> |
| isKeepScreenOn                  | boolean                   | Yes  | Yes  | Whether the screen is always on. The default value is `false`.                 |
| isPrivacyMode<sup>7+</sup>      | boolean                   | Yes  | Yes  | Whether the window is in privacy mode. The default value is `false`.                     |
| isRoundCorner<sup>7+</sup>      | boolean                   | Yes  | Yes  | Whether the window has rounded corners. The default value is `false`.               |
| isTransparent<sup>7+</sup>      | boolean                   | Yes  | Yes  | Whether the window is transparent. The default value is `false`.                 |
W
wusongqing 已提交
209

W
wusongqing 已提交
210
## ColorSpace<sup>8+</sup>
W
wusongqing 已提交
211 212 213 214 215

Describes the color gamut mode.

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

W
wusongqing 已提交
216
| Name      | Default Value | Description          |
W
wusongqing 已提交
217 218 219
| ---------- | ------ | -------------- |
| DEFAULT    | 0      | Default color gamut mode.|
| WIDE_GAMUT | 1      | Wide color gamut mode.  |
W
wusongqing 已提交
220

W
wusongqing 已提交
221
## window.create<sup>7+</sup>
W
wusongqing 已提交
222 223 224 225 226

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

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

227
This API can be used only in the FA model.
W
wusongqing 已提交
228

W
wusongqing 已提交
229 230
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
231
**Parameters**
W
wusongqing 已提交
232

233 234 235 236
| Name  | Type                                  | Mandatory| Description                                |
| -------- | -------------------------------------- | ---- | ------------------------------------ |
| id       | string                                 | Yes  | Window ID.                            |
| type     | [WindowType](#windowtype)              | Yes  | Window type.                          |
W
wusongqing 已提交
237
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the subwindow created.|
W
wusongqing 已提交
238

W
wusongqing 已提交
239
**Example**
W
wusongqing 已提交
240

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

W
wusongqing 已提交
252
## window.create<sup>7+</sup>
W
wusongqing 已提交
253 254 255 256 257

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

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

258
This API can be used only in the FA model.
W
wusongqing 已提交
259

W
wusongqing 已提交
260 261
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
262
**Parameters**
W
wusongqing 已提交
263

W
wusongqing 已提交
264 265 266 267
| Name| Type                     | Mandatory| Description      |
| ------ | ------------------------- | ---- | ---------- |
| id     | string                    | Yes  | Window ID.  |
| type   | [WindowType](#windowtype) | Yes  | Window type.|
W
wusongqing 已提交
268

W
wusongqing 已提交
269
**Return value**
W
wusongqing 已提交
270

271 272
| Type                            | Description                                   |
| -------------------------------- | --------------------------------------- |
W
wusongqing 已提交
273
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
W
wusongqing 已提交
274

W
wusongqing 已提交
275
**Example**
W
wusongqing 已提交
276

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

W
wusongqing 已提交
288 289 290 291
## window.create<sup>8+</sup>

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

W
wusongqing 已提交
292
Creates a subwindow (in API version 8) or a system window (from API version 9). This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
293 294 295

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

W
wusongqing 已提交
296
**Parameters**
W
wusongqing 已提交
297

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

W
wusongqing 已提交
305
**Example**
W
wusongqing 已提交
306

307 308 309 310 311 312 313 314 315 316 317 318
```js
var windowClass = null;
 window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
    if (err.code) {
        console.error('Failed to create the Window. Cause: ' + JSON.stringify(err));
        return;
    }
    windowClass = data;
    console.info('Window created. Data: ' + JSON.stringify(data));
    windowClass.resetSize(500, 1000);
});
```
Z
zengyawen 已提交
319

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

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

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

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

W
wusongqing 已提交
328
**Parameters**
E
ester.zhou 已提交
329

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

W
wusongqing 已提交
336
**Return value**
E
ester.zhou 已提交
337

338 339 340
| Type                            | Description                                   |
| -------------------------------- | --------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the window created. |
E
ester.zhou 已提交
341

W
wusongqing 已提交
342
**Example**
W
wusongqing 已提交
343

344 345 346 347 348 349 350 351 352 353
```js
var windowClass = null;
let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT);
promise.then((data)=> {
 	windowClass = data;
    console.info('Window created. Data:' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
});
```
W
wusongqing 已提交
354

W
wusongqing 已提交
355
## window.find<sup>7+</sup>
W
wusongqing 已提交
356 357 358 359 360 361 362

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

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

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

W
wusongqing 已提交
363
**Parameters**
W
wusongqing 已提交
364

365 366 367
| Name  | Type                                  | Mandatory| Description                                |
| -------- | -------------------------------------- | ---- | ------------------------------------ |
| id       | string                                 | Yes  | Window ID.                            |
W
wusongqing 已提交
368
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the window found.|
W
wusongqing 已提交
369

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

372 373 374 375 376 377 378 379 380 381 382
```js
var windowClass = null;
 window.find("alertWindow", (err, data) => {
   if (err.code) {
       console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
       return;
   }
   windowClass = data;
   console.info('window found. Data: ' + JSON.stringify(data));
});
```
E
ester.zhou 已提交
383

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

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

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

W
wusongqing 已提交
390
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
391

W
wusongqing 已提交
392
**Parameters**
W
wusongqing 已提交
393

W
wusongqing 已提交
394 395 396
| Name| Type  | Mandatory| Description    |
| ------ | ------ | ---- | -------- |
| id     | string | Yes  | Window ID.|
W
wusongqing 已提交
397

W
wusongqing 已提交
398
**Return value**
W
wusongqing 已提交
399

400 401
| Type                            | Description                                 |
| -------------------------------- | ------------------------------------- |
W
wusongqing 已提交
402
| Promise&lt;[Window](#window)&gt; | Promise used to return the window found.|
W
wusongqing 已提交
403

W
wusongqing 已提交
404
**Example**
W
wusongqing 已提交
405

406 407 408 409 410 411 412 413 414 415
```js
var windowClass = null;
let promise = window.find("alertWindow");
promise.then((data)=> {
 	windowClass = data;
    console.info('window found. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
});
```
Z
zengyawen 已提交
416

W
wusongqing 已提交
417
## window.getTopWindow
W
wusongqing 已提交
418 419 420 421 422

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

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

423
This API can be used only in the FA model.
W
wusongqing 已提交
424

W
wusongqing 已提交
425
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
426

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

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

W
wusongqing 已提交
433
**Example**
Z
zengyawen 已提交
434

435 436 437 438 439 440 441 442 443 444 445
```js
var windowClass = null;
window.getTopWindow((err, data) => {
    if (err.code) {
        console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
        return;
    }
    windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
446 447 448 449 450 451 452

## window.getTopWindow

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

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

453
This API can be used only in the FA model.
W
wusongqing 已提交
454

W
wusongqing 已提交
455 456
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
457
**Return value**
W
wusongqing 已提交
458

459 460
| Type                            | Description                                           |
| -------------------------------- | ----------------------------------------------- |
W
wusongqing 已提交
461
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
W
wusongqing 已提交
462

W
wusongqing 已提交
463
**Example**
W
wusongqing 已提交
464

465 466 467 468 469 470 471 472 473 474
```js
var windowClass = null;
let promise = window.getTopWindow();
promise.then((data)=> {
 	windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
})
```
W
wusongqing 已提交
475 476 477 478 479 480 481 482 483

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

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

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

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

W
wusongqing 已提交
484
**Parameters**
W
wusongqing 已提交
485

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

W
wusongqing 已提交
491
**Example**
W
wusongqing 已提交
492

493 494 495 496 497 498 499 500 501 502 503
```js
var windowClass = null;
window.getTopWindow(this.context, (err, data) => {
    if (err.code) {
        console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
        return;
    }
    windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
504 505 506 507 508 509 510 511 512

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

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

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

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

W
wusongqing 已提交
513
**Parameters**
W
wusongqing 已提交
514

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

W
wusongqing 已提交
519
**Return value**
W
wusongqing 已提交
520

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

W
wusongqing 已提交
525
**Example**
W
wusongqing 已提交
526

527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725
```js
var windowClass = null;
let promise = window.getTopWindow(this.context);
promise.then((data)=> {
 	windowClass = data;
    console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
})
```

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

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

This is a system API and cannot be called by third-party applications.

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

**Parameters**

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

**Example**

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

var displayClass = null;
display.getDefaultDisplay((err, data) => {
    if(err.code) {
        return;
    }
    displayClass = data;
    window.minimizeAll(displayClass.id, (err, data) => {
        if(err.code) {
            console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
            return;
        }
        console.info('Succeeded in minimizing all windows.');
    });
});
```

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

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

This is a system API and cannot be called by third-party applications.

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

**Parameters**

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

**Return value**

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

**Example**

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

var displayClass = null;
display.getDefaultDisplay((err, data) => {
    if(err.code) {
        return;
    }
    displayClass = data;
    let promise = window.minimizeAll(displayClass.id);
    promise.then((data)=> {
        console.info('Succeeded in minimizing all windows.');
    }).catch((err)=>{
        console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
    })
});
```

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

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

This is a system API and cannot be called by third-party applications.

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

**Parameters**

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

**Example**

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

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

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

This is a system API and cannot be called by third-party applications.

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

**Return value**

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

**Example**

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

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

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

This is a system API and cannot be called by third-party applications.

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

**Parameters**

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

**Example**

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

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

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

This is a system API and cannot be called by third-party applications.

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

**Parameters**

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

**Return value**

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

**Example**

```js
let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE);
promise.then((data)=> {
    console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
})
```
W
wusongqing 已提交
726 727 728 729 730

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

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

W
wusongqing 已提交
731
Enables listening for properties changes of the status bar and navigation bar.
W
wusongqing 已提交
732 733 734 735 736

This is a system API and cannot be called by third-party applications.

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

W
wusongqing 已提交
737
**Parameters**
W
wusongqing 已提交
738

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

W
wusongqing 已提交
744
**Example**
W
wusongqing 已提交
745

746 747 748 749 750
```js
window.on('systemBarTintChange', (data) => {
    console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
});
```
Z
zengyawen 已提交
751

W
wusongqing 已提交
752 753 754
## off('systemBarTintChange')<sup>8+</sup>

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

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

W
wusongqing 已提交
758 759 760
This is a system API and cannot be called by third-party applications.

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

W
wusongqing 已提交
762
**Parameters**
Z
zengyawen 已提交
763

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

W
wusongqing 已提交
769
**Example**
Z
zengyawen 已提交
770

771 772 773
```js
window.off('systemBarTintChange');
```
W
wusongqing 已提交
774 775 776

## Window

777 778 779
Represents the current window instance, which is the basic unit managed by the window manager.

In the following API examples, you must use [getTopWindow()](#windowgettopwindow), [create()](#windowcreate7), or [find()](#windowfind7) to obtain a `Window` instance and then call a method in this instance.
W
wusongqing 已提交
780 781 782 783 784 785 786 787 788 789 790

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

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

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

This is a system API and cannot be called by third-party applications.

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

W
wusongqing 已提交
791
**Parameters**
W
wusongqing 已提交
792

W
wusongqing 已提交
793 794
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
795
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
W
wusongqing 已提交
796

W
wusongqing 已提交
797
**Example**
W
wusongqing 已提交
798

799 800 801 802 803 804 805 806 807
```js
windowClass.hide((err, data) => {
    if (err.code) {
        console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('window hidden. data: ' + JSON.stringify(data));
})
```
W
wusongqing 已提交
808 809 810 811 812 813 814 815 816 817 818

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

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

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

This is a system API and cannot be called by third-party applications.

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

W
wusongqing 已提交
819
**Return value**
W
wusongqing 已提交
820

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

W
wusongqing 已提交
825
**Example**
W
wusongqing 已提交
826

827 828 829 830 831 832 833 834
```js
let promise = windowClass.hide();
promise.then((data)=> {
    console.info('window hidden. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
})
```
W
wusongqing 已提交
835 836 837 838 839 840 841 842 843

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

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

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

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

W
wusongqing 已提交
844
**Parameters**
W
wusongqing 已提交
845

W
wusongqing 已提交
846 847
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
848
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
W
wusongqing 已提交
849

W
wusongqing 已提交
850
**Example**
W
wusongqing 已提交
851

852 853 854 855 856 857 858 859 860
```js
windowClass.show((err, data) => {
    if (err.code) {
        console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
})
```
W
wusongqing 已提交
861 862 863 864 865 866 867 868 869

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

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

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

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

W
wusongqing 已提交
870
**Return value**
W
wusongqing 已提交
871

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

W
wusongqing 已提交
876
**Example**
W
wusongqing 已提交
877

878 879 880 881 882 883 884 885
```js
let promise = windowClass.show();
promise.then((data)=> {
    console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
})
```
W
wusongqing 已提交
886 887 888 889 890 891 892 893 894

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

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

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

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

W
wusongqing 已提交
895
**Parameters**
W
wusongqing 已提交
896

W
wusongqing 已提交
897 898
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
899
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
W
wusongqing 已提交
900

W
wusongqing 已提交
901
**Example**
W
wusongqing 已提交
902

903 904 905 906 907 908 909 910 911
```js
windowClass.destroy((err, data) => {
    if (err.code) {
        console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data));
})
```
W
wusongqing 已提交
912 913 914 915 916 917 918 919 920

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

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

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

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

W
wusongqing 已提交
921
**Return value**
W
wusongqing 已提交
922

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

W
wusongqing 已提交
927
**Example**
W
wusongqing 已提交
928

929 930 931 932 933 934 935 936
```js
let promise = windowClass.destroy();
promise.then((data)=> {
    console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
})
```
W
wusongqing 已提交
937 938 939 940 941

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

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

W
wusongqing 已提交
942
Moves this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
943 944 945

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

W
wusongqing 已提交
946
**Parameters**
W
wusongqing 已提交
947

W
wusongqing 已提交
948 949 950 951
| Name  | Type                     | Mandatory| Description                                             |
| -------- | ------------------------- | ---- | ------------------------------------------------- |
| x        | number                    | Yes  | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.|
| y        | number                    | Yes  | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.|
952
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                       |
W
wusongqing 已提交
953

W
wusongqing 已提交
954
**Example**
W
wusongqing 已提交
955

956 957 958 959 960 961 962 963 964 965
```js
windowClass.moveTo(300, 300, (err, data)=>{
    if (err.code) {
        console.error('Failed to move the window. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Window moved. Data: ' + JSON.stringify(data));

});
```
W
wusongqing 已提交
966 967 968 969 970

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

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

W
wusongqing 已提交
971
Moves this window. This API uses a promise to return the result.
W
wusongqing 已提交
972 973 974

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

W
wusongqing 已提交
975
**Parameters**
W
wusongqing 已提交
976

W
wusongqing 已提交
977 978 979 980
| Name| Type  | Mandatory| Description                                             |
| ------ | ------ | ---- | ------------------------------------------------- |
| x      | number | Yes  | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.|
| y      | number | Yes  | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.|
W
wusongqing 已提交
981

W
wusongqing 已提交
982
**Return value**
W
wusongqing 已提交
983

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

W
wusongqing 已提交
988
**Example**
W
wusongqing 已提交
989

990 991 992 993 994 995 996 997
```js
let promise = windowClass.moveTo(300, 300);
promise.then((data)=> {
    console.info('Window moved. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
})
```
W
wusongqing 已提交
998 999 1000 1001 1002 1003 1004 1005 1006

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

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

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

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

W
wusongqing 已提交
1007
**Parameters**
W
wusongqing 已提交
1008

W
wusongqing 已提交
1009 1010 1011 1012
| Name  | Type                     | Mandatory| Description                      |
| -------- | ------------------------- | ---- | -------------------------- |
| width    | number                    | Yes  | New width of the window, in px.|
| height   | number                    | Yes  | New height of the window, in px.|
1013
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                |
W
wusongqing 已提交
1014

W
wusongqing 已提交
1015
**Example**
W
wusongqing 已提交
1016

1017 1018 1019 1020 1021 1022 1023 1024 1025
```js
windowClass.resetSize(500, 1000, (err, data) => {
    if (err.code) {
        console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Window size changed. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1026 1027 1028 1029 1030 1031 1032 1033 1034

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

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

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

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

W
wusongqing 已提交
1035
**Parameters**
W
wusongqing 已提交
1036

W
wusongqing 已提交
1037 1038 1039 1040
| Name| Type  | Mandatory| Description                      |
| ------ | ------ | ---- | -------------------------- |
| width  | number | Yes  | New width of the window, in px.|
| height | number | Yes  | New height of the window, in px.|
W
wusongqing 已提交
1041

W
wusongqing 已提交
1042
**Return value**
W
wusongqing 已提交
1043

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

W
wusongqing 已提交
1048
**Example**
W
wusongqing 已提交
1049

1050 1051 1052 1053 1054 1055 1056 1057
```js
let promise = windowClass.resetSize(500, 1000);
promise.then((data)=> {
    console.info('Window size changed. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068

### setWindowType<sup>7+</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.

This is a system API and cannot be called by third-party applications.

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

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

W
wusongqing 已提交
1071 1072 1073
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| type     | [WindowType](#windowtype) | Yes  | Window type.|
1074
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1075

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

1078 1079 1080 1081 1082 1083 1084 1085 1086 1087
```js
var type = window.WindowType.TYPE_APP;
windowClass.setWindowType(type, (err, data) => {
  if (err.code) {
      console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
      return;
  }
  console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098

### setWindowType<sup>7+</sup>

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

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

This is a system API and cannot be called by third-party applications.

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

W
wusongqing 已提交
1099
**Parameters**
W
wusongqing 已提交
1100

W
wusongqing 已提交
1101 1102 1103
| Name| Type                     | Mandatory| Description      |
| ------ | ------------------------- | ---- | ---------- |
| type   | [WindowType](#windowtype) | Yes  | Window type.|
W
wusongqing 已提交
1104

W
wusongqing 已提交
1105
**Return value**
W
wusongqing 已提交
1106

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

W
wusongqing 已提交
1111
**Example**
W
wusongqing 已提交
1112

1113 1114 1115 1116 1117 1118 1119 1120 1121
```js
var type = window.WindowType.TYPE_APP;
let promise = windowClass.setWindowType(type);
promise.then((data)=> {
    console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
1122 1123 1124 1125 1126 1127 1128 1129 1130

### getProperties

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

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

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

W
wusongqing 已提交
1131
**Parameters**
W
wusongqing 已提交
1132

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

W
wusongqing 已提交
1137
**Example**
W
wusongqing 已提交
1138

1139 1140 1141 1142 1143 1144 1145 1146 1147
```js
windowClass.getProperties((err, data) => {
    if (err.code) {
        console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1148 1149 1150 1151 1152 1153 1154 1155 1156

### getProperties

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

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

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

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

1159 1160
| Type                                                | Description                           |
| ---------------------------------------------------- | ------------------------------- |
W
wusongqing 已提交
1161
| Promise&lt;[WindowProperties](#windowproperties)&gt; | Promise used to return the window properties.|
W
wusongqing 已提交
1162

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

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

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

1176
getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt;): void
W
wusongqing 已提交
1177 1178 1179 1180 1181

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

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

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

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

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

1191 1192 1193 1194 1195 1196 1197 1198 1199 1200
```js
var type = window.AvoidAreaType.TYPE_SYSTEM;
windowClass.getAvoidArea(type, (err, data) => {
    if (err.code) {
        console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1201 1202 1203

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

1204
getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise&lt;[AvoidArea](#avoidarea7)&gt;
W
wusongqing 已提交
1205 1206 1207 1208 1209

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

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

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

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

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

1218 1219 1220
| Type                                     | Description                               |
|-----------------------------------------| ----------------------------------- |
| Promise&lt;[AvoidArea](#avoidarea7)&gt; | Promise used to return the area.|
W
wusongqing 已提交
1221

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

1224 1225 1226 1227 1228 1229 1230 1231
```js
let promise = windowClass.getAvoidArea();
promise.then((data)=> {
    console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
});
```
W
wusongqing 已提交
1232 1233 1234 1235 1236 1237 1238 1239 1240

### setFullScreen

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

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

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

W
wusongqing 已提交
1241
**Parameters**
W
wusongqing 已提交
1242

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

W
wusongqing 已提交
1248
**Example**
W
wusongqing 已提交
1249

1250 1251 1252 1253 1254 1255 1256 1257 1258 1259
```js
var isFullScreen = true;
windowClass.setFullScreen(isFullScreen, (err, data) => {
    if (err.code) {
        console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1260 1261 1262 1263 1264 1265 1266 1267 1268

### setFullScreen

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

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

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

W
wusongqing 已提交
1269
**Parameters**
W
wusongqing 已提交
1270

W
wusongqing 已提交
1271 1272 1273
| Name      | Type   | Mandatory| Description                                          |
| ------------ | ------- | ---- | ---------------------------------------------- |
| isFullScreen | boolean | Yes  | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.|
W
wusongqing 已提交
1274

W
wusongqing 已提交
1275
**Return value**
W
wusongqing 已提交
1276

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

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

1283 1284 1285 1286 1287 1288 1289 1290 1291
```js
var isFullScreen = true;
let promise = windowClass.setFullScreen(isFullScreen);
promise.then((data)=> {
    console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
1292 1293 1294 1295 1296

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

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

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

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

W
wusongqing 已提交
1301
**Parameters**
W
wusongqing 已提交
1302

W
wusongqing 已提交
1303 1304 1305
| 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.|
1306
| callback           | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                                  |
W
wusongqing 已提交
1307

W
wusongqing 已提交
1308
**Example**
W
wusongqing 已提交
1309

1310 1311 1312 1313 1314 1315 1316 1317 1318 1319
```js
var isLayoutFullScreen= true;
windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => {
    if (err.code) {
        console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1320 1321 1322 1323 1324

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

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

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

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

W
wusongqing 已提交
1329
**Parameters**
W
wusongqing 已提交
1330

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

W
wusongqing 已提交
1335
**Return value**
W
wusongqing 已提交
1336

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

W
wusongqing 已提交
1341
**Example**
W
wusongqing 已提交
1342

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

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

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

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

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

W
wusongqing 已提交
1361
**Parameters**
W
wusongqing 已提交
1362

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

W
wusongqing 已提交
1368
**Example**
W
wusongqing 已提交
1369

1370 1371 1372 1373 1374 1375 1376 1377 1378 1379
```js
var names = ["status", "navigation"];
windowClass.setSystemBarEnable(names, (err, data) => {
    if (err.code) {
        console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1380 1381 1382 1383 1384 1385 1386 1387 1388

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

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

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

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

W
wusongqing 已提交
1389
**Parameters**
W
wusongqing 已提交
1390

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

W
wusongqing 已提交
1395
**Return value**
W
wusongqing 已提交
1396

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

W
wusongqing 已提交
1401
**Example**
W
wusongqing 已提交
1402

1403 1404 1405 1406 1407 1408 1409 1410 1411
```js
var names = ["status", "navigation"];
let promise = windowClass.setSystemBarEnable(names);
promise.then((data)=> {
    console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
});
```
W
wusongqing 已提交
1412 1413 1414 1415 1416 1417 1418 1419 1420

### setSystemBarProperties

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

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

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

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

1423 1424
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
W
wusongqing 已提交
1425
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448
| callback            | AsyncCallback&lt;void&gt;                   | Yes  | Callback used to return the result.            |

**Example**

```js
var SystemBarProperties={
    statusBarColor: '#ff00ff',
    navigationBarColor: '#00ff00',
    // The following properties are supported since API version 7.
    isStatusBarLightIcon: true,
    isNavigationBarLightIcon:false,
    // The following properties are supported since API version 8.
    statusBarContentColor:'#ffffff',
    navigationBarContentColor:'#00ffff'
};
windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => {
    if (err.code) {
        console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1449 1450 1451 1452 1453 1454 1455 1456 1457

### setSystemBarProperties

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

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

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

W
wusongqing 已提交
1458
**Parameters**
W
wusongqing 已提交
1459

1460 1461
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
W
wusongqing 已提交
1462
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
W
wusongqing 已提交
1463

W
wusongqing 已提交
1464
**Return value**
W
wusongqing 已提交
1465

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

1470
**Example**
W
wusongqing 已提交
1471

1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489
```js
var SystemBarProperties={
    statusBarColor: '#ff00ff',
    navigationBarColor: '#00ff00',
    // The following properties are supported since API version 7.
    isStatusBarLightIcon: true,
    isNavigationBarLightIcon:false,
    // The following properties are supported since API version 8.
    statusBarContentColor:'#ffffff',
    navigationBarContentColor:'#00ffff'
};
let promise = windowClass.setSystemBarProperties(SystemBarProperties);
promise.then((data)=> {
    console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
1490

1491 1492 1493 1494 1495
### 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 已提交
1496 1497 1498

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

W
wusongqing 已提交
1499
**Parameters**
W
wusongqing 已提交
1500

1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
| Orientation         | [Orientation](#orientation9)                | Yes  | Orientation to set.        |
| callback            | AsyncCallback&lt;void&gt;                   | Yes  | Callback used to return the result.            |

**Example**

```js
var orientation = window.Orientation.AUTO_ROTATION;
windowClass.setPreferredOrientation(orientation, (err, data) => {
    if (err.code) {
        console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting window orientation. Data: ' + JSON.stringify(data));
});
```

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

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

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

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

**Parameters**

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

**Return value**

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

**Example**

```js
var orientation = window.Orientation.AUTO_ROTATION;
let promise = windowClass.setPreferredOrientation(orientation);
promise.then((data)=> {
    console.info('Succeeded in setting the window orientation. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the window orientation. Cause: ' + JSON.stringify(err));
});
```

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

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

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

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

**Parameters**

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

W
wusongqing 已提交
1566
**Example**
W
wusongqing 已提交
1567

1568 1569 1570 1571 1572 1573 1574 1575 1576
```js
windowClass.loadContent("pages/page2/page2", (err, data) => {
   if (err.code) {
         console.error('Failed to load the content. Cause:' + JSON.stringify(err));
         return;
   }
  console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1577 1578 1579 1580 1581

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

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

1582
Loads content from a page to this window. This API uses a promise to return the result.
W
wusongqing 已提交
1583 1584 1585

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

W
wusongqing 已提交
1586
**Parameters**
W
wusongqing 已提交
1587

W
wusongqing 已提交
1588 1589 1590
| Name| Type  | Mandatory| Description                |
| ------ | ------ | ---- | -------------------- |
| path   | string | Yes  | Path of the page from which the content will be loaded.|
G
ge-yafang 已提交
1591

W
wusongqing 已提交
1592
**Return value**
W
wusongqing 已提交
1593

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

W
wusongqing 已提交
1598
**Example**
W
wusongqing 已提交
1599

1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648
```js
let promise = windowClass.loadContent("pages/page2/page2");
promise.then((data)=> {
    console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
});
```
### loadContent<sup>9+</sup>

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

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

This API can be used only in the stage model.

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

**Example**

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

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

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

1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688
Loads content from a page associated with a local storage to this window. This API uses a promise to return the result.

This API can be used only in the stage model.

**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.                                        |
| storage | LocalStorage | Yes  | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|

**Return value**

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

**Example**

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

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

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

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

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

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

W
wusongqing 已提交
1703
**Example**
W
wusongqing 已提交
1704

1705 1706 1707 1708 1709 1710 1711 1712 1713
```js
windowClass.isShowing((err, data) => {
    if (err.code) {
        console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1714 1715 1716 1717 1718 1719 1720 1721 1722

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

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

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

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

W
wusongqing 已提交
1723
**Return value**
W
wusongqing 已提交
1724

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

W
wusongqing 已提交
1729
**Example**
W
wusongqing 已提交
1730

1731 1732 1733 1734 1735 1736 1737 1738
```js
let promise = windowClass.isShowing();
promise.then((data)=> {
    console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
1739 1740 1741 1742 1743 1744 1745 1746 1747

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

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

W
wusongqing 已提交
1755
**Example**
W
wusongqing 已提交
1756

1757 1758 1759 1760 1761
```js
windowClass.on('windowSizeChange', (data) => {
    console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1762 1763 1764 1765 1766 1767 1768 1769 1770

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

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

Disables listening for window size changes.

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

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

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

W
wusongqing 已提交
1778
**Example**
W
wusongqing 已提交
1779

1780 1781 1782
```js
windowClass.off('windowSizeChange');
```
W
wusongqing 已提交
1783

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

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

Enables listening for changes to the area where the window cannot be displayed.
1789 1790 1791
> **NOTE**
>
>   This API is deprecated since API version 9. Use [on('avoidAreaChange')](#onavoidareachange9) instead.
W
wusongqing 已提交
1792 1793 1794

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

W
wusongqing 已提交
1795
**Parameters**
W
wusongqing 已提交
1796

1797 1798 1799 1800
| 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 已提交
1801

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

1804 1805 1806 1807 1808
```js
windowClass.on('systemAvoidAreaChange', (data) => {
    console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1809

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

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

Disables listening for changes to the area where the window cannot be displayed.
1815 1816 1817
> **NOTE**
>
>  This API is deprecated since API version 9. Use [off('avoidAreaChange')](#offavoidareachange9) instead.
W
wusongqing 已提交
1818 1819 1820

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

W
wusongqing 已提交
1821
**Parameters**
W
wusongqing 已提交
1822

1823 1824 1825 1826
| 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 已提交
1827

W
wusongqing 已提交
1828
**Example**
W
wusongqing 已提交
1829

1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877
```js
windowClass.off('systemAvoidAreaChange');
```


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

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

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

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

**Parameters**

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

**Example**

```js
windowClass.on('avoidAreaChange', (type, data) => {
    console.info('Succeeded in enabling the listener for system avoid area changes. type:'  + JSON.stringify(type) + 'Data: ' + JSON.stringify(data));
});
```

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

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

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

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

**Parameters**

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

**Example**

```js
windowClass.off('avoidAreaChange');
```
W
wusongqing 已提交
1878 1879 1880 1881 1882 1883 1884 1885 1886

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

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

W
wusongqing 已提交
1894
**Example**
W
wusongqing 已提交
1895

1896 1897 1898 1899 1900
```js
windowClass.on('keyboardHeightChange', (data) => {
    console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
1901 1902 1903 1904 1905 1906 1907 1908 1909

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

W
wusongqing 已提交
1912 1913
| Name  | Type                  | Mandatory| Description                                                        |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961
| type     | string                 | Yes  | Event type. The value is fixed at `keyboardHeightChange`, indicating the keyboard height change event.|
| callback | Callback&lt;number&gt; | No  | Callback used to return the current keyboard height.                              |

**Example**

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

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

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

Enables listening for click events outside this window.
This is a system API and cannot be called by third-party applications.

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

**Parameters**

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

**Example**

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

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

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

Disables listening for click events outside this window.
This is a system API and cannot be called by third-party applications.

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

**Parameters**

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

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

1965 1966 1967
```js
windowClass.off('touchOutside');
```
W
wusongqing 已提交
1968 1969 1970 1971 1972 1973 1974 1975 1976

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

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

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

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

W
wusongqing 已提交
1977
**Parameters**
W
wusongqing 已提交
1978

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

W
wusongqing 已提交
1983
**Example**
W
wusongqing 已提交
1984

1985 1986 1987 1988 1989 1990 1991 1992 1993
```js
windowClass.isSupportWideGamut((err, data) => {
    if (err.code) {
        console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
})
```
W
wusongqing 已提交
1994 1995 1996 1997 1998 1999 2000 2001 2002

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

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

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

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

W
wusongqing 已提交
2003
**Return value**
W
wusongqing 已提交
2004

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

W
wusongqing 已提交
2009
**Example**
W
wusongqing 已提交
2010

2011 2012 2013 2014 2015 2016 2017 2018
```js
let promise = windowClass.isSupportWideGamut();
promise.then((data)=> {
    console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
2019 2020 2021 2022 2023 2024 2025 2026 2027

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

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

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

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

W
wusongqing 已提交
2028
**Parameters**
W
wusongqing 已提交
2029

W
wusongqing 已提交
2030 2031 2032
| Name    | Type                     | Mandatory| Description        |
| ---------- | ------------------------- | ---- | ------------ |
| colorSpace | [ColorSpace](#colorspace) | Yes  | Color gamut mode.|
2033
| callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.  |
W
wusongqing 已提交
2034

W
wusongqing 已提交
2035
**Example**
W
wusongqing 已提交
2036

2037 2038 2039 2040 2041 2042 2043 2044 2045
```js
windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => {
    if (err.code) {
        console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data));
})
```
W
wusongqing 已提交
2046 2047 2048 2049 2050 2051 2052 2053 2054

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

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

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

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

W
wusongqing 已提交
2055
**Parameters**
W
wusongqing 已提交
2056

2057 2058
| Name    | Type                     | Mandatory| Description          |
| ---------- | ------------------------- | ---- | -------------- |
W
wusongqing 已提交
2059
| colorSpace | [ColorSpace](#colorspace) | Yes  | Color gamut mode.|
W
wusongqing 已提交
2060

W
wusongqing 已提交
2061
**Return value**
W
wusongqing 已提交
2062

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

W
wusongqing 已提交
2067
**Example**
W
wusongqing 已提交
2068

2069 2070 2071 2072 2073 2074 2075 2076
```js
let promise = windowClass.isSupportWideGamut(window.ColorSpace.WIDE_GAMUT);
promise.then((data)=> {
    console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
2077 2078 2079 2080 2081 2082 2083 2084 2085

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

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

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

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

W
wusongqing 已提交
2086
**Parameters**
W
wusongqing 已提交
2087

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

W
wusongqing 已提交
2092
**Example**
W
wusongqing 已提交
2093

2094 2095 2096 2097 2098 2099 2100 2101 2102
```js
windowClass.getColorSpace((err, data) => {
    if (err.code) {
        console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data));
})
```
W
wusongqing 已提交
2103 2104 2105 2106 2107 2108 2109 2110 2111

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

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

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

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

W
wusongqing 已提交
2112
**Return value**
W
wusongqing 已提交
2113

2114 2115 2116
| Type                                    | Description                           |
| ---------------------------------------- | ------------------------------- |
| Promise&lt;[ColorSpace](#colorspace)&gt; | Promise used to return the current color gamut mode.|
W
wusongqing 已提交
2117

W
wusongqing 已提交
2118
**Example**
W
wusongqing 已提交
2119

2120 2121 2122 2123 2124 2125 2126 2127
```js
let promise = windowClass.getColorSpace();
promise.then((data)=> {
    console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
2128 2129 2130 2131 2132

### setBackgroundColor

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

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

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

W
wusongqing 已提交
2137
**Parameters**
W
wusongqing 已提交
2138

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

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

2146 2147 2148 2149 2150 2151 2152 2153 2154 2155
```js
var color = '#00ff33';
windowClass.setBackgroundColor(color, (err, data) => {
    if (err.code) {
        console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
2156 2157 2158 2159 2160

### setBackgroundColor

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

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

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

W
wusongqing 已提交
2165
**Parameters**
W
wusongqing 已提交
2166

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

W
wusongqing 已提交
2171
**Return value**
W
wusongqing 已提交
2172

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

W
wusongqing 已提交
2177
**Example**
W
wusongqing 已提交
2178

2179 2180 2181 2182 2183 2184 2185 2186 2187
```js
var color = '#00ff33';
let promise = windowClass.setBackgroundColor(color);
promise.then((data)=> {
    console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
2188 2189 2190 2191 2192 2193 2194 2195 2196

### setBrightness

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

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

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

W
wusongqing 已提交
2197
**Parameters**
W
wusongqing 已提交
2198

W
wusongqing 已提交
2199 2200
| Name    | Type                     | Mandatory| Description                                |
| ---------- | ------------------------- | ---- | ------------------------------------ |
2201 2202
| brightness | number                    | Yes  | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.|
| callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                          |
W
wusongqing 已提交
2203

W
wusongqing 已提交
2204
**Example**
W
wusongqing 已提交
2205

2206 2207 2208 2209 2210 2211 2212 2213 2214 2215
```js
var brightness = 1;
windowClass.setBrightness(brightness, (err, data) => {
    if (err.code) {
        console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
2216 2217 2218 2219 2220 2221 2222 2223 2224

### setBrightness

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

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

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

W
wusongqing 已提交
2225
**Parameters**
W
wusongqing 已提交
2226

W
wusongqing 已提交
2227 2228
| Name    | Type  | Mandatory| Description                                |
| ---------- | ------ | ---- | ------------------------------------ |
2229
| brightness | number | Yes  | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.|
W
wusongqing 已提交
2230

W
wusongqing 已提交
2231
**Return value**
W
wusongqing 已提交
2232

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

W
wusongqing 已提交
2237
**Example**
W
wusongqing 已提交
2238

2239 2240 2241 2242 2243 2244 2245 2246 2247
```js
var brightness = 1;
let promise = windowClass.setBrightness(brightness);
promise.then((data)=> {
    console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
2248

W
wusongqing 已提交
2249 2250 2251 2252 2253 2254
### setDimBehind<sup>(deprecated)</sup>

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

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

W
wusongqing 已提交
2255
> **NOTE**
W
wusongqing 已提交
2256
> 
2257
>  This API is deprecated since API version 9.
W
wusongqing 已提交
2258 2259 2260 2261 2262 2263 2264

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

**Parameters**

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

**Example**

2270 2271 2272 2273 2274 2275 2276 2277 2278
```js
windowClass.setDimBehind(0.5, (err, data) => {
    if (err.code) {
        console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data));
});
```
W
wusongqing 已提交
2279 2280 2281 2282 2283 2284 2285

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

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

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

W
wusongqing 已提交
2286
> **NOTE**
W
wusongqing 已提交
2287
> 
2288
>  This API is deprecated since API version 9.
W
wusongqing 已提交
2289 2290 2291 2292 2293 2294 2295

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

**Parameters**

| Name        | Type  | Mandatory| Description                                              |
| -------------- | ------ | ---- | -------------------------------------------------- |
2296
| dimBehindValue | number | Yes  | Dimness of the window to set. The value ranges from 0 to 1. The value `1` indicates the dimmest.|
W
wusongqing 已提交
2297 2298 2299

**Return value**

2300 2301 2302
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
2303 2304 2305

**Example**

2306 2307 2308 2309 2310 2311 2312 2313
```js
let promise = windowClass.setDimBehind(0.5);
promise.then((data)=> {
    console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
2314

W
wusongqing 已提交
2315 2316 2317 2318 2319 2320 2321 2322
### setFocusable<sup>7+</sup>

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

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

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

W
wusongqing 已提交
2323
**Parameters**
W
wusongqing 已提交
2324

W
wusongqing 已提交
2325 2326 2327
| Name     | Type                     | Mandatory| Description                        |
| ----------- | ------------------------- | ---- | ---------------------------- |
| isFocusable | boolean                   | Yes  | Whether the window can gain focus.|
2328
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                  |
W
wusongqing 已提交
2329

W
wusongqing 已提交
2330
**Example**
W
wusongqing 已提交
2331

2332 2333 2334 2335 2336 2337 2338 2339 2340 2341
```js
var isFocusable= true;
windowClass.setFocusable(isFocusable, (err, data) => {
    if (err.code) {
        console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
});
```
W
wusongqing 已提交
2342 2343 2344 2345 2346 2347 2348 2349 2350

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

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

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

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

W
wusongqing 已提交
2351
**Parameters**
W
wusongqing 已提交
2352

W
wusongqing 已提交
2353 2354 2355
| Name     | Type   | Mandatory| Description                        |
| ----------- | ------- | ---- | ---------------------------- |
| isFocusable | boolean | Yes  | Whether the window can gain focus.|
W
wusongqing 已提交
2356

W
wusongqing 已提交
2357
**Return value**
W
wusongqing 已提交
2358

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

W
wusongqing 已提交
2363
**Example**
W
wusongqing 已提交
2364

2365 2366 2367 2368 2369 2370 2371 2372 2373
```js
var isFocusable= true;
let promise = windowClass.setFocusable(isFocusable);
promise.then((data)=> {
    console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
2374 2375 2376 2377 2378 2379 2380 2381 2382

### setKeepScreenOn

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

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

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

W
wusongqing 已提交
2383
**Parameters**
W
wusongqing 已提交
2384

W
wusongqing 已提交
2385 2386 2387
| Name        | Type                     | Mandatory| Description                    |
| -------------- | ------------------------- | ---- | ------------------------ |
| isKeepScreenOn | boolean                   | Yes  | Whether to keep the screen always on.|
2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421
| callback       | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.              |

**Example**

```js
var isKeepScreenOn = true;
windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => {
    if (err.code) {
        console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
});
```

### setKeepScreenOn

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

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

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

**Parameters**

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

**Return value**

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

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

2425 2426 2427 2428 2429 2430 2431 2432 2433
```js
var isKeepScreenOn = true;
let promise = windowClass.setKeepScreenOn(isKeepScreenOn);
promise.then((data) => {
    console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.info('Failed to set the screen to be always on. Cause:  ' + JSON.stringify(err)); 
});
```
W
wusongqing 已提交
2434

W
wusongqing 已提交
2435 2436 2437 2438 2439 2440
### setOutsideTouchable<sup>(deprecated)</sup>

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

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

W
wusongqing 已提交
2441
> **NOTE**
W
wusongqing 已提交
2442
> 
2443
>  This API is deprecated since API version 9.
W
wusongqing 已提交
2444 2445 2446 2447 2448 2449 2450

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

**Parameters**

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

**Example**

2456 2457 2458 2459 2460 2461 2462 2463 2464
```js
windowClass.setOutsideTouchable(true, (err, data) => {
    if (err.code) {
        console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data));
})
```
W
wusongqing 已提交
2465 2466 2467 2468 2469 2470 2471

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

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

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

W
wusongqing 已提交
2472
> **NOTE**
W
wusongqing 已提交
2473
> 
2474
>  This API is deprecated since API version 9.
W
wusongqing 已提交
2475 2476 2477 2478 2479 2480 2481

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

**Parameters**

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

**Return value**

2486 2487 2488
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
2489 2490 2491

**Example**

2492 2493 2494 2495 2496 2497 2498 2499
```js
let promise = windowClass.setOutsideTouchable(true);
promise.then((data)=> {
    console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
2500 2501 2502 2503 2504 2505 2506 2507 2508

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

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

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

W
wusongqing 已提交
2509
**Parameters**
W
wusongqing 已提交
2510

W
wusongqing 已提交
2511 2512 2513
| Name       | Type                     | Mandatory| Description                |
| ------------- | ------------------------- | ---- | -------------------- |
| isPrivacyMode | boolean                   | Yes  | Whether the window is in privacy mode.|
2514
| callback      | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |
W
wusongqing 已提交
2515

W
wusongqing 已提交
2516
**Example**
W
wusongqing 已提交
2517

2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528
```js
var isPrivacyMode = true;
windowClass.setPrivacyMode(isPrivacyMode, (err, data) => {
    if (err.code) {
        console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data));

});
```
W
wusongqing 已提交
2529 2530 2531 2532 2533 2534 2535 2536 2537

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

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

Sets whether this window is in privacy mode. This API uses a promise to return the result.

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

W
wusongqing 已提交
2538
**Parameters**
W
wusongqing 已提交
2539

W
wusongqing 已提交
2540 2541 2542
| Name       | Type   | Mandatory| Description                |
| ------------- | ------- | ---- | -------------------- |
| isPrivacyMode | boolean | Yes  | Whether the window is in privacy mode.|
W
wusongqing 已提交
2543

W
wusongqing 已提交
2544
**Return value**
W
wusongqing 已提交
2545

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

W
wusongqing 已提交
2550
**Example**
W
wusongqing 已提交
2551

2552 2553 2554 2555 2556 2557 2558 2559 2560
```js
var isPrivacyMode = true;
let promise = windowClass.setPrivacyMode(isPrivacyMode);
promise.then((data)=> {
    console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
});
```
W
wusongqing 已提交
2561 2562 2563 2564 2565 2566 2567 2568 2569

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

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

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

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

W
wusongqing 已提交
2570
**Parameters**
W
wusongqing 已提交
2571

W
wusongqing 已提交
2572 2573 2574
| Name     | Type                     | Mandatory| Description                |
| ----------- | ------------------------- | ---- | -------------------- |
| isTouchable | boolean                   | Yes  | Whether the window is touchable.|
2575
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |
W
wusongqing 已提交
2576

W
wusongqing 已提交
2577
**Example**
W
wusongqing 已提交
2578

2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589
```js
var isTouchable = true;
windowClass.setTouchable(isTouchable, (err, data) => {
    if (err.code) {
        console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
        return;
    }
    console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data));

});
```
W
wusongqing 已提交
2590 2591 2592 2593 2594 2595 2596 2597 2598

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

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

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

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

W
wusongqing 已提交
2599
**Parameters**
W
wusongqing 已提交
2600

W
wusongqing 已提交
2601 2602 2603
| Name     | Type   | Mandatory| Description                |
| ----------- | ------- | ---- | -------------------- |
| isTouchable | boolean | Yes  | Whether the window is touchable.|
W
wusongqing 已提交
2604

W
wusongqing 已提交
2605
**Return value**
W
wusongqing 已提交
2606

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

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

2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686
```js
var isTouchable = true;
let promise = windowClass.setTouchable(isTouchable);
promise.then((data)=> {
    console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data));
}).catch((err)=>{
    console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
});
```

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

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

Sets whether this window is forbidden to move in split-screen mode. This API uses an asynchronous callback to return the result.

This is a system API and cannot be called by third-party applications.

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

**Parameters**

| Name     | Type                     | Mandatory| Description                |
| ----------- | ------------------------- | ---- | -------------------- |
| isForbidSplitMove | boolean                   | Yes  | Whether the window is forbidden to move in split-screen mode.|
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |

**Example**

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

});
```

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

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

Sets whether this window is forbidden to move in split-screen mode. This API uses a promise to return the result.

This is a system API and cannot be called by third-party applications.

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

**Parameters**

| Name     | Type   | Mandatory| Description                |
| ----------- | ------- | ---- | -------------------- |
| isForbidSplitMove | boolean | Yes  | Whether the window is forbidden to move in split-screen mode.|

**Return value**

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

**Example**

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

W
wusongqing 已提交
2688
## WindowStageEventType<sup>9+</sup>
W
wusongqing 已提交
2689 2690 2691

Describes the lifecycle of a window stage.

2692 2693
This API can be used only in the stage model.

W
wusongqing 已提交
2694 2695
**System capability**: SystemCapability.WindowManager.WindowManager.Core

2696 2697
| Name      | Default Value | Description      |
| ---------- | ------ | ---------- |
W
wusongqing 已提交
2698 2699 2700 2701
| FOREGROUND | 1      | The window stage is running in the foreground.|
| ACTIVE     | 2      | The window stage gains focus.|
| INACTIVE   | 3      | The window stage loses focus.|
| BACKGROUND | 4      | The window stage is running in the background.|
W
wusongqing 已提交
2702 2703 2704

## WindowStage<sup>9+</sup>

2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725
Implements a window manager, which manages each basic window unit, that is, [Window](#window) instance.

Before calling any of the following APIs, you must use `[onWindowStageCreate()](js-apis-application-ability.md#abilityonwindowstagecreate)` to create a `WindowStage` instance.

### getMainWindow<sup>9+</sup>

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

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

This API can be used only in the stage model.

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

**Parameters**

| Name  | Type                                  | Mandatory| Description                                         |
| -------- | -------------------------------------- | ---- | --------------------------------------------- |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the main window.|

**Example**
W
wusongqing 已提交
2726

2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        var windowClass = null;
        windowStage.getMainWindow((err, data) => {
            if (err.code) {
                console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
                return;
            }
            windowClass = data;
            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
        });
    }
}
```
W
wusongqing 已提交
2744 2745 2746 2747 2748 2749
### 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.

2750 2751
This API can be used only in the stage model.

W
wusongqing 已提交
2752 2753
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2754
**Return value**
W
wusongqing 已提交
2755

2756 2757
| Type                            | Description                                            |
| -------------------------------- | ------------------------------------------------ |
W
wusongqing 已提交
2758
| Promise&lt;[Window](#window)&gt; | Promise used to return the main window.|
W
wusongqing 已提交
2759

W
wusongqing 已提交
2760
**Example**
W
wusongqing 已提交
2761

2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        var windowClass = null;
        let promise = windowStage.getMainWindow();
        promise.then((data)=> {
        windowClass = data;
            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
        }).catch((err)=>{
            console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
        });
    }
}
```
### createSubWindow<sup>9+</sup>
W
wusongqing 已提交
2779

2780
createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void
W
wusongqing 已提交
2781

2782
Creates a subwindow for this window stage. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2783

2784
This API can be used only in the stage model.
W
wusongqing 已提交
2785 2786 2787

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

W
wusongqing 已提交
2788
**Parameters**
W
wusongqing 已提交
2789

2790 2791 2792 2793
| Name  | Type                                  | Mandatory| Description                                         |
| -------- | -------------------------------------- | ---- | --------------------------------------------- |
| name     | String                                 | Yes  | Name of the subwindow.                               |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the subwindow.|
W
wusongqing 已提交
2794

W
wusongqing 已提交
2795
**Example**
W
wusongqing 已提交
2796

2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        var windowClass = null;
        windowStage.createSubWindow("mySubWindow", (err, data) => {
            if (err.code) {
                console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
                return;
            }
            windowClass = data;
            console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
            windowClass.resetSize(500, 1000);
        });
    }
}
```
W
wusongqing 已提交
2815 2816 2817 2818 2819 2820
### 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.

2821 2822
This API can be used only in the stage model.

W
wusongqing 已提交
2823
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
2824

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

W
wusongqing 已提交
2827 2828 2829
| Name| Type  | Mandatory| Description          |
| ------ | ------ | ---- | -------------- |
| name   | String | Yes  | Name of the subwindow.|
G
ge-yafang 已提交
2830

W
wusongqing 已提交
2831
**Return value**
W
wusongqing 已提交
2832

2833 2834 2835
| Type                            | Description                                            |
| -------------------------------- | ------------------------------------------------ |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow.|
G
ge-yafang 已提交
2836

W
wusongqing 已提交
2837
**Example**
W
wusongqing 已提交
2838

2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        var windowClass = null;
        let promise = windowStage.createSubWindow("mySubWindow");
        promise.then((data)=> {
            windowClass = data;
            console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
        }).catch((err)=>{
            console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
        })
    }
}
```
### getSubWindow<sup>9+</sup>
W
wusongqing 已提交
2856

2857
getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void
W
wusongqing 已提交
2858

2859
Obtains all the subwindows of this window stage. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2860

2861
This API can be used only in the stage model.
W
wusongqing 已提交
2862 2863 2864

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

W
wusongqing 已提交
2865
**Parameters**
W
wusongqing 已提交
2866

2867 2868 2869
| Name  | Type                                               | Mandatory| Description                                             |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[Window](#window)&gt;&gt; | Yes  | Callback used to return all the subwindows.|
W
wusongqing 已提交
2870

W
wusongqing 已提交
2871
**Example**
W
wusongqing 已提交
2872

2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        var windowClass = null;
        windowStage.getSubWindow((err, data) => {
            if (err.code) {
                console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
                return;
            }
            windowClass = data;
            console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
        });
    }
}
```
W
wusongqing 已提交
2890 2891 2892 2893 2894 2895
### 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.

2896 2897
This API can be used only in the stage model.

W
wusongqing 已提交
2898
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
2899

W
wusongqing 已提交
2900
**Return value**
W
wusongqing 已提交
2901

2902 2903
| Type                                         | Description                                                |
| --------------------------------------------- | ---------------------------------------------------- |
W
wusongqing 已提交
2904
| Promise&lt;Array&lt;[Window](#window)&gt;&gt; | Promise used to return all the subwindows.|
W
wusongqing 已提交
2905

W
wusongqing 已提交
2906
**Example**
W
wusongqing 已提交
2907

2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        var windowClass = null;
        let promise = windowStage.getSubWindow();
        promise.then((data)=> {
            windowClass = data;
            console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
        }).catch((err)=>{
            console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
        })
    }
}
```
### loadContent<sup>9+</sup>
W
wusongqing 已提交
2925

2926
loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void&gt;): void
W
wusongqing 已提交
2927

2928
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 已提交
2929

2930
This API can be used only in the stage model.
W
wusongqing 已提交
2931 2932

**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
2933

W
wusongqing 已提交
2934
**Parameters**
W
wusongqing 已提交
2935

2936 2937 2938 2939 2940
| Name  | Type                                           | Mandatory| Description                                                        |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path     | string                                          | Yes  | Path of the page from which the content will be loaded.                                        |
| storage  | LocalStorage | 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.                                                  |
W
wusongqing 已提交
2941

W
wusongqing 已提交
2942
**Example**
W
wusongqing 已提交
2943

2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    storage : LocalStorage  
    onWindowStageCreate(windowStage) {
        this.storage = new LocalStorage();
        this.storage.setOrCreate("storageSimpleProp",121);
        console.log('onWindowStageCreate');
        windowStage.loadContent("pages/page2",this.storage,(err, data) => {
            if (err.code) {
                console.error('Failed to load the content. Cause:' + JSON.stringify(err));
                return;
            }
            console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
        });
    }
}
```

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

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.

This API can be used only in the stage model.

**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.                                        |
| storage | LocalStorage | No  | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|

**Return value**

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

**Example**

```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    storage : LocalStorage 
    onWindowStageCreate(windowStage) {
        this.storage = new LocalStorage();
        this.storage.setOrCreate("storageSimpleProp",121);
        console.log('onWindowStageCreate');
        var windowClass = null;
        let promise = windowStage.loadContent("pages/page2",this.storage);
        promise.then((data)=> {
            windowClass = data;
            console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
        }).catch((err)=>{
            console.error('Failed to load the content. Cause:' + JSON.stringify(err));
        })
    }
}
```
W
wusongqing 已提交
3007 3008 3009 3010 3011

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

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

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

This API can be used only in the stage model.
W
wusongqing 已提交
3015

3016
**System capability**: SystemCapability.WindowManager.WindowManager.Core
W
wusongqing 已提交
3017

W
wusongqing 已提交
3018
**Parameters**
W
wusongqing 已提交
3019

W
wusongqing 已提交
3020 3021 3022
| Name  | Type                     | Mandatory| Description                |
| -------- | ------------------------- | ---- | -------------------- |
| path     | string                    | Yes  | Path of the page from which the content will be loaded.|
3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |

**Example**

```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        windowStage.loadContent("pages/page2", (err, data) => {
            if (err.code) {
                console.error('Failed to load the content. Cause:' + JSON.stringify(err));
                return;
            }
            console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
        });
    }
}
```
G
ge-yafang 已提交
3042

W
wusongqing 已提交
3043 3044 3045 3046 3047 3048
### on('windowStageEvent')<sup>9+</sup>

on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;): void

Enables listening for window stage lifecycle changes.

3049 3050
This API can be used only in the stage model.

W
wusongqing 已提交
3051
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
3052

W
wusongqing 已提交
3053
**Parameters**
W
wusongqing 已提交
3054

W
wusongqing 已提交
3055 3056
| Name  | Type                                                        | Mandatory| Description                                                        |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3057 3058
| type     | string                                                       | Yes  | Event type. The value is fixed at `windowStageEvent`, indicating the window stage lifecycle change event.|
| callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | Yes  | Callback used to return the window stage lifecycle state.               |
W
wusongqing 已提交
3059

W
wusongqing 已提交
3060
**Example**
W
wusongqing 已提交
3061

3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        windowStage.on('windowStageEvent', (data) => {
            console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data));
        });
    }
}
```
W
wusongqing 已提交
3073 3074 3075 3076 3077 3078 3079

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

off(eventType: 'windowStageEvent', callback?: Callback&lt;WindowStageEventType&gt;): void

Disables listening for window stage lifecycle changes.

3080 3081
This API can be used only in the stage model.

W
wusongqing 已提交
3082
**System capability**: SystemCapability.WindowManager.WindowManager.Core
G
ge-yafang 已提交
3083

W
wusongqing 已提交
3084
**Parameters**
W
wusongqing 已提交
3085

W
wusongqing 已提交
3086 3087
| Name  | Type                                                        | Mandatory| Description                                                        |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3088 3089
| type     | string                                                       | Yes  | Event type. The value is fixed at `windowStageEvent`, indicating the window stage lifecycle change event.|
| callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | No  | Callback used to return the window stage lifecycle state.               |
G
ge-yafang 已提交
3090

W
wusongqing 已提交
3091
**Example**
W
wusongqing 已提交
3092

3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        windowStage.off('windowStageEvent');
    }
}
```

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

disableWindowDecor(): void

Disables window decorators.
W
wusongqing 已提交
3108

3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127
This type can be used only in the stage model.

This is a system API and cannot be called by third-party applications.

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

**Example**

```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('disableWindowDecor');
        windowStage.disableWindowDecor();
    }
}
```

### setShowOnLockScreen()<sup>9+</sup>
W
wusongqing 已提交
3128 3129 3130 3131 3132

setShowOnLockScreen(showOnLockScreen: boolean): void

Sets whether to display the window of the application on the lock screen.

3133 3134
This API can be used only in the stage model.

W
wusongqing 已提交
3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145
**System capability**: SystemCapability.WindowManager.WindowManager.Core

**Parameters**

| Name          | Type   | Mandatory| Description                        |
| ---------------- | ------- | ---- | ---------------------------- |
| showOnLockScreen | boolean | Yes  | Whether to display the window on the lock screen.|

**Example**

```ts
3146
import Ability from '@ohos.application.Ability';
W
wusongqing 已提交
3147 3148 3149 3150 3151 3152 3153
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        windowStage.setShowOnLockScreen(true);
    }
}
```