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

W
wusongqing 已提交
3 4
The **Window** module provides basic capabilities for managing windows, including creating and destroying windows and setting serial port attributes.

W
wusongqing 已提交
5 6
> **NOTE**<br/>
> 
W
wusongqing 已提交
7
> 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 已提交
8

W
wusongqing 已提交
9
## Modules to Import
Z
zengyawen 已提交
10

G
ge-yafang 已提交
11
```js
Z
zengyawen 已提交
12 13 14
import window from '@ohos.window';
```

W
wusongqing 已提交
15
## WindowType<sup>7+</sup>
W
wusongqing 已提交
16

W
wusongqing 已提交
17
Enumerates the window types.
W
wusongqing 已提交
18

W
wusongqing 已提交
19
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
20

W
wusongqing 已提交
21 22 23 24
| Name             | Default Value| Description              |
| ----------------- | ------ | ------------------ |
| TYPE_APP          | 0      | Application subwindow.  |
| TYPE_SYSTEM_ALERT | 1      | System alert window.|
Z
zengyawen 已提交
25

W
wusongqing 已提交
26
## AvoidAreaType<sup>7+</sup>
W
wusongqing 已提交
27 28 29 30 31

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

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

W
wusongqing 已提交
32 33 34 35
| Name       | Default Value| Description              |
| ----------- | ------ | ------------------ |
| TYPE_SYSTEM | 0      | Default area of the system.|
| TYPE_CUTOUT | 1      | Notch.  |
W
wusongqing 已提交
36

W
wusongqing 已提交
37
## WindowMode<sup>7+</sup>
W
wusongqing 已提交
38 39 40 41 42 43 44

Enumerates the window modes of an application.

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

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

W
wusongqing 已提交
45 46 47 48 49 50 51
| Name      | Default 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.|
W
wusongqing 已提交
52

W
wusongqing 已提交
53
## SystemBarProperties
Z
zengyawen 已提交
54 55 56

Describes the properties of the status bar and navigation bar.

W
wusongqing 已提交
57 58
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
59 60
| Name                                  | Type| Readable| Writable| Description                                                        |
| -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
61
| 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 已提交
62 63
| 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.                                            |
W
wusongqing 已提交
64
| 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 已提交
65 66
| 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 已提交
67

W
wusongqing 已提交
68
## SystemBarRegionTint<sup>8+</sup>
W
wusongqing 已提交
69 70 71 72 73 74 75

Describes the callback for a single system bar.

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

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

