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

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

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

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

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

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

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

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

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

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

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

61
**System API**: This is a system API.
62 63 64 65 66 67 68 69 70 71 72 73 74 75

**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
**System API**: This is a system API.
W
wusongqing 已提交
78 79 80

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

Enumerates the window orientations.

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

| Name                                 | Value  | Description                         |
| ------------------------------------- | ---- | ----------------------------- |
| UNSPECIFIED                           | 0    | Unspecified. The orientation is determined by the system.|
| PORTRAIT                              | 1    | Portrait.            |
| LANDSCAPE                             | 2    | Landscape.  |
X
xpeng 已提交
112
| PORTRAIT_INVERTED                     | 3    | Reverse portrait.  |
113 114 115 116 117 118 119 120 121
| 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

Describes the callback for a single system bar.

126
**System API**: This is a system API.
W
wusongqing 已提交
127 128 129

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

Describes the callback for the current system bar.

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

**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 window can be displayed in the area.|
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

195 196 197 198 199 200 201 202 203 204 205 206 207 208
| Name                                 | Type                 | Readable| Writable| Description                                                        |
| ------------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| windowRect<sup>7+</sup>               | [Rect](#rect)             | Yes  | Yes  | Window size.                                                  |
| type<sup>7+</sup>                     | [WindowType](#windowtype) | Yes  | Yes  | Window type.                                                  |
| isFullScreen                          | boolean                   | Yes  | Yes  | Whether the window is displayed in full screen mode. The default value is `false`.                                     |
| isLayoutFullScreen<sup>7+</sup>       | boolean                   | Yes  | Yes  | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is `false`.                             |
| focusable<sup>7+</sup>                | boolean                   | Yes  | No  | Whether the window can gain focus. The default value is `true`.                                |
| touchable<sup>7+</sup>                | boolean                   | Yes  | No  | Whether the window is touchable. The default value is `true`.                                |
| brightness                            | number                    | Yes  | Yes  | Screen brightness. The value ranges from 0 to 1. The value `1` indicates the maximum brightness.                 |
| dimBehindValue<sup>(deprecated)</sup> | number                    | Yes  | Yes  | Dimness of the window that is not on top. The value ranges from 0 to 1. The value `1` indicates the maximum dimness.<br>**NOTE**<br>This property is supported since API version 7 and deprecated since API version 9.<br> |
| isKeepScreenOn                        | boolean                   | Yes  | Yes  | Whether the screen is always on. The default value is `false`.                                 |
| isPrivacyMode<sup>7+</sup>            | boolean                   | Yes  | Yes  | Whether the window is in privacy mode. The default value is `false`.                                     |
| isRoundCorner<sup>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
**Model restriction**: 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
```js
var windowClass = null;
243 244 245 246 247 248 249 250
window.create("first", window.WindowType.TYPE_APP,(err,data) => {
    if(err.code){
        console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
        return;
    }
    windowClass = data;
    console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
});
251
```
W
wusongqing 已提交
252

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

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

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

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

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

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

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

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

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

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

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

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

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

W
wusongqing 已提交
293
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 已提交
294 295 296

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

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

W
wusongqing 已提交
299 300
| Name  | Type                                  | Mandatory| Description                                                        |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
301
| 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 已提交
302 303
| id       | string                                 | Yes  | Window ID.                                                    |
| type     | [WindowType](#windowtype)              | Yes  | Window type.                                                  |
304
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the subwindow created.                        |
W
wusongqing 已提交
305

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

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

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

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

W
wusongqing 已提交
325
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 已提交
326 327

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

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

W
wusongqing 已提交
331 332
| Name| Type                     | Mandatory| Description                                                        |
| ------ | ------------------------- | ---- | ------------------------------------------------------------ |
333
| 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 已提交
334 335
| id     | string                    | Yes  | Window ID.                                                    |
| type   | [WindowType](#windowtype) | Yes  | Window type.                                                  |
W
wusongqing 已提交
336

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

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

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

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

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

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 已提交
364
**Parameters**
W
wusongqing 已提交
365

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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

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

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

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

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

436 437 438 439 440 441 442 443 444 445 446
```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 已提交
447 448 449 450 451 452 453

## window.getTopWindow

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

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

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

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

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

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

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

466 467 468 469 470 471 472 473 474 475
```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 已提交
476 477 478 479 480 481 482 483 484

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

W
wusongqing 已提交
487 488
| Name  | Type                                  | Mandatory| Description                                                        |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
489 490
| 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 已提交
491

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

494 495 496 497 498 499 500 501 502 503 504
```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 已提交
505 506 507 508 509 510 511 512 513

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

W
wusongqing 已提交
516 517
| Name| Type   | Mandatory| Description                                                        |
| ------ | ------- | ---- | ------------------------------------------------------------ |
518
| 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 已提交
519

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

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

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

528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543
```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.

544
**System API**: This is a system API.
545 546 547 548 549 550 551

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

**Parameters**

| Name  | Type                     | Mandatory| Description          |
| -------- | ------------------------- | ---- | -------------- |
552
| id       | number                    | Yes  | ID of the [display](js-apis-display.md#display).|
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
| 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.

582
**System API**: This is a system API.
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

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

624
**System API**: This is a system API.
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

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

651
**System API**: This is a system API.
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

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

677
**System API**: This is a system API.
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700

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

701
**System API**: This is a system API.
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726

**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 已提交
727 728 729 730 731

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

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

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

734
**System API**: This is a system API.
W
wusongqing 已提交
735 736 737

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

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

W
wusongqing 已提交
740 741
| Name  | Type                                                     | Mandatory| Description                                                        |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
742 743
| 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 已提交
744

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

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

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

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

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

759
**System API**: This is a system API.
W
wusongqing 已提交
760 761

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

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

W
wusongqing 已提交
765 766
| Name  | Type                                                     | Mandatory| Description                                                        |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
767 768
| 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 已提交
769

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

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

## Window

778 779 780
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 已提交
781 782 783 784 785 786 787

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

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

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

788
**System API**: This is a system API.
W
wusongqing 已提交
789 790 791

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

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

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

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

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

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

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

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

816
**System API**: This is a system API.
W
wusongqing 已提交
817 818 819

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

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

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

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

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

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

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

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

853 854 855 856 857 858 859 860 861
```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 已提交
862 863 864 865 866 867 868 869 870

### 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 已提交
871
**Return value**
W
wusongqing 已提交
872

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

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

879 880 881 882 883 884 885 886
```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 已提交
887 888 889 890 891 892 893 894 895

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

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

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

904 905 906 907 908 909 910 911 912
```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 已提交
913 914 915 916 917 918 919 920 921

### 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 已提交
922
**Return value**
W
wusongqing 已提交
923

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

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

930 931 932 933 934 935 936 937
```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 已提交
938 939 940 941 942

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

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

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

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

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

W
wusongqing 已提交
949 950 951 952
| 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.|
953
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                       |
W
wusongqing 已提交
954

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

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

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

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

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

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

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

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

W
wusongqing 已提交
978 979 980 981
| 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 已提交
982

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

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

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

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

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

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

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

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

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

W
wusongqing 已提交
1038 1039 1040 1041
| 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 已提交
1042

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

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

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

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

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

1066
**System API**: This is a system API.
W
wusongqing 已提交
1067 1068 1069

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

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

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

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

1079 1080 1081 1082 1083 1084 1085 1086 1087 1088
```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 已提交
1089 1090 1091 1092 1093 1094 1095

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

1096
**System API**: This is a system API.
W
wusongqing 已提交
1097 1098 1099

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

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

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

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

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

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

1114 1115 1116 1117 1118 1119 1120 1121 1122
```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 已提交
1123 1124 1125 1126 1127 1128 1129 1130 1131

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

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

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

1140 1141 1142 1143 1144 1145 1146 1147 1148
```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 已提交
1149 1150 1151 1152 1153 1154 1155 1156 1157

### 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 已提交
1158
**Return value**
W
wusongqing 已提交
1159

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

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

1166 1167 1168 1169 1170 1171 1172 1173
```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 已提交
1174 1175 1176

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

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

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 已提交
1183
**Parameters**
W
wusongqing 已提交
1184

1185 1186
| Name  | Type                                           | Mandatory| Description                                                        |
| -------- |-----------------------------------------------| ---- | ------------------------------------------------------------ |
1187
| 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.|
1188
| callback | AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt; | Yes  | Callback used to return the area.                            |
W
wusongqing 已提交
1189

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

1192 1193 1194 1195 1196 1197 1198 1199 1200 1201
```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 已提交
1202 1203 1204

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

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

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 已提交
1211
**Parameters**
W
wusongqing 已提交
1212

1213 1214
| Name| Type                              | Mandatory| Description                                                        |
| ------ |----------------------------------| ---- | ------------------------------------------------------------ |
1215
| 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 已提交
1216

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

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

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

1225 1226 1227 1228 1229 1230 1231 1232
```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 已提交
1233 1234 1235 1236 1237 1238 1239 1240 1241

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

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

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

1251 1252 1253 1254 1255 1256 1257 1258 1259 1260
```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 已提交
1261 1262 1263 1264 1265 1266 1267 1268 1269

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

W
wusongqing 已提交
1272 1273 1274
| 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 已提交
1275

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

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

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

1284 1285 1286 1287 1288 1289 1290 1291 1292
```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 已提交
1293 1294 1295 1296 1297

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

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

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

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

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

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

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

1311 1312 1313 1314 1315 1316 1317 1318 1319 1320
```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 已提交
1321 1322 1323 1324 1325

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

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

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

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

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

W
wusongqing 已提交
1332 1333 1334
| 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 已提交
1335

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

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

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

1344 1345 1346 1347 1348 1349 1350 1351 1352
```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 已提交
1353 1354 1355 1356 1357 1358 1359 1360 1361

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

W
wusongqing 已提交
1364 1365
| Name  | Type                     | Mandatory| Description                                                        |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
1366 1367
| 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 已提交
1368

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

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

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

W
wusongqing 已提交
1393 1394
| Name| Type | Mandatory| Description                                                        |
| ------ | ----- | ---- | ------------------------------------------------------------ |
1395
| 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 已提交
1396

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

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

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

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

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

1426 1427
| Name             | Type                                       | Mandatory| Description                  |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
W
wusongqing 已提交
1428
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451
| 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 已提交
1452 1453 1454 1455 1456 1457 1458 1459 1460

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

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

W
wusongqing 已提交
1467
**Return value**
W
wusongqing 已提交
1468

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

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

1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492
```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 已提交
1493

1494 1495 1496 1497 1498
### 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 已提交
1499 1500 1501

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

W
wusongqing 已提交
1502
**Parameters**
W
wusongqing 已提交
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 1563 1564 1565
| 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 已提交
1566
| path     | string                    | Yes  | Path of the page from which the content will be loaded.|
1567
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |
G
ge-yafang 已提交
1568

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

1571 1572 1573 1574 1575 1576 1577 1578 1579
```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 已提交
1580 1581 1582 1583 1584

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

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

1585
Loads content from a page to this window. This API uses a promise to return the result.
W
wusongqing 已提交
1586 1587 1588

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

W
wusongqing 已提交
1589
**Parameters**
W
wusongqing 已提交
1590

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

W
wusongqing 已提交
1595
**Return value**
W
wusongqing 已提交
1596

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

W
wusongqing 已提交
1601
**Example**
W
wusongqing 已提交
1602

1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616
```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.

1617
**Model restriction**: This API can be used only in the stage model.
1618 1619 1620 1621 1622 1623 1624 1625

**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.                                        |
1626
| storage  | [LocalStorage](../../ui/ui-ts-local-storage.md) | Yes  | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651
| 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 已提交
1652

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

1655
**Model restriction**: This API can be used only in the stage model.
1656 1657 1658 1659 1660 1661 1662 1663

**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.                                        |
1664
| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | Yes  | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691

**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 已提交
1692 1693 1694 1695 1696 1697 1698 1699
### 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 已提交
1700
**Parameters**
W
wusongqing 已提交
1701

1702 1703 1704
| 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 已提交
1705

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

1708 1709 1710 1711 1712 1713 1714 1715 1716
```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 已提交
1717 1718 1719 1720 1721 1722 1723 1724 1725

### 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 已提交
1726
**Return value**
W
wusongqing 已提交
1727

1728 1729 1730
| 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 已提交
1731

W
wusongqing 已提交
1732
**Example**
W
wusongqing 已提交
1733

1734 1735 1736 1737 1738 1739 1740 1741
```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 已提交
1742 1743 1744 1745 1746 1747 1748 1749 1750

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

1753 1754 1755 1756
| 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 已提交
1757

W
wusongqing 已提交
1758
**Example**
W
wusongqing 已提交
1759

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

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

W
wusongqing 已提交
1776 1777
| Name  | Type                         | Mandatory| Description                                                    |
| -------- | ----------------------------- | ---- | -------------------------------------------------------- |
1778 1779
| 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 已提交
1780

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

1783 1784 1785
```js
windowClass.off('windowSizeChange');
```
W
wusongqing 已提交
1786

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

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

Enables listening for changes to the area where the window cannot be displayed.
1792
> **NOTE**<br> This API is supported since API version 7 and deprecated since API version 9. Use [on('avoidAreaChange')](#onavoidareachange9) instead.
1793
>
1794
>  
W
wusongqing 已提交
1795 1796 1797

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

W
wusongqing 已提交
1798
**Parameters**
W
wusongqing 已提交
1799

1800 1801 1802 1803
| 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 已提交
1804

W
wusongqing 已提交
1805
**Example**
W
wusongqing 已提交
1806

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

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

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

Disables listening for changes to the area where the window cannot be displayed.
1818
> **NOTE**<br> This API is supported since API version 7 and deprecated since API version 9. Use [off('avoidAreaChange')](#offavoidareachange9) instead.
1819
>
1820
>  
W
wusongqing 已提交
1821 1822 1823

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

W
wusongqing 已提交
1824
**Parameters**
W
wusongqing 已提交
1825

1826 1827 1828 1829
| 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 已提交
1830

W
wusongqing 已提交
1831
**Example**
W
wusongqing 已提交
1832

1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855
```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
1856 1857
windowClass.on('avoidAreaChange', (data) => {
    console.info('Succeeded in enabling the listener for system avoid area changes. type:'  + JSON.stringify(data.type) + ', area: ' + JSON.stringify(data.area));
1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880
});
```

### 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 已提交
1881 1882 1883 1884 1885 1886 1887 1888 1889

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

1892 1893 1894 1895
| 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 已提交
1896

W
wusongqing 已提交
1897
**Example**
W
wusongqing 已提交
1898

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

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

W
wusongqing 已提交
1915 1916
| Name  | Type                  | Mandatory| Description                                                        |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930
| 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.
1931 1932

**System API**: This is a system API.
1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955

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

**System API**: This is a system API.
1958 1959 1960 1961 1962 1963 1964 1965 1966

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

W
wusongqing 已提交
1968
**Example**
W
wusongqing 已提交
1969

1970 1971 1972
```js
windowClass.off('touchOutside');
```
W
wusongqing 已提交
1973 1974 1975 1976 1977 1978 1979 1980 1981

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

1984 1985 1986
| 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 已提交
1987

W
wusongqing 已提交
1988
**Example**
W
wusongqing 已提交
1989

1990 1991 1992 1993 1994 1995 1996 1997 1998
```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 已提交
1999 2000 2001 2002 2003 2004 2005 2006 2007

### 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 已提交
2008
**Return value**
W
wusongqing 已提交
2009

W
wusongqing 已提交
2010 2011
| Type                  | Description                                                        |
| ---------------------- | ------------------------------------------------------------ |
2012
| 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 已提交
2013

W
wusongqing 已提交
2014
**Example**
W
wusongqing 已提交
2015

2016 2017 2018 2019 2020 2021 2022 2023
```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 已提交
2024 2025 2026 2027 2028 2029 2030 2031 2032

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

W
wusongqing 已提交
2035 2036 2037
| Name    | Type                     | Mandatory| Description        |
| ---------- | ------------------------- | ---- | ------------ |
| colorSpace | [ColorSpace](#colorspace) | Yes  | Color gamut mode.|
2038
| callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.  |
W
wusongqing 已提交
2039

W
wusongqing 已提交
2040
**Example**
W
wusongqing 已提交
2041

2042 2043 2044 2045 2046 2047 2048 2049 2050
```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 已提交
2051 2052 2053 2054 2055 2056 2057 2058 2059

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

2062 2063
| Name    | Type                     | Mandatory| Description          |
| ---------- | ------------------------- | ---- | -------------- |
W
wusongqing 已提交
2064
| colorSpace | [ColorSpace](#colorspace) | Yes  | Color gamut mode.|
W
wusongqing 已提交
2065

W
wusongqing 已提交
2066
**Return value**
W
wusongqing 已提交
2067

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

W
wusongqing 已提交
2072
**Example**
W
wusongqing 已提交
2073

2074
```js
X
xpeng 已提交
2075
let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT);
2076 2077 2078 2079 2080 2081
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 已提交
2082 2083 2084 2085 2086 2087 2088 2089 2090

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

2093 2094 2095
| 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 已提交
2096

W
wusongqing 已提交
2097
**Example**
W
wusongqing 已提交
2098

2099 2100 2101 2102 2103 2104 2105 2106 2107
```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 已提交
2108 2109 2110 2111 2112 2113 2114 2115 2116

### 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 已提交
2117
**Return value**
W
wusongqing 已提交
2118

2119 2120 2121
| Type                                    | Description                           |
| ---------------------------------------- | ------------------------------- |
| Promise&lt;[ColorSpace](#colorspace)&gt; | Promise used to return the current color gamut mode.|
W
wusongqing 已提交
2122

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

2125 2126 2127 2128 2129 2130 2131 2132
```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 已提交
2133 2134 2135 2136 2137

### setBackgroundColor

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

2138
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 已提交
2139 2140 2141

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

W
wusongqing 已提交
2142
**Parameters**
W
wusongqing 已提交
2143

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

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

2151 2152 2153 2154 2155 2156 2157 2158 2159 2160
```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 已提交
2161 2162 2163 2164 2165

### setBackgroundColor

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

2166
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 已提交
2167 2168 2169

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

W
wusongqing 已提交
2170
**Parameters**
W
wusongqing 已提交
2171

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

W
wusongqing 已提交
2176
**Return value**
W
wusongqing 已提交
2177

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

W
wusongqing 已提交
2182
**Example**
W
wusongqing 已提交
2183

2184 2185 2186 2187 2188 2189 2190 2191 2192
```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 已提交
2193 2194 2195 2196 2197 2198 2199 2200 2201

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

W
wusongqing 已提交
2204 2205
| Name    | Type                     | Mandatory| Description                                |
| ---------- | ------------------------- | ---- | ------------------------------------ |
2206 2207
| 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 已提交
2208

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

2211 2212 2213 2214 2215 2216 2217 2218 2219 2220
```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 已提交
2221 2222 2223 2224 2225 2226 2227 2228 2229

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

W
wusongqing 已提交
2232 2233
| Name    | Type  | Mandatory| Description                                |
| ---------- | ------ | ---- | ------------------------------------ |
2234
| brightness | number | Yes  | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.|
W
wusongqing 已提交
2235

W
wusongqing 已提交
2236
**Return value**
W
wusongqing 已提交
2237

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

W
wusongqing 已提交
2242
**Example**
W
wusongqing 已提交
2243

2244 2245 2246 2247 2248 2249 2250 2251 2252
```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 已提交
2253

W
wusongqing 已提交
2254 2255 2256 2257 2258 2259
### 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 已提交
2260
> **NOTE**
2261 2262 2263 2264
>
> This API cannot be used.
>
> This API is supported since API version 7 and deprecated since API version 9.  
W
wusongqing 已提交
2265 2266 2267 2268 2269 2270 2271

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

**Parameters**

| Name        | Type                     | Mandatory| Description                                              |
| -------------- | ------------------------- | ---- | -------------------------------------------------- |
2272 2273
| 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 已提交
2274 2275 2276

**Example**

2277 2278 2279 2280 2281 2282 2283 2284 2285
```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 已提交
2286 2287 2288 2289 2290 2291 2292

### 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 已提交
2293
> **NOTE**
2294 2295 2296 2297
>
> This API cannot be used.
>
> This API is supported since API version 7 and deprecated since API version 9.  
W
wusongqing 已提交
2298 2299 2300 2301 2302 2303 2304

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

**Parameters**

| Name        | Type  | Mandatory| Description                                              |
| -------------- | ------ | ---- | -------------------------------------------------- |
2305
| dimBehindValue | number | Yes  | Dimness of the window to set. The value ranges from 0 to 1. The value `1` indicates the dimmest.|
W
wusongqing 已提交
2306 2307 2308

**Return value**

2309 2310 2311
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
2312 2313 2314

**Example**

2315 2316 2317 2318 2319 2320 2321 2322
```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 已提交
2323

W
wusongqing 已提交
2324 2325 2326 2327 2328 2329 2330 2331
### 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 已提交
2332
**Parameters**
W
wusongqing 已提交
2333

W
wusongqing 已提交
2334 2335 2336
| Name     | Type                     | Mandatory| Description                        |
| ----------- | ------------------------- | ---- | ---------------------------- |
| isFocusable | boolean                   | Yes  | Whether the window can gain focus.|
2337
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                  |
W
wusongqing 已提交
2338

W
wusongqing 已提交
2339
**Example**
W
wusongqing 已提交
2340

2341 2342 2343 2344 2345 2346 2347 2348 2349 2350
```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 已提交
2351 2352 2353 2354 2355 2356 2357 2358 2359

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

W
wusongqing 已提交
2362 2363 2364
| Name     | Type   | Mandatory| Description                        |
| ----------- | ------- | ---- | ---------------------------- |
| isFocusable | boolean | Yes  | Whether the window can gain focus.|
W
wusongqing 已提交
2365

W
wusongqing 已提交
2366
**Return value**
W
wusongqing 已提交
2367

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

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

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

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

W
wusongqing 已提交
2394 2395 2396
| Name        | Type                     | Mandatory| Description                    |
| -------------- | ------------------------- | ---- | ------------------------ |
| isKeepScreenOn | boolean                   | Yes  | Whether to keep the screen always on.|
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 2422 2423 2424 2425 2426 2427 2428 2429 2430
| 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 已提交
2431

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

2434 2435 2436 2437 2438 2439 2440 2441 2442
```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 已提交
2443

W
wusongqing 已提交
2444 2445 2446 2447 2448 2449
### 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 已提交
2450
> **NOTE**
2451 2452 2453 2454
>
> This API cannot be used.
>
> This API is supported since API version 7 and deprecated since API version 9.  
W
wusongqing 已提交
2455 2456 2457 2458 2459 2460 2461

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

**Parameters**

| Name   | Type                     | Mandatory| Description            |
| --------- | ------------------------- | ---- | ---------------- |
2462 2463
| 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 已提交
2464 2465 2466

**Example**

2467 2468 2469 2470 2471 2472 2473 2474 2475
```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 已提交
2476 2477 2478 2479 2480 2481 2482

### 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 已提交
2483
> **NOTE**
2484 2485 2486 2487
>
> This API cannot be used.
>
> This API is supported since API version 7 and deprecated since API version 9.  
W
wusongqing 已提交
2488 2489 2490 2491 2492 2493 2494

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

**Parameters**

| Name   | Type   | Mandatory| Description            |
| --------- | ------- | ---- | ---------------- |
2495
| 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 已提交
2496 2497 2498

**Return value**

2499 2500 2501
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
W
wusongqing 已提交
2502 2503 2504

**Example**

2505 2506 2507 2508 2509 2510 2511 2512
```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 已提交
2513 2514 2515 2516 2517

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

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

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

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

W
wusongqing 已提交
2522
**Parameters**
W
wusongqing 已提交
2523

W
wusongqing 已提交
2524 2525 2526
| Name       | Type                     | Mandatory| Description                |
| ------------- | ------------------------- | ---- | -------------------- |
| isPrivacyMode | boolean                   | Yes  | Whether the window is in privacy mode.|
2527
| callback      | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |
W
wusongqing 已提交
2528

W
wusongqing 已提交
2529
**Example**
W
wusongqing 已提交
2530

2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541
```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 已提交
2542 2543 2544 2545 2546

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

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

2547
Sets whether this window is in privacy mode. This API uses a promise to return the result. When in privacy mode, the window content cannot be captured or recorded.
W
wusongqing 已提交
2548 2549 2550

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

W
wusongqing 已提交
2551
**Parameters**
W
wusongqing 已提交
2552

W
wusongqing 已提交
2553 2554 2555
| Name       | Type   | Mandatory| Description                |
| ------------- | ------- | ---- | -------------------- |
| isPrivacyMode | boolean | Yes  | Whether the window is in privacy mode.|
W
wusongqing 已提交
2556

W
wusongqing 已提交
2557
**Return value**
W
wusongqing 已提交
2558

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

W
wusongqing 已提交
2563
**Example**
W
wusongqing 已提交
2564

2565 2566 2567 2568 2569 2570 2571 2572 2573
```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 已提交
2574 2575 2576 2577 2578 2579 2580 2581 2582

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

W
wusongqing 已提交
2585 2586 2587
| Name     | Type                     | Mandatory| Description                |
| ----------- | ------------------------- | ---- | -------------------- |
| isTouchable | boolean                   | Yes  | Whether the window is touchable.|
2588
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |
W
wusongqing 已提交
2589

W
wusongqing 已提交
2590
**Example**
W
wusongqing 已提交
2591

2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602
```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 已提交
2603 2604 2605 2606 2607 2608 2609 2610 2611

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

W
wusongqing 已提交
2614 2615 2616
| Name     | Type   | Mandatory| Description                |
| ----------- | ------- | ---- | -------------------- |
| isTouchable | boolean | Yes  | Whether the window is touchable.|
W
wusongqing 已提交
2617

W
wusongqing 已提交
2618
**Return value**
W
wusongqing 已提交
2619

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

W
wusongqing 已提交
2624
**Example**
W
wusongqing 已提交
2625

2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641
```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.

2642
**System API**: This is a system API.
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

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

2673
**System API**: This is a system API.
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699

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

W
wusongqing 已提交
2701
## WindowStageEventType<sup>9+</sup>
W
wusongqing 已提交
2702 2703 2704

Describes the lifecycle of a window stage.

2705
**Model restriction**: This API can be used only in the stage model.
2706

W
wusongqing 已提交
2707 2708
**System capability**: SystemCapability.WindowManager.WindowManager.Core

2709 2710
| Name      | Default Value | Description      |
| ---------- | ------ | ---------- |
W
wusongqing 已提交
2711 2712 2713 2714
| 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 已提交
2715 2716 2717

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

2718 2719 2720 2721 2722 2723 2724 2725 2726 2727
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.

2728
**Model restriction**: This API can be used only in the stage model.
2729 2730 2731 2732 2733 2734 2735 2736 2737 2738

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

2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756
```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 已提交
2757 2758 2759 2760 2761 2762
### 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.

2763
**Model restriction**: This API can be used only in the stage model.
2764

W
wusongqing 已提交
2765 2766
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
2767
**Return value**
W
wusongqing 已提交
2768

2769 2770
| Type                            | Description                                            |
| -------------------------------- | ------------------------------------------------ |
W
wusongqing 已提交
2771
| Promise&lt;[Window](#window)&gt; | Promise used to return the main window.|
W
wusongqing 已提交
2772

W
wusongqing 已提交
2773
**Example**
W
wusongqing 已提交
2774

2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791
```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 已提交
2792

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

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

2797
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
2798 2799 2800

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

W
wusongqing 已提交
2801
**Parameters**
W
wusongqing 已提交
2802

2803 2804 2805 2806
| 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 已提交
2807

W
wusongqing 已提交
2808
**Example**
W
wusongqing 已提交
2809

2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827
```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 已提交
2828 2829 2830 2831 2832 2833
### 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.

2834
**Model restriction**: This API can be used only in the stage model.
2835

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

W
wusongqing 已提交
2838
**Parameters**
W
wusongqing 已提交
2839

W
wusongqing 已提交
2840 2841 2842
| Name| Type  | Mandatory| Description          |
| ------ | ------ | ---- | -------------- |
| name   | String | Yes  | Name of the subwindow.|
G
ge-yafang 已提交
2843

W
wusongqing 已提交
2844
**Return value**
W
wusongqing 已提交
2845

2846 2847 2848
| Type                            | Description                                            |
| -------------------------------- | ------------------------------------------------ |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow.|
G
ge-yafang 已提交
2849

W
wusongqing 已提交
2850
**Example**
W
wusongqing 已提交
2851

2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868
```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 已提交
2869

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

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

2874
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
2875 2876 2877

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

W
wusongqing 已提交
2878
**Parameters**
W
wusongqing 已提交
2879

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

W
wusongqing 已提交
2884
**Example**
W
wusongqing 已提交
2885

2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902
```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 已提交
2903 2904 2905 2906 2907 2908
### 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.

2909
**Model restriction**: This API can be used only in the stage model.
2910

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

W
wusongqing 已提交
2913
**Return value**
W
wusongqing 已提交
2914

2915 2916
| Type                                         | Description                                                |
| --------------------------------------------- | ---------------------------------------------------- |
W
wusongqing 已提交
2917
| Promise&lt;Array&lt;[Window](#window)&gt;&gt; | Promise used to return all the subwindows.|
W
wusongqing 已提交
2918

W
wusongqing 已提交
2919
**Example**
W
wusongqing 已提交
2920

2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937
```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 已提交
2938

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

2941
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 已提交
2942

2943
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
2944 2945

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

W
wusongqing 已提交
2947
**Parameters**
W
wusongqing 已提交
2948

2949 2950 2951
| Name  | Type                                           | Mandatory| Description                                                        |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path     | string                                          | Yes  | Path of the page from which the content will be loaded.                                        |
2952
| storage  | [LocalStorage](../../ui/ui-ts-local-storage.md) | Yes  | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
2953
| callback | AsyncCallback&lt;void&gt;                       | Yes  | Callback used to return the result.                                                  |
W
wusongqing 已提交
2954

W
wusongqing 已提交
2955
**Example**
W
wusongqing 已提交
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
```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.

2982
**Model restriction**: This API can be used only in the stage model.
2983 2984 2985 2986 2987 2988 2989 2990

**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.                                        |
2991
| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | No  | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019

**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 已提交
3020 3021 3022 3023 3024

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

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

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

3027
**Model restriction**: This API can be used only in the stage model.
W
wusongqing 已提交
3028

3029
**System capability**: SystemCapability.WindowManager.WindowManager.Core
W
wusongqing 已提交
3030

W
wusongqing 已提交
3031
**Parameters**
W
wusongqing 已提交
3032

W
wusongqing 已提交
3033 3034 3035
| Name  | Type                     | Mandatory| Description                |
| -------- | ------------------------- | ---- | -------------------- |
| path     | string                    | Yes  | Path of the page from which the content will be loaded.|
3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054
| 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 已提交
3055

W
wusongqing 已提交
3056 3057 3058 3059 3060 3061
### on('windowStageEvent')<sup>9+</sup>

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

Enables listening for window stage lifecycle changes.

3062
**Model restriction**: This API can be used only in the stage model.
3063

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

W
wusongqing 已提交
3066
**Parameters**
W
wusongqing 已提交
3067

W
wusongqing 已提交
3068 3069
| Name  | Type                                                        | Mandatory| Description                                                        |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3070 3071
| 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 已提交
3072

W
wusongqing 已提交
3073
**Example**
W
wusongqing 已提交
3074

3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085
```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 已提交
3086 3087 3088 3089 3090 3091 3092

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

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

Disables listening for window stage lifecycle changes.

3093
**Model restriction**: This API can be used only in the stage model.
3094

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

W
wusongqing 已提交
3097
**Parameters**
W
wusongqing 已提交
3098

W
wusongqing 已提交
3099 3100
| Name  | Type                                                        | Mandatory| Description                                                        |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3101 3102
| 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 已提交
3103

W
wusongqing 已提交
3104
**Example**
W
wusongqing 已提交
3105

3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120
```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 已提交
3121

3122
**Model restriction**: This API can be used only in the stage model.
3123

3124
**System API**: This is a system API.
3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140

**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 已提交
3141 3142 3143 3144 3145

setShowOnLockScreen(showOnLockScreen: boolean): void

Sets whether to display the window of the application on the lock screen.

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

W
wusongqing 已提交
3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158
**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
3159
import Ability from '@ohos.application.Ability';
W
wusongqing 已提交
3160 3161 3162 3163 3164 3165 3166
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        windowStage.setShowOnLockScreen(true);
    }
}
```