W
wusongqing 已提交
76 77
| Name           | Type                 | Readable| Writable| Description                                                        |
| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
78
| 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 已提交
79 80
| isEnable        | boolean                   | Yes  | Yes  | Whether the system bar is displayed.                                        |
| region          | [Rect](#rect)             | Yes  | Yes  | Current position and size of the system bar.                                    |
W
wusongqing 已提交
81
| 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 已提交
82
| contentColor    | string                    | Yes  | Yes  | Color of the text on the system bar.                                            |
W
wusongqing 已提交
83

W
wusongqing 已提交
84
## SystemBarTintState<sup>8+</sup>
W
wusongqing 已提交
85 86 87 88 89 90 91

Describes the callback for the current system bar.

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

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

W
wusongqing 已提交
92 93 94 95
| 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 changed.|
W
wusongqing 已提交
96

W
wusongqing 已提交
97
## Rect<sup>7+</sup>
Z
zengyawen 已提交
98

W
wusongqing 已提交
99
Describes the rectangular area of the window.
Z
zengyawen 已提交
100

W
wusongqing 已提交
101 102
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
103 104 105 106 107 108
| 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 已提交
109

W
wusongqing 已提交
110
## AvoidArea<sup>7+</sup>
Z
zengyawen 已提交
111 112 113

Describes the area where the window cannot be displayed.

W
wusongqing 已提交
114 115
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
116 117 118 119 120 121
| Name      | Type     | Readable| Writable| Description              |
| ---------- | ------------- | ---- | ---- | ------------------ |
| 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 已提交
122

W
wusongqing 已提交
123
## Size<sup>7+</sup>
Z
zengyawen 已提交
124 125 126

Describes the window size.

W
wusongqing 已提交
127 128
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
129 130 131 132
| Name  | Type| Readable| Writable| Description      |
| ------ | -------- | ---- | ---- | ---------- |
| width  | number   | Yes  | Yes  | Window width.|
| height | number   | Yes  | Yes  | Window height.|
W
wusongqing 已提交
133

W
wusongqing 已提交
134
## WindowProperties
Z
zengyawen 已提交
135 136 137

Describes the window properties.

W
wusongqing 已提交
138
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
139

W
wusongqing 已提交
140 141 142 143 144 145 146 147 148
| 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. |
W
wusongqing 已提交
149
| 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>This attribute is supported since API version 7 and deprecated since API version 9.<br> |
W
wusongqing 已提交
150 151 152 153
| 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 已提交
154

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

Describes the color gamut mode.

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

W
wusongqing 已提交
161 162 163 164
| Name      | Default Value| Description          |
| ---------- | ------ | -------------- |
| DEFAULT    | 0      | Default color gamut mode.|
| WIDE_GAMUT | 1      | Wide color gamut mode.  |
W
wusongqing 已提交
165

W
wusongqing 已提交
166
## window.create<sup>7+</sup>
W
wusongqing 已提交
167 168 169 170 171

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

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

W
wusongqing 已提交
172
This API is deprecated since API version 8. You are advised to use [window.create<sup>8+</sup>](#windowcreate8) instead.
W
wusongqing 已提交
173

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

W
wusongqing 已提交
176
**Parameters**
W
wusongqing 已提交
177

W
wusongqing 已提交
178 179 180 181 182
| Name  | Type                                  | Mandatory| Description                      |
| -------- | -------------------------------------- | ---- | -------------------------- |
| id       | string                                 | Yes  | Window ID.                  |
| type     | [WindowType](#windowtype)              | Yes  | Window type.                |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the subwindow created.|
W
wusongqing 已提交
183

W
wusongqing 已提交
184
**Example**
W
wusongqing 已提交
185

G
ge-yafang 已提交
186
  ```js
W
wusongqing 已提交
187 188 189 190 191 192 193 194 195 196 197 198
   var windowClass = null;
   window.create("first", window.WindowType.TYPE_APP, (err, data) => {
      if (err.code) {
          console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
          return;
      }
      windowClass = data;
      console.info('SubWindow created. Data: ' + JSON.stringify(data))
      windowClass.resetSize(500, 1000);
  });
  ```

W
wusongqing 已提交
199
## window.create<sup>7+</sup>
W
wusongqing 已提交
200 201 202 203 204

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

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

W
wusongqing 已提交
205
This API is deprecated since API version 8. You are advised to use [window.create<sup>8+</sup>](#windowcreate8) instead.
W
wusongqing 已提交
206

W
wusongqing 已提交
207 208
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
209
**Parameters**
W
wusongqing 已提交
210

W
wusongqing 已提交
211 212 213 214
| Name| Type                     | Mandatory| Description      |
| ------ | ------------------------- | ---- | ---------- |
| id     | string                    | Yes  | Window ID.  |
| type   | [WindowType](#windowtype) | Yes  | Window type.|
W
wusongqing 已提交
215

W
wusongqing 已提交
216
**Return value**
W
wusongqing 已提交
217

W
wusongqing 已提交
218 219 220
| Type                            | Description                                             |
| -------------------------------- | ------------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
W
wusongqing 已提交
221

W
wusongqing 已提交
222
**Example**
W
wusongqing 已提交
223

G
ge-yafang 已提交
224
  ```js
W
wusongqing 已提交
225 226 227 228 229 230 231
   var windowClass = null;
   let promise = window.create("first", window.WindowType.TYPE_APP);
   promise.then((data)=> {
   	windowClass = data;
      console.info('SubWindow created. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
Z
zengyawen 已提交
232
   });
W
wusongqing 已提交
233
  ```
Z
zengyawen 已提交
234

W
wusongqing 已提交
235 236 237 238
## window.create<sup>8+</sup>

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

239
Creates a subwindow (in API version 8) or a system window (since API version 9). This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
240 241 242

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

W
wusongqing 已提交
243
**Parameters**
W
wusongqing 已提交
244

W
wusongqing 已提交
245 246
| Name  | Type                                  | Mandatory| Description                                                        |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
247
| 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 已提交
248 249 250
| id       | string                                 | Yes  | Window ID.                                                    |
| type     | [WindowType](#windowtype)              | Yes  | Window type.                                                  |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the window created.                                      |
W
wusongqing 已提交
251

W
wusongqing 已提交
252
**Example**
W
wusongqing 已提交
253

G
ge-yafang 已提交
254
  ```js
W
wusongqing 已提交
255 256 257 258 259 260
   var windowClass = null;
   window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
      if (err.code) {
          console.error('Failed to create the Window. Cause: ' + JSON.stringify(err));
          return;
      }
Z
zengyawen 已提交
261
      windowClass = data;
W
wusongqing 已提交
262 263 264 265
      console.info('Window created. Data: ' + JSON.stringify(data))
      windowClass.resetSize(500, 1000);
  });
  ```
Z
zengyawen 已提交
266

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

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

271
Creates a subwindow (in API version 8) or a system window (since API version 9). This API uses a promise to return the result.
W
wusongqing 已提交
272 273

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

W
wusongqing 已提交
275
**Parameters**
E
ester.zhou 已提交
276

W
wusongqing 已提交
277 278
| Name| Type                     | Mandatory| Description                                                        |
| ------ | ------------------------- | ---- | ------------------------------------------------------------ |
279
| 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 已提交
280 281
| id     | string                    | Yes  | Window ID.                                                    |
| type   | [WindowType](#windowtype) | Yes  | Window type.                                                  |
W
wusongqing 已提交
282

W
wusongqing 已提交
283
**Return value**
E
ester.zhou 已提交
284

W
wusongqing 已提交
285 286 287
| Type                            | Description                                           |
| -------------------------------- | ----------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the window created.|
E
ester.zhou 已提交
288

W
wusongqing 已提交
289
**Example**
W
wusongqing 已提交
290

G
ge-yafang 已提交
291
  ```js
W
wusongqing 已提交
292 293 294 295 296 297 298 299 300 301
   var windowClass = null;
   let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT);
   promise.then((data)=> {
   	windowClass = data;
      console.info('Window created. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to create the Window. Cause: ' + JSON.stringify(err));
   });
  ```

W
wusongqing 已提交
302
## window.find<sup>7+</sup>
W
wusongqing 已提交
303 304 305 306 307 308 309

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 已提交
310
**Parameters**
W
wusongqing 已提交
311

W
wusongqing 已提交
312 313 314 315
| Name  | Type                                  | Mandatory| Description                        |
| -------- | -------------------------------------- | ---- | ---------------------------- |
| id       | string                                 | Yes  | Window ID.                    |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the window found.|
W
wusongqing 已提交
316

W
wusongqing 已提交
317
**Example**
W
wusongqing 已提交
318

G
ge-yafang 已提交
319
  ```js
W
wusongqing 已提交
320 321 322 323 324 325 326 327
   var windowClass = null;
   window.find("alertWindow", (err, data) => {
     if (err.code) {
         console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
         return;
     }
     windowClass = data;
     console.info('window found. Data: ' + JSON.stringify(data))
E
ester.zhou 已提交
328 329 330
  });
  ```

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

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

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

W
wusongqing 已提交
337
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
338

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

W
wusongqing 已提交
341 342 343
| Name| Type  | Mandatory| Description    |
| ------ | ------ | ---- | -------- |
| id     | string | Yes  | Window ID.|
W
wusongqing 已提交
344

W
wusongqing 已提交
345
**Return value**
W
wusongqing 已提交
346

W
wusongqing 已提交
347 348 349
| Type                            | Description                                           |
| -------------------------------- | ----------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the window found.|
W
wusongqing 已提交
350

W
wusongqing 已提交
351
**Example**
W
wusongqing 已提交
352

G
ge-yafang 已提交
353
  ```js
W
wusongqing 已提交
354 355 356 357 358 359 360 361 362
   var windowClass = null;
   let promise = window.find("alertWindow");
   promise.then((data)=> {
   	windowClass = data;
      console.info('window found. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
   });
  ```
Z
zengyawen 已提交
363

W
wusongqing 已提交
364
## window.getTopWindow
W
wusongqing 已提交
365 366 367 368 369

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.

W
wusongqing 已提交
370
This API is deprecated since API version 8. You are advised to use [window.getTopWindow<sup>8+</sup>](#windowgettopwindow8) instead.
W
wusongqing 已提交
371

W
wusongqing 已提交
372
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
373

W
wusongqing 已提交
374
**Parameters**
Z
zengyawen 已提交
375

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

W
wusongqing 已提交
380
**Example**
Z
zengyawen 已提交
381

G
ge-yafang 已提交
382
  ```js
W
wusongqing 已提交
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
  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));
  });
  ```

## window.getTopWindow

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

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

W
wusongqing 已提交
400
This API is deprecated since API version 8. You are advised to use [window.getTopWindow<sup>8+</sup>](#windowgettopwindow8) instead.
W
wusongqing 已提交
401

W
wusongqing 已提交
402 403
**System capability**: SystemCapability.WindowManager.WindowManager.Core

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

W
wusongqing 已提交
406 407 408
| Type                            | Description                                                     |
| -------------------------------- | --------------------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
W
wusongqing 已提交
409

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

G
ge-yafang 已提交
412
  ```js
W
wusongqing 已提交
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
   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));
   })
  ```

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

W
wusongqing 已提交
433 434 435 436
| Name  | Type                                  | Mandatory| Description                                                        |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| 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 [Context](js-apis-ability-context.md).|
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the top window obtained.                      |
W
wusongqing 已提交
437

W
wusongqing 已提交
438
**Example**
W
wusongqing 已提交
439

G
ge-yafang 已提交
440
  ```js
W
wusongqing 已提交
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
  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));
  });
  ```

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

W
wusongqing 已提交
462 463 464
| Name| Type   | Mandatory| Description                                                        |
| ------ | ------- | ---- | ------------------------------------------------------------ |
| 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 [Context](js-apis-ability-context.md).|
W
wusongqing 已提交
465

W
wusongqing 已提交
466
**Return value**
W
wusongqing 已提交
467

W
wusongqing 已提交
468 469 470
| Type                            | Description                                                     |
| -------------------------------- | --------------------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
W
wusongqing 已提交
471

W
wusongqing 已提交
472
**Example**
W
wusongqing 已提交
473

G
ge-yafang 已提交
474
  ```js
W
wusongqing 已提交
475 476 477 478 479 480 481 482 483 484 485 486 487 488
   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));
   })
  ```

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

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

W
wusongqing 已提交
489
Enables listening for properties changes of the status bar and navigation bar.
W
wusongqing 已提交
490 491 492 493 494

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

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

W
wusongqing 已提交
495
**Parameters**
W
wusongqing 已提交
496

W
wusongqing 已提交
497 498 499 500
| Name  | Type                                                     | Mandatory| Description                                                        |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | string                                                    | Yes  | Type of event to listen for. 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 information.                                      |
W
wusongqing 已提交
501

W
wusongqing 已提交
502
**Example**
W
wusongqing 已提交
503

G
ge-yafang 已提交
504
  ```js
W
wusongqing 已提交
505
  var type = 'systemBarTintChange';
E
ester.zhou 已提交
506
  windowClass.on(type, (data) => {
W
wusongqing 已提交
507
      console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
E
ester.zhou 已提交
508 509
  });
  ```
Z
zengyawen 已提交
510

W
wusongqing 已提交
511 512 513
## off('systemBarTintChange')<sup>8+</sup>

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

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

W
wusongqing 已提交
517 518 519
This is a system API and cannot be called by third-party applications.

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

W
wusongqing 已提交
521
**Parameters**
Z
zengyawen 已提交
522

W
wusongqing 已提交
523 524 525 526
| Name  | Type                                                     | Mandatory| Description                                                        |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | string                                                    | Yes  | Type of event to listen for. 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 information.                                      |
Z
zengyawen 已提交
527

W
wusongqing 已提交
528
**Example**
Z
zengyawen 已提交
529

G
ge-yafang 已提交
530
  ```js
W
wusongqing 已提交
531
  var type = 'systemBarTintChange';
E
ester.zhou 已提交
532 533
  windowClass.off(type);
  ```
W
wusongqing 已提交
534 535 536

## Window

W
wusongqing 已提交
537
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 已提交
538 539 540 541 542 543 544 545 546 547 548

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

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

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

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

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

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

W
wusongqing 已提交
551 552 553
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.|
W
wusongqing 已提交
554

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

G
ge-yafang 已提交
557
  ```js
W
wusongqing 已提交
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576
  windowClass.hide((err, data) => {
      if (err.code) {
          console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('window hidden. data: ' + JSON.stringify(data))
  })
  ```

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

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

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

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

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

W
wusongqing 已提交
577
**Return value**
W
wusongqing 已提交
578

W
wusongqing 已提交
579 580 581
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
582

W
wusongqing 已提交
583
**Example**
W
wusongqing 已提交
584

G
ge-yafang 已提交
585
  ```js
W
wusongqing 已提交
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601
   let promise = windowClass.hide();
   promise.then((data)=> {
      console.info('window hidden. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
   })
  ```

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

W
wusongqing 已提交
604 605 606
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.|
W
wusongqing 已提交
607

W
wusongqing 已提交
608
**Example**
W
wusongqing 已提交
609

G
ge-yafang 已提交
610
  ```js
W
wusongqing 已提交
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
  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))
  })
  ```

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

W
wusongqing 已提交
630 631 632
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
633

W
wusongqing 已提交
634
**Example**
W
wusongqing 已提交
635

G
ge-yafang 已提交
636
  ```js
W
wusongqing 已提交
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652
   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));
   })
  ```

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

W
wusongqing 已提交
655 656 657
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.|
W
wusongqing 已提交
658

W
wusongqing 已提交
659
**Example**
W
wusongqing 已提交
660

G
ge-yafang 已提交
661
  ```js
W
wusongqing 已提交
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678
  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))
  })
  ```

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

W
wusongqing 已提交
681 682 683
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
684

W
wusongqing 已提交
685
**Example**
W
wusongqing 已提交
686

G
ge-yafang 已提交
687
  ```js
W
wusongqing 已提交
688 689 690 691 692 693 694 695 696 697 698 699
   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));
   })
  ```

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

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

W
wusongqing 已提交
700
Moves this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
701 702 703

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

W
wusongqing 已提交
704
**Parameters**
W
wusongqing 已提交
705

W
wusongqing 已提交
706 707 708 709 710
| Name  | Type                     | Mandatory| Description                                             |
| -------- | ------------------------- | ---- | ------------------------------------------------- |
| x        | number                    | Yes  | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.|
| y        | number                    | Yes  | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                                       |
W
wusongqing 已提交
711

W
wusongqing 已提交
712
**Example**
W
wusongqing 已提交
713

G
ge-yafang 已提交
714
  ```js
W
wusongqing 已提交
715 716 717 718 719 720 721 722 723 724 725 726 727 728
  windowClass.moveTo(300, 300, (err, data)=>{
      if (err.code) {
          console.error('Failed to move the window. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Window moved. Data: ' + JSON.stringify(data))
  
  });
  ```

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

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

W
wusongqing 已提交
729
Moves this window. This API uses a promise to return the result.
W
wusongqing 已提交
730 731 732

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

W
wusongqing 已提交
733
**Parameters**
W
wusongqing 已提交
734

W
wusongqing 已提交
735 736 737 738
| 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 已提交
739

W
wusongqing 已提交
740
**Return value**
W
wusongqing 已提交
741

W
wusongqing 已提交
742 743 744
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
745

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

G
ge-yafang 已提交
748
  ```js
W
wusongqing 已提交
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764
   let promise = windowClass.moveTo(300, 300);
   promise.then((data)=> {
      console.info('Window moved. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
   })
  ```

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

W
wusongqing 已提交
767 768 769 770 771
| Name  | Type                     | Mandatory| Description                      |
| -------- | ------------------------- | ---- | -------------------------- |
| width    | number                    | Yes  | New width of the window, in px.|
| height   | number                    | Yes  | New height of the window, in px.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                |
W
wusongqing 已提交
772

W
wusongqing 已提交
773
**Example**
W
wusongqing 已提交
774

G
ge-yafang 已提交
775
  ```js
W
wusongqing 已提交
776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792
  windowClass.resetSize(500, 1000, (err, data) => {
      if (err.code) {
          console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Window size changed. Data: ' + JSON.stringify(data))
  });
  ```

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

W
wusongqing 已提交
795 796 797 798
| 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 已提交
799

W
wusongqing 已提交
800
**Return value**
W
wusongqing 已提交
801

W
wusongqing 已提交
802 803 804
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
805

W
wusongqing 已提交
806
**Example**
W
wusongqing 已提交
807

G
ge-yafang 已提交
808
  ```js
W
wusongqing 已提交
809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826
   let promise = windowClass.resetSize(500, 1000);
   promise.then((data)=> {
      console.info('Window size changed. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
   });
  ```

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

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

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

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

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

W
wusongqing 已提交
827
**Parameters**
W
wusongqing 已提交
828

W
wusongqing 已提交
829 830 831 832
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| type     | [WindowType](#windowtype) | Yes  | Window type.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.|
W
wusongqing 已提交
833

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

G
ge-yafang 已提交
836
  ```js
W
wusongqing 已提交
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856
  var type = window.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))
  });
  ```

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

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

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

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

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

W
wusongqing 已提交
857
**Parameters**
W
wusongqing 已提交
858

W
wusongqing 已提交
859 860 861
| Name| Type                     | Mandatory| Description      |
| ------ | ------------------------- | ---- | ---------- |
| type   | [WindowType](#windowtype) | Yes  | Window type.|
W
wusongqing 已提交
862

W
wusongqing 已提交
863
**Return value**
W
wusongqing 已提交
864

W
wusongqing 已提交
865 866 867
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
868

W
wusongqing 已提交
869
**Example**
W
wusongqing 已提交
870

G
ge-yafang 已提交
871
  ```js
W
wusongqing 已提交
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888
   var type = window.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));
   });
  ```

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

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

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

G
ge-yafang 已提交
897
  ```js
W
wusongqing 已提交
898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914
  windowClass.getProperties((err, data) => {
      if (err.code) {
          console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
  });
  ```

### getProperties

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 已提交
915
**Return value**
W
wusongqing 已提交
916

W
wusongqing 已提交
917 918 919
| Type                                                | Description                                 |
| ---------------------------------------------------- | ------------------------------------- |
| Promise&lt;[WindowProperties](#windowproperties)&gt; | Promise used to return the window properties.|
W
wusongqing 已提交
920

W
wusongqing 已提交
921
**Example**
W
wusongqing 已提交
922

W
wusongqing 已提交
923
  ```js
W
wusongqing 已提交
924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939
   let promise = windowClass.getProperties();
   promise.then((data)=> {
      console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
   });
  ```

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

getAvoidArea(type: AvoidAreaType, callback: AsyncCallback&lt;AvoidArea&gt;): void

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 已提交
940
**Parameters**
W
wusongqing 已提交
941

W
wusongqing 已提交
942 943 944 945
| Name  | Type                                        | Mandatory| Description                                                        |
| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | [AvoidAreaType](#avoidareatype)              | Yes  | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.|
| callback | AsyncCallback&lt;[AvoidArea](#avoidarea)&gt; | Yes  | Callback used to return the area.                                  |
W
wusongqing 已提交
946

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

G
ge-yafang 已提交
949
  ```js
W
wusongqing 已提交
950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967
  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));
  });
  ```

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

getAvoidArea(type: AvoidAreaType): Promise&lt;AvoidArea&gt;

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 已提交
968
**Parameters**
W
wusongqing 已提交
969

W
wusongqing 已提交
970 971 972
| Name| Type                           | Mandatory| Description                                                        |
| ------ | ------------------------------- | ---- | ------------------------------------------------------------ |
| type   | [AvoidAreaType](#avoidareatype) | Yes  | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.|
W
wusongqing 已提交
973

W
wusongqing 已提交
974
**Return value**
W
wusongqing 已提交
975

W
wusongqing 已提交
976 977 978
| Type                                  | Description                                         |
| -------------------------------------- | --------------------------------------------- |
| Promise&lt;[AvoidArea](#avoidarea)&gt; | Promise used to return the area.|
W
wusongqing 已提交
979

W
wusongqing 已提交
980
**Example**
W
wusongqing 已提交
981

G
ge-yafang 已提交
982
  ```js
W
wusongqing 已提交
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998
   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));
   });
  ```

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

W
wusongqing 已提交
1001 1002 1003 1004
| Name      | Type                     | Mandatory| Description                                          |
| ------------ | ------------------------- | ---- | ---------------------------------------------- |
| isFullScreen | boolean                   | Yes  | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.|
| callback     | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                                    |
W
wusongqing 已提交
1005

W
wusongqing 已提交
1006
**Example**
W
wusongqing 已提交
1007

G
ge-yafang 已提交
1008
  ```js
W
wusongqing 已提交
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026
  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))
  });
  ```

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

W
wusongqing 已提交
1029 1030 1031
| 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 已提交
1032

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

W
wusongqing 已提交
1035 1036 1037
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1038

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

G
ge-yafang 已提交
1041
  ```js
W
wusongqing 已提交
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054
  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));
  });
  ```

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

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

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

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

W
wusongqing 已提交
1059
**Parameters**
W
wusongqing 已提交
1060

W
wusongqing 已提交
1061 1062 1063 1064
| 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.|
| callback           | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                                                  |
W
wusongqing 已提交
1065

W
wusongqing 已提交
1066
**Example**
W
wusongqing 已提交
1067

G
ge-yafang 已提交
1068
  ```js
W
wusongqing 已提交
1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082
  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))
  });
  ```

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

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

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

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

W
wusongqing 已提交
1087
**Parameters**
W
wusongqing 已提交
1088

W
wusongqing 已提交
1089 1090 1091
| 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 已提交
1092

W
wusongqing 已提交
1093
**Return value**
W
wusongqing 已提交
1094

W
wusongqing 已提交
1095 1096 1097
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1098

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

G
ge-yafang 已提交
1101
  ```js
W
wusongqing 已提交
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118
  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));
  });
  ```

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

W
wusongqing 已提交
1121 1122 1123 1124
| Name  | Type                     | Mandatory| Description                                                        |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| names    | Array                     | Yes  | Whether to display the status bar and navigation bar. 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 execution result.                                                  |
W
wusongqing 已提交
1125

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

G
ge-yafang 已提交
1128
  ```js
W
wusongqing 已提交
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146
  var names = ["status", "navigation"];
  windowClass.setSystemBarEnable(names, (err, data) => {
      if (err.code) {
          console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data))
  });
  ```

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

W
wusongqing 已提交
1149 1150 1151
| Name| Type | Mandatory| Description                                                        |
| ------ | ----- | ---- | ------------------------------------------------------------ |
| names  | Array | Yes  | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.|
W
wusongqing 已提交
1152

W
wusongqing 已提交
1153
**Return value**
W
wusongqing 已提交
1154

W
wusongqing 已提交
1155 1156 1157
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1158

W
wusongqing 已提交
1159
**Example**
W
wusongqing 已提交
1160

G
ge-yafang 已提交
1161
  ```js
W
wusongqing 已提交
1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178
  var names = ["status", "navigation"];
  let promise = windowClass.setSystemBarEnable(names);
  promise.then((data)=> {
      console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
  });
  ```

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

W
wusongqing 已提交
1181 1182 1183 1184
| Name             | Type                                       | Mandatory| Description                |
| ------------------- | ------------------------------------------- | ---- | -------------------- |
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
| callback            | AsyncCallback&lt;void&gt;                   | Yes  | Callback used to return the execution result.          |
W
wusongqing 已提交
1185

W
wusongqing 已提交
1186
**Example**
W
wusongqing 已提交
1187

G
ge-yafang 已提交
1188
  ```js
W
wusongqing 已提交
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215
  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))
  });
  ```

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

W
wusongqing 已提交
1218 1219 1220
| Name             | Type                                       | Mandatory| Description                |
| ------------------- | ------------------------------------------- | ---- | -------------------- |
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
W
wusongqing 已提交
1221

W
wusongqing 已提交
1222
**Return value**
W
wusongqing 已提交
1223

W
wusongqing 已提交
1224 1225 1226
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1227

W
wusongqing 已提交
1228
**Example**
W
wusongqing 已提交
1229

G
ge-yafang 已提交
1230
  ```js
W
wusongqing 已提交
1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256
  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));
  });
  ```

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

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

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

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

W
wusongqing 已提交
1257
**Parameters**
W
wusongqing 已提交
1258

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

W
wusongqing 已提交
1264
**Example**
W
wusongqing 已提交
1265

G
ge-yafang 已提交
1266
  ```js
W
wusongqing 已提交
1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283
  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))
  });
  ```

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

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

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

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

W
wusongqing 已提交
1284
**Parameters**
W
wusongqing 已提交
1285

W
wusongqing 已提交
1286 1287 1288
| Name| Type  | Mandatory| Description                |
| ------ | ------ | ---- | -------------------- |
| path   | string | Yes  | Path of the page from which the content will be loaded.|
G
ge-yafang 已提交
1289

W
wusongqing 已提交
1290
**Return value**
W
wusongqing 已提交
1291

W
wusongqing 已提交
1292 1293 1294
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1295

W
wusongqing 已提交
1296
**Example**
W
wusongqing 已提交
1297

G
ge-yafang 已提交
1298
  ```js
W
wusongqing 已提交
1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314
  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));
  });
  ```

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

W
wusongqing 已提交
1317 1318 1319
| Name  | Type                        | Mandatory| Description                            |
| -------- | ---------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return whether the window is displayed.|
W
wusongqing 已提交
1320

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

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

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

W
wusongqing 已提交
1343 1344 1345
| Type                  | Description                                                 |
| ---------------------- | ----------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return whether the window is displayed.|
W
wusongqing 已提交
1346

W
wusongqing 已提交
1347
**Example**
W
wusongqing 已提交
1348

G
ge-yafang 已提交
1349
  ```js
W
wusongqing 已提交
1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365
  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));
  });
  ```

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

W
wusongqing 已提交
1368 1369 1370 1371
| Name  | Type                         | Mandatory| Description                                                    |
| -------- | ----------------------------- | ---- | -------------------------------------------------------- |
| type     | string                        | Yes  | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.|
| callback | Callback&lt;[Size](#size)&gt; | Yes  | Callback used to return the information.                                  |
W
wusongqing 已提交
1372

W
wusongqing 已提交
1373
**Example**
W
wusongqing 已提交
1374

G
ge-yafang 已提交
1375
  ```js
W
wusongqing 已提交
1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389
  var type = 'windowSizeChange';
  windowClass.on(type, (data) => {
      console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data));
  });
  ```

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

W
wusongqing 已提交
1392 1393 1394 1395
| Name  | Type                         | Mandatory| Description                                                    |
| -------- | ----------------------------- | ---- | -------------------------------------------------------- |
| type     | string                        | Yes  | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.|
| callback | Callback&lt;[Size](#size)&gt; | No  | Callback used to return the information.                                  |
W
wusongqing 已提交
1396

W
wusongqing 已提交
1397
**Example**
W
wusongqing 已提交
1398

W
wusongqing 已提交
1399
  ```js
W
wusongqing 已提交
1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411
  var type = 'windowSizeChange';
  windowClass.off(type);
  ```

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

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

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

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

W
wusongqing 已提交
1412
**Parameters**
W
wusongqing 已提交
1413

W
wusongqing 已提交
1414 1415 1416 1417
| Name  | Type                                   | Mandatory| Description                                                        |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | string                                  | Yes  | Type of event to listen for. The value is fixed at **systemAvoidAreaChange**, indicating the event of changes to the area where the window cannot be displayed.|
| callback | Callback&lt;[AvoidArea](#avoidarea)&gt; | Yes  | Callback used to return the information.                                      |
W
wusongqing 已提交
1418

W
wusongqing 已提交
1419
**Example**
W
wusongqing 已提交
1420

G
ge-yafang 已提交
1421
  ```js
W
wusongqing 已提交
1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435
  var type = 'systemAvoidAreaChange';
  windowClass.on(type, (data) => {
      console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
  });
  ```

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

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

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

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

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

W
wusongqing 已提交
1438 1439 1440 1441
| Name  | Type                                   | Mandatory| Description                                                        |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | string                                  | Yes  | Type of event to listen for. The value is fixed at **systemAvoidAreaChange**, indicating the event of changes to the area where the window cannot be displayed.|
| callback | Callback&lt;[AvoidArea](#avoidarea)&gt; | No  | Callback used to return the information.                                      |
W
wusongqing 已提交
1442

W
wusongqing 已提交
1443
**Example**
W
wusongqing 已提交
1444

W
wusongqing 已提交
1445
  ```js
W
wusongqing 已提交
1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457
  var type = 'systemAvoidAreaChange';
  windowClass.off(type);
  ```

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

W
wusongqing 已提交
1460 1461 1462 1463
| Name  | Type              | Mandatory| Description                                                        |
| -------- | ------------------ | ---- | ------------------------------------------------------------ |
| type     | string             | Yes  | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.|
| callback | Callbacknumber&gt; | Yes  | Callback used to return the information.                                      |
W
wusongqing 已提交
1464

W
wusongqing 已提交
1465
**Example**
W
wusongqing 已提交
1466

G
ge-yafang 已提交
1467
  ```js
W
wusongqing 已提交
1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481
  var type = 'keyboardHeightChange';
  windowClass.on(type, (data) => {
      console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
  });
  ```

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

W
wusongqing 已提交
1484 1485 1486 1487
| Name  | Type                  | Mandatory| Description                                                        |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| type     | string                 | Yes  | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.|
| callback | Callback&lt;number&gt; | No  | Callback used to return the information.                                      |
W
wusongqing 已提交
1488

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

W
wusongqing 已提交
1491
  ```js
W
wusongqing 已提交
1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503
  var type = 'keyboardHeightChange';
  windowClass.off(type);
  ```

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

W
wusongqing 已提交
1506 1507 1508
| Name  | Type                        | Mandatory| Description                            |
| -------- | ---------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return whether the wide color gamut mode is supported.|
W
wusongqing 已提交
1509

W
wusongqing 已提交
1510
**Example**
W
wusongqing 已提交
1511

G
ge-yafang 已提交
1512
  ```js
W
wusongqing 已提交
1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529
  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))
  })
  ```

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

W
wusongqing 已提交
1532 1533 1534
| Type                  | Description                                                        |
| ---------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return whether the wide color gamut mode is supported.|
W
wusongqing 已提交
1535

W
wusongqing 已提交
1536
**Example**
W
wusongqing 已提交
1537

W
wusongqing 已提交
1538
  ```js
W
wusongqing 已提交
1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554
  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));
  });
  ```

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

W
wusongqing 已提交
1557 1558 1559 1560
| Name    | Type                     | Mandatory| Description        |
| ---------- | ------------------------- | ---- | ------------ |
| colorSpace | [ColorSpace](#colorspace) | Yes  | Color gamut mode.|
| callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.  |
W
wusongqing 已提交
1561

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

G
ge-yafang 已提交
1564
  ```js
W
wusongqing 已提交
1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581
  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))
  })
  ```

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

W
wusongqing 已提交
1584 1585 1586
| Name    | Type                     | Mandatory| Description        |
| ---------- | ------------------------- | ---- | ------------ |
| colorSpace | [ColorSpace](#colorspace) | Yes  | Color gamut mode.|
W
wusongqing 已提交
1587

W
wusongqing 已提交
1588
**Return value**
W
wusongqing 已提交
1589

W
wusongqing 已提交
1590 1591 1592
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1593

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

G
ge-yafang 已提交
1596
  ```js
W
wusongqing 已提交
1597 1598 1599 1600
  let promise = windowClass.isSupportWideGamut(window.ColorSpace.WIDE_GAMUT);
  promise.then((data)=> {
      console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
W
wusongqing 已提交
1601
      console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
W
wusongqing 已提交
1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612
  });
  ```

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

W
wusongqing 已提交
1615 1616 1617
| Name  | Type                                          | Mandatory| Description                      |
| -------- | ---------------------------------------------- | ---- | -------------------------- |
| callback | AsyncCallback&lt;[ColorSpace](#colorspace)&gt; | Yes  | Callback used to return the color gamut mode obtained.|
W
wusongqing 已提交
1618

W
wusongqing 已提交
1619
**Example**
W
wusongqing 已提交
1620

G
ge-yafang 已提交
1621
  ```js
W
wusongqing 已提交
1622 1623
  windowClass.getColorSpace((err, data) => {
      if (err.code) {
W
wusongqing 已提交
1624
          console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err));
W
wusongqing 已提交
1625 1626
          return;
      }
W
wusongqing 已提交
1627
      console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data))
W
wusongqing 已提交
1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638
  })
  ```

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

W
wusongqing 已提交
1641 1642 1643
| Type                                    | Description                                     |
| ---------------------------------------- | ----------------------------------------- |
| Promise&lt;[ColorSpace](#colorspace)&gt; | Promise used to return the color gamut mode obtained.|
W
wusongqing 已提交
1644

W
wusongqing 已提交
1645
**Example**
W
wusongqing 已提交
1646

G
ge-yafang 已提交
1647
  ```js
W
wusongqing 已提交
1648 1649 1650 1651
  let promise = windowClass.getColorSpace();
  promise.then((data)=> {
      console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data))
  }).catch((err)=>{
W
wusongqing 已提交
1652
      console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err));
W
wusongqing 已提交
1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663
  });
  ```

### setBackgroundColor

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

Sets the background color for this window. This API uses an asynchronous callback to return the result.

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

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

W
wusongqing 已提交
1666 1667
| Name  | Type                     | Mandatory| Description                                                        |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
1668
| color    | string                    | Yes  | Background color to set. The value is a hexadecimal color value and is case insensitive, for example, **#00FF00** or **#FF00FF00**.|
W
wusongqing 已提交
1669
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                                                  |
W
wusongqing 已提交
1670

W
wusongqing 已提交
1671
**Example**
W
wusongqing 已提交
1672

G
ge-yafang 已提交
1673
  ```js
W
wusongqing 已提交
1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691
  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));
  });
  ```

### setBackgroundColor

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

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

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

W
wusongqing 已提交
1692
**Parameters**
W
wusongqing 已提交
1693

W
wusongqing 已提交
1694 1695
| Name| Type  | Mandatory| Description                                                        |
| ------ | ------ | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
1696
| color  | string | Yes  | Background color to set. The value is a hexadecimal color value and is case insensitive, for example, **#00FF00** or **#FF00FF00**.|
W
wusongqing 已提交
1697

W
wusongqing 已提交
1698
**Return value**
W
wusongqing 已提交
1699

W
wusongqing 已提交
1700 1701 1702
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1703

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

G
ge-yafang 已提交
1706
  ```js
W
wusongqing 已提交
1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723
  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));
  });
  ```

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

W
wusongqing 已提交
1726 1727 1728 1729
| Name    | Type                     | Mandatory| Description                                |
| ---------- | ------------------------- | ---- | ------------------------------------ |
| brightness | number                    | Yes  | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.|
| callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                          |
W
wusongqing 已提交
1730

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

G
ge-yafang 已提交
1733
  ```js
W
wusongqing 已提交
1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751
  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));
  });
  ```

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

W
wusongqing 已提交
1754 1755 1756
| Name    | Type  | Mandatory| Description                                |
| ---------- | ------ | ---- | ------------------------------------ |
| brightness | number | Yes  | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.|
W
wusongqing 已提交
1757

W
wusongqing 已提交
1758
**Return value**
W
wusongqing 已提交
1759

W
wusongqing 已提交
1760 1761 1762
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1763

W
wusongqing 已提交
1764
**Example**
W
wusongqing 已提交
1765

G
ge-yafang 已提交
1766
  ```js
W
wusongqing 已提交
1767 1768 1769 1770 1771 1772 1773 1774 1775
  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 已提交
1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839
### 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.

> This API is supported since API version 7 and deprecated since API version 9.
> 

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

**Parameters**

| Name        | Type                     | Mandatory| Description                                              |
| -------------- | ------------------------- | ---- | -------------------------------------------------- |
| 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 execution result.                                        |

**Example**

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

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

> This API is supported since API version 7 and deprecated since API version 9.
> 

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

**Parameters**

| Name        | Type  | Mandatory| Description                                              |
| -------------- | ------ | ---- | -------------------------------------------------- |
| dimBehindValue | number | Yes  | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest.|

**Return value**

| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|

**Example**

  ```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 已提交
1840 1841 1842 1843 1844 1845 1846 1847
### 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 已提交
1848
**Parameters**
W
wusongqing 已提交
1849

W
wusongqing 已提交
1850 1851 1852 1853
| Name     | Type                     | Mandatory| Description                        |
| ----------- | ------------------------- | ---- | ---------------------------- |
| isFocusable | boolean                   | Yes  | Whether the window can gain focus.|
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                  |
W
wusongqing 已提交
1854

W
wusongqing 已提交
1855
**Example**
W
wusongqing 已提交
1856

G
ge-yafang 已提交
1857
  ```js
W
wusongqing 已提交
1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875
  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));
  });
  ```

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

W
wusongqing 已提交
1878 1879 1880
| Name     | Type   | Mandatory| Description                        |
| ----------- | ------- | ---- | ---------------------------- |
| isFocusable | boolean | Yes  | Whether the window can gain focus.|
W
wusongqing 已提交
1881

W
wusongqing 已提交
1882
**Return value**
W
wusongqing 已提交
1883

W
wusongqing 已提交
1884 1885 1886
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1887

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

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

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

W
wusongqing 已提交
1910 1911 1912 1913
| Name        | Type                     | Mandatory| Description                    |
| -------------- | ------------------------- | ---- | ------------------------ |
| isKeepScreenOn | boolean                   | Yes  | Whether to keep the screen always on.|
| callback       | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.              |
W
wusongqing 已提交
1914

W
wusongqing 已提交
1915
**Example**
W
wusongqing 已提交
1916

G
ge-yafang 已提交
1917
  ```js
W
wusongqing 已提交
1918 1919 1920 1921 1922 1923 1924 1925 1926 1927
  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));
  });
  ```

W
wusongqing 已提交
1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991
### 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.

> This API is supported since API version 7 and deprecated since API version 9.
> 

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

**Parameters**

| Name   | Type                     | Mandatory| Description            |
| --------- | ------------------------- | ---- | ---------------- |
| 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 execution result.      |

**Example**

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

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

> This API is supported since API version 7 and deprecated since API version 9.
> 

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

**Parameters**

| Name   | Type   | Mandatory| Description            |
| --------- | ------- | ---- | ---------------- |
| 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.|

**Return value**

| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|

**Example**

  ```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 已提交
1992 1993 1994 1995 1996 1997 1998 1999
### 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

W
wusongqing 已提交
2000
**Parameters**
W
wusongqing 已提交
2001

W
wusongqing 已提交
2002 2003 2004
| Name        | Type   | Mandatory| Description                    |
| -------------- | ------- | ---- | ------------------------ |
| isKeepScreenOn | boolean | Yes  | Whether to keep the screen always on.|
W
wusongqing 已提交
2005

W
wusongqing 已提交
2006
**Return value**
W
wusongqing 已提交
2007

W
wusongqing 已提交
2008 2009 2010
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
2011

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

G
ge-yafang 已提交
2014
  ```js
W
wusongqing 已提交
2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031
  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.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
  });
  ```

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

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

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

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

W
wusongqing 已提交
2032
**Parameters**
W
wusongqing 已提交
2033

W
wusongqing 已提交
2034 2035 2036 2037
| Name       | Type                     | Mandatory| Description                |
| ------------- | ------------------------- | ---- | -------------------- |
| isPrivacyMode | boolean                   | Yes  | Whether the window is in privacy mode.|
| callback      | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.          |
W
wusongqing 已提交
2038

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

G
ge-yafang 已提交
2041
  ```js
W
wusongqing 已提交
2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060
  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));
  
  });
  ```

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

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

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

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

W
wusongqing 已提交
2061
**Parameters**
W
wusongqing 已提交
2062

W
wusongqing 已提交
2063 2064 2065
| Name       | Type   | Mandatory| Description                |
| ------------- | ------- | ---- | -------------------- |
| isPrivacyMode | boolean | Yes  | Whether the window is in privacy mode.|
W
wusongqing 已提交
2066

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

W
wusongqing 已提交
2069 2070 2071
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
2072

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

G
ge-yafang 已提交
2075
  ```js
W
wusongqing 已提交
2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092
  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));
  });
  ```

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

W
wusongqing 已提交
2095 2096 2097 2098
| Name     | Type                     | Mandatory| Description                |
| ----------- | ------------------------- | ---- | -------------------- |
| isTouchable | boolean                   | Yes  | Whether the window is touchable.|
| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.          |
W
wusongqing 已提交
2099

W
wusongqing 已提交
2100
**Example**
W
wusongqing 已提交
2101

G
ge-yafang 已提交
2102
  ```js
W
wusongqing 已提交
2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121
  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));
  
  });
  ```

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

W
wusongqing 已提交
2124 2125 2126
| Name     | Type   | Mandatory| Description                |
| ----------- | ------- | ---- | -------------------- |
| isTouchable | boolean | Yes  | Whether the window is touchable.|
W
wusongqing 已提交
2127

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

W
wusongqing 已提交
2130 2131 2132
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
2133

W
wusongqing 已提交
2134
**Example**
W
wusongqing 已提交
2135

G
ge-yafang 已提交
2136
  ```js
W
wusongqing 已提交
2137 2138 2139 2140 2141 2142 2143 2144 2145
  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));
  });
  ```

W
wusongqing 已提交
2146
## WindowStageEventType<sup>9+</sup>
W
wusongqing 已提交
2147 2148 2149 2150 2151

Describes the lifecycle of a window stage.

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

W
wusongqing 已提交
2152 2153 2154 2155 2156 2157
| Name      | Default Value| Description    |
| ---------- | ------ | -------- |
| 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 已提交
2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170

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

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(): Promise&lt;Window&gt;

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

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

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

W
wusongqing 已提交
2173 2174 2175
| Type                            | Description                                                      |
| -------------------------------- | ---------------------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the main window.|
W
wusongqing 已提交
2176

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

G
ge-yafang 已提交
2179
  ```ts
W
wusongqing 已提交
2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202
  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));
          });
      }
  }
  ```

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

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

W
wusongqing 已提交
2203
**Parameters**
W
wusongqing 已提交
2204

W
wusongqing 已提交
2205 2206 2207
| Name  | Type                                  | Mandatory| Description                                   |
| -------- | -------------------------------------- | ---- | --------------------------------------- |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the main window.|
W
wusongqing 已提交
2208

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

G
ge-yafang 已提交
2211
  ```ts
W
wusongqing 已提交
2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234
  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));
          });
      }
  }
  ```

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

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

W
wusongqing 已提交
2236
**Parameters**
W
wusongqing 已提交
2237

W
wusongqing 已提交
2238 2239 2240
| Name| Type  | Mandatory| Description          |
| ------ | ------ | ---- | -------------- |
| name   | String | Yes  | Name of the subwindow.|
G
ge-yafang 已提交
2241

W
wusongqing 已提交
2242
**Return value**
W
wusongqing 已提交
2243

W
wusongqing 已提交
2244 2245 2246
| Type                            | Description                                             |
| -------------------------------- | ------------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
G
ge-yafang 已提交
2247

W
wusongqing 已提交
2248
**Example**
W
wusongqing 已提交
2249

G
ge-yafang 已提交
2250
  ```ts
W
wusongqing 已提交
2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273
  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 create sub window. Data: ' + JSON.stringify(data))
          }).catch((err)=>{
              console.error('Failed to create sub window. Cause: ' + JSON.stringify(err));
          })
      }
  }
  ```

### createSubWindow<sup>9+</sup>

createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void

Creates a subwindow for this window stage. This API uses an asynchronous callback to return the result.

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

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

W
wusongqing 已提交
2276 2277 2278 2279
| Name  | Type                                  | Mandatory| Description                          |
| -------- | -------------------------------------- | ---- | ------------------------------ |
| name     | String                                 | Yes  | Name of the subwindow.                |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes  | Callback used to return the subwindow created.|
W
wusongqing 已提交
2280

W
wusongqing 已提交
2281
**Example**
W
wusongqing 已提交
2282

G
ge-yafang 已提交
2283
  ```ts
W
wusongqing 已提交
2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307
  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 sub window. Cause: ' + JSON.stringify(err));
                  return;
              }
              windowClass = data;
              console.info('Succeeded in create sub window. Data: ' + JSON.stringify(data));
              windowClass.resetSize(500, 1000);
          });
      }
  }
  ```

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

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

W
wusongqing 已提交
2309
**Return value**
W
wusongqing 已提交
2310

W
wusongqing 已提交
2311 2312 2313
| Type                                         | Description                                                        |
| --------------------------------------------- | ------------------------------------------------------------ |
| Promise&lt;Array&lt;[Window](#window)&gt;&gt; | Promise used to return all the subwindows.|
W
wusongqing 已提交
2314

W
wusongqing 已提交
2315
**Example**
W
wusongqing 已提交
2316

G
ge-yafang 已提交
2317
  ```ts
W
wusongqing 已提交
2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339
  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 sub window. Data: ' + JSON.stringify(data))
          }).catch((err)=>{
              console.error('Failed to obtain the sub window. Cause: ' + JSON.stringify(err));
          })
      }
  }
  ```

### getSubWindow<sup>9+</sup>

getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void

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

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

W
wusongqing 已提交
2341
**Parameters**
W
wusongqing 已提交
2342

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

W
wusongqing 已提交
2347
**Example**
W
wusongqing 已提交
2348

G
ge-yafang 已提交
2349
  ```ts
W
wusongqing 已提交
2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371
  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 sub window. Cause: ' + JSON.stringify(err));
                  return;
              }
              windowClass = data;
              console.info('Succeeded in obtaining the sub window. Data: ' + JSON.stringify(data));
          });
      }
  }
  ```

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

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

Loads content to this window stage. This API uses an asynchronous callback to return the result.

W
wusongqing 已提交
2372
**System capability**: SystemCapability.WindowManager.WindowManager.Coretype with the value **windowSizeChange**
W
wusongqing 已提交
2373

W
wusongqing 已提交
2374
**Parameters**
W
wusongqing 已提交
2375

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

W
wusongqing 已提交
2381
**Example**
W
wusongqing 已提交
2382

G
ge-yafang 已提交
2383
  ```ts
W
wusongqing 已提交
2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396
  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 已提交
2397

W
wusongqing 已提交
2398 2399 2400 2401 2402 2403 2404
### on('windowStageEvent')<sup>9+</sup>

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

Enables listening for window stage lifecycle changes.

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

W
wusongqing 已提交
2406
**Parameters**
W
wusongqing 已提交
2407

W
wusongqing 已提交
2408 2409 2410 2411
| Name  | Type                                                        | Mandatory| Description                                                        |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type     | string                                                       | Yes  | Type of event to listen for. 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 information.                                      |
W
wusongqing 已提交
2412

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

G
ge-yafang 已提交
2415
  ```ts
W
wusongqing 已提交
2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
          var type = 'windowStageEvent';
          windowStage.on(type, (data) => {
              console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data));
          });
      }
  }
  ```

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

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

Disables listening for window stage lifecycle changes.

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

W
wusongqing 已提交
2435
**Parameters**
W
wusongqing 已提交
2436

W
wusongqing 已提交
2437 2438 2439 2440
| Name  | Type                                                        | Mandatory| Description                                                        |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type     | string                                                       | Yes  | Type of event to listen for. 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 information.                                      |
G
ge-yafang 已提交
2441

W
wusongqing 已提交
2442
**Example**
W
wusongqing 已提交
2443

G
ge-yafang 已提交
2444
  ```ts
W
wusongqing 已提交
2445 2446 2447 2448 2449 2450 2451 2452
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
          var type = 'windowStageEvent';
          windowStage.off(type);
      }
  }
  ```