js-apis-window.md 97.4 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
>  **NOTE**<br/>
W
wusongqing 已提交
6
> 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 已提交
7

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

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

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

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

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

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

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

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

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

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

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

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 已提交
44 45 46 47 48 49 50
| 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 已提交
51

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

Describes the properties of the status bar and navigation bar.

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

W
wusongqing 已提交
58 59 60 61 62 63 64 65
| Name                                  | Type| Readable| Writable| Description                                                        |
| -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ |
| statusBarColor                         | string   | Yes  | Yes  | Background color of the status bar. The value is a hexadecimal RGB or aRGB color value, for example, **\#00FF00** or **\#FF00FF00**.|
| 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.                                            |
| navigationBarColor                     | string   | Yes  | Yes  | Background color of the navigation bar. The value is a hexadecimal RGB or aRGB color value, for example, **\#00FF00** or **\#FF00FF00**.|
| 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 已提交
66

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

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 已提交
75 76
| Name           | Type                 | Readable| Writable| Description                                                        |
| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
77
| 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 已提交
78 79 80 81
| isEnable        | boolean                   | Yes  | Yes  | Whether the system bar is displayed.                                        |
| region          | [Rect](#rect)             | Yes  | Yes  | Current position and size of the system bar.                                    |
| backgroundColor | string                    | Yes  | Yes  | Background color of the system bar. The value is a hexadecimal RGB or aRGB color value, for example, **\#00FF00** or **\#FF00FF00**.|
| contentColor    | string                    | Yes  | Yes  | Color of the text on the system bar.                                            |
W
wusongqing 已提交
82

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

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 已提交
91 92 93 94
| 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 已提交
95

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

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

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

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

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

Describes the area where the window cannot be displayed.

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

W
wusongqing 已提交
115 116 117 118 119 120
| 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 已提交
121

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

Describes the window size.

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

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

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

Describes the window properties.

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

W
wusongqing 已提交
139 140 141 142 143 144 145 146 147 148 149 150
| 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.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| dimBehindValue<sup>7+</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 API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| isKeepScreenOn                  | boolean                   | Yes  | Yes  | Whether the screen is always on. The default value is **false**.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| isPrivacyMode<sup>7+</sup>      | boolean                   | Yes  | Yes  | Whether the window is in privacy mode. The default value is **false**.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
W
wusongqing 已提交
151
| isRoundCorner<sup>7+</sup>      | boolean                   | Yes  | Yes  | Whether the window has rounded corners. The default value is **false**.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
W
wusongqing 已提交
152
| isTransparent<sup>7+</sup>      | boolean                   | Yes  | Yes  | Whether the window is transparent. The default value is **false**.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
W
wusongqing 已提交
153

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

Describes the color gamut mode.

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

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

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

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 已提交
171 172
This API is discarded since API version 8. You are advised to use [window.create<sup>8+</sup>](#windowcreate8) instead.

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

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

W
wusongqing 已提交
177 178 179 180 181
  | 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 已提交
182

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

G
ge-yafang 已提交
185
  ```js
W
wusongqing 已提交
186 187 188 189 190 191 192 193 194 195 196 197
   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 已提交
198
## window.create<sup>7+</sup>
W
wusongqing 已提交
199 200 201 202 203

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

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

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

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

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

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

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

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

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

G
ge-yafang 已提交
223
  ```js
W
wusongqing 已提交
224 225 226 227 228 229 230
   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 已提交
231
   });
W
wusongqing 已提交
232
  ```
Z
zengyawen 已提交
233

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

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

W
wusongqing 已提交
238 239 240
Creates a subwindow when the context is [Context](js-apis-Context.md). This API uses an asynchronous callback to return the result.

Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md), starting from API version 9. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
241 242 243

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

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

W
wusongqing 已提交
246 247 248 249 250 251
  | 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-service-extension-context.md).|
  | 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 已提交
252

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

G
ge-yafang 已提交
255
  ```js
W
wusongqing 已提交
256 257 258 259 260 261
   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 已提交
262
      windowClass = data;
W
wusongqing 已提交
263 264 265 266
      console.info('Window created. Data: ' + JSON.stringify(data))
      windowClass.resetSize(500, 1000);
  });
  ```
Z
zengyawen 已提交
267

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

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

W
wusongqing 已提交
272 273 274
Creates a subwindow when the context is [Context](js-apis-Context.md). This API uses a promise to return the result.

Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md), starting from API version 9. This API uses a promise to return the result.
W
wusongqing 已提交
275 276

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

W
wusongqing 已提交
278
**Parameters**
E
ester.zhou 已提交
279

W
wusongqing 已提交
280 281 282 283 284
  | 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-service-extension-context.md).|
  | id     | string                    | Yes  | Window ID.                                                    |
  | type   | [WindowType](#windowtype) | Yes  | Window type.                                                  |
W
wusongqing 已提交
285

W
wusongqing 已提交
286
**Return value**
E
ester.zhou 已提交
287

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

W
wusongqing 已提交
292
**Example**
W
wusongqing 已提交
293

G
ge-yafang 已提交
294
  ```js
W
wusongqing 已提交
295 296 297 298 299 300 301 302 303 304
   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 已提交
305
## window.find<sup>7+</sup>
W
wusongqing 已提交
306 307 308 309 310 311 312

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 已提交
313
**Parameters**
W
wusongqing 已提交
314

W
wusongqing 已提交
315 316 317 318
  | 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 已提交
319

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

G
ge-yafang 已提交
322
  ```js
W
wusongqing 已提交
323 324 325 326 327 328 329 330
   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 已提交
331 332 333
  });
  ```

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

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

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

W
wusongqing 已提交
340
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
341

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

W
wusongqing 已提交
344 345 346
  | Name| Type  | Mandatory| Description    |
  | ------ | ------ | ---- | -------- |
  | id     | string | Yes  | Window ID.|
W
wusongqing 已提交
347

W
wusongqing 已提交
348
**Return value**
W
wusongqing 已提交
349

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

W
wusongqing 已提交
354
**Example**
W
wusongqing 已提交
355

G
ge-yafang 已提交
356
  ```js
W
wusongqing 已提交
357 358 359 360 361 362 363 364 365
   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 已提交
366

W
wusongqing 已提交
367
## window.getTopWindow
W
wusongqing 已提交
368 369 370 371 372

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 已提交
373 374
This API is discarded since API version 8. You are advised to use [window.getTopWindow<sup>8+</sup>](#windowgettopwindow8) instead.

W
wusongqing 已提交
375
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
376

W
wusongqing 已提交
377
**Parameters**
Z
zengyawen 已提交
378

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

W
wusongqing 已提交
383
**Example**
Z
zengyawen 已提交
384

G
ge-yafang 已提交
385
  ```js
W
wusongqing 已提交
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
  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 已提交
403 404
This API is discarded since API version 8. You are advised to use [window.getTopWindow<sup>8+</sup>](#windowgettopwindow8) instead.

W
wusongqing 已提交
405 406
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
407
**Return value**
W
wusongqing 已提交
408

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

W
wusongqing 已提交
413
**Example**
W
wusongqing 已提交
414

G
ge-yafang 已提交
415
  ```js
W
wusongqing 已提交
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
   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 已提交
434
**Parameters**
W
wusongqing 已提交
435

W
wusongqing 已提交
436 437 438 439
  | 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 已提交
440

W
wusongqing 已提交
441
**Example**
W
wusongqing 已提交
442

G
ge-yafang 已提交
443
  ```js
W
wusongqing 已提交
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
  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 已提交
463
**Parameters**
W
wusongqing 已提交
464

W
wusongqing 已提交
465 466 467
  | 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 已提交
468

W
wusongqing 已提交
469
**Return value**
W
wusongqing 已提交
470

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

W
wusongqing 已提交
475
**Example**
W
wusongqing 已提交
476

G
ge-yafang 已提交
477
  ```js
W
wusongqing 已提交
478 479 480 481 482 483 484 485 486 487 488 489 490 491
   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 已提交
492
Enables listening for properties changes of the status bar and navigation bar.
W
wusongqing 已提交
493 494 495 496 497

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

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

W
wusongqing 已提交
498
**Parameters**
W
wusongqing 已提交
499

W
wusongqing 已提交
500 501
  | Name  | Type                                                     | Mandatory| Description                                                        |
  | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
502
  | 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.|
W
wusongqing 已提交
503
  | callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | Yes  | Callback used to return the information.                                      |
W
wusongqing 已提交
504

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

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

W
wusongqing 已提交
514 515 516
## off('systemBarTintChange')<sup>8+</sup>

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

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

W
wusongqing 已提交
520 521 522
This is a system API and cannot be called by third-party applications.

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

W
wusongqing 已提交
524
**Parameters**
Z
zengyawen 已提交
525

W
wusongqing 已提交
526 527
  | Name  | Type                                                     | Mandatory| Description                                                        |
  | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
528
  | 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.|
W
wusongqing 已提交
529
  | callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | No  | Callback used to return the information.                                      |
Z
zengyawen 已提交
530

W
wusongqing 已提交
531
**Example**
Z
zengyawen 已提交
532

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

## Window

W
wusongqing 已提交
540
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 已提交
541 542 543 544 545 546 547 548 549 550 551

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

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

W
wusongqing 已提交
558
**Example**
W
wusongqing 已提交
559

G
ge-yafang 已提交
560
  ```js
W
wusongqing 已提交
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
  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 已提交
580
**Return value**
W
wusongqing 已提交
581

W
wusongqing 已提交
582 583 584
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
585

W
wusongqing 已提交
586
**Example**
W
wusongqing 已提交
587

G
ge-yafang 已提交
588
  ```js
W
wusongqing 已提交
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
   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 已提交
605
**Parameters**
W
wusongqing 已提交
606

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

W
wusongqing 已提交
611
**Example**
W
wusongqing 已提交
612

G
ge-yafang 已提交
613
  ```js
W
wusongqing 已提交
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
  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 已提交
631
**Return value**
W
wusongqing 已提交
632

W
wusongqing 已提交
633 634 635
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
636

W
wusongqing 已提交
637
**Example**
W
wusongqing 已提交
638

G
ge-yafang 已提交
639
  ```js
W
wusongqing 已提交
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655
   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 已提交
656
**Parameters**
W
wusongqing 已提交
657

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

W
wusongqing 已提交
662
**Example**
W
wusongqing 已提交
663

G
ge-yafang 已提交
664
  ```js
W
wusongqing 已提交
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681
  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 已提交
682
**Return value**
W
wusongqing 已提交
683

W
wusongqing 已提交
684 685 686
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
687

W
wusongqing 已提交
688
**Example**
W
wusongqing 已提交
689

G
ge-yafang 已提交
690
  ```js
W
wusongqing 已提交
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706
   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

Moves the position of this window. This API uses an asynchronous callback to return the result.

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

W
wusongqing 已提交
707
**Parameters**
W
wusongqing 已提交
708

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

W
wusongqing 已提交
715
**Example**
W
wusongqing 已提交
716

G
ge-yafang 已提交
717
  ```js
W
wusongqing 已提交
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735
  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;

Moves the position of this window. This API uses a promise to return the result.

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

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

W
wusongqing 已提交
738 739 740 741
  | Name| Type  | Mandatory| Description                                   |
  | ------ | ------ | ---- | --------------------------------------- |
  | x      | number | Yes  | Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.|
  | y      | number | Yes  | Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.|
W
wusongqing 已提交
742

W
wusongqing 已提交
743
**Return value**
W
wusongqing 已提交
744

W
wusongqing 已提交
745 746 747
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
748

W
wusongqing 已提交
749
**Example**
W
wusongqing 已提交
750

G
ge-yafang 已提交
751
  ```js
W
wusongqing 已提交
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767
   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 已提交
768
**Parameters**
W
wusongqing 已提交
769

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

W
wusongqing 已提交
776
**Example**
W
wusongqing 已提交
777

G
ge-yafang 已提交
778
  ```js
W
wusongqing 已提交
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795
  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 已提交
796
**Parameters**
W
wusongqing 已提交
797

W
wusongqing 已提交
798 799 800 801
  | Name| Type  | Mandatory| Description            |
  | ------ | ------ | ---- | ---------------- |
  | width  | number | Yes  | New width of the window.|
  | height | number | Yes  | New height of the window.|
W
wusongqing 已提交
802

W
wusongqing 已提交
803
**Return value**
W
wusongqing 已提交
804

W
wusongqing 已提交
805 806 807
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
808

W
wusongqing 已提交
809
**Example**
W
wusongqing 已提交
810

G
ge-yafang 已提交
811
  ```js
W
wusongqing 已提交
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829
   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 已提交
830
**Parameters**
W
wusongqing 已提交
831

W
wusongqing 已提交
832 833 834 835
  | 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 已提交
836

W
wusongqing 已提交
837
**Example**
W
wusongqing 已提交
838

G
ge-yafang 已提交
839
  ```js
W
wusongqing 已提交
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859
  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 已提交
860
**Parameters**
W
wusongqing 已提交
861

W
wusongqing 已提交
862 863 864
  | Name| Type                     | Mandatory| Description      |
  | ------ | ------------------------- | ---- | ---------- |
  | type   | [WindowType](#windowtype) | Yes  | Window type.|
W
wusongqing 已提交
865

W
wusongqing 已提交
866
**Return value**
W
wusongqing 已提交
867

W
wusongqing 已提交
868 869 870
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
871

W
wusongqing 已提交
872
**Example**
W
wusongqing 已提交
873

G
ge-yafang 已提交
874
  ```js
W
wusongqing 已提交
875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891
   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 已提交
892
**Parameters**
W
wusongqing 已提交
893

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

W
wusongqing 已提交
898
**Example**
W
wusongqing 已提交
899

G
ge-yafang 已提交
900
  ```js
W
wusongqing 已提交
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917
  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 已提交
918
**Return value**
W
wusongqing 已提交
919

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

W
wusongqing 已提交
924
**Example**
W
wusongqing 已提交
925

W
wusongqing 已提交
926
  ```js
W
wusongqing 已提交
927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942
   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 已提交
943
**Parameters**
W
wusongqing 已提交
944

W
wusongqing 已提交
945 946 947 948
  | 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 已提交
949

W
wusongqing 已提交
950
**Example**
W
wusongqing 已提交
951

G
ge-yafang 已提交
952
  ```js
W
wusongqing 已提交
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970
  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 已提交
971
**Parameters**
W
wusongqing 已提交
972

W
wusongqing 已提交
973 974 975
  | 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 已提交
976

W
wusongqing 已提交
977
**Return value**
W
wusongqing 已提交
978

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

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

G
ge-yafang 已提交
985
  ```js
W
wusongqing 已提交
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001
   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 已提交
1002
**Parameters**
W
wusongqing 已提交
1003

W
wusongqing 已提交
1004 1005 1006 1007
  | 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 已提交
1008

W
wusongqing 已提交
1009
**Example**
W
wusongqing 已提交
1010

G
ge-yafang 已提交
1011
  ```js
W
wusongqing 已提交
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029
  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 已提交
1030
**Parameters**
W
wusongqing 已提交
1031

W
wusongqing 已提交
1032 1033 1034
  | 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 已提交
1035

W
wusongqing 已提交
1036
**Return value**
W
wusongqing 已提交
1037

W
wusongqing 已提交
1038 1039 1040
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1041

W
wusongqing 已提交
1042
**Example**
W
wusongqing 已提交
1043

G
ge-yafang 已提交
1044
  ```js
W
wusongqing 已提交
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061
  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

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

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

W
wusongqing 已提交
1062
**Parameters**
W
wusongqing 已提交
1063

W
wusongqing 已提交
1064 1065 1066 1067
  | Name            | Type                     | Mandatory| Description                                                        |
  | ------------------ | ------------------------- | ---- | ------------------------------------------------------------ |
  | isLayoutFullScreen | boolean                   | Yes  | Whether the window layout is in full-screen mode, 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 已提交
1068

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

G
ge-yafang 已提交
1071
  ```js
W
wusongqing 已提交
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089
  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;

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

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

W
wusongqing 已提交
1090
**Parameters**
W
wusongqing 已提交
1091

W
wusongqing 已提交
1092 1093 1094
  | Name            | Type   | Mandatory| Description                                                        |
  | ------------------ | ------- | ---- | ------------------------------------------------------------ |
  | isLayoutFullScreen | boolean | Yes  | Whether the window layout is in full-screen mode, in which the status bar and navigation bar are displayed.|
W
wusongqing 已提交
1095

W
wusongqing 已提交
1096
**Return value**
W
wusongqing 已提交
1097

W
wusongqing 已提交
1098 1099 1100
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1101

W
wusongqing 已提交
1102
**Example**
W
wusongqing 已提交
1103

G
ge-yafang 已提交
1104
  ```js
W
wusongqing 已提交
1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121
  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 已提交
1122
**Parameters**
W
wusongqing 已提交
1123

W
wusongqing 已提交
1124 1125 1126 1127
  | 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 已提交
1128

W
wusongqing 已提交
1129
**Example**
W
wusongqing 已提交
1130

G
ge-yafang 已提交
1131
  ```js
W
wusongqing 已提交
1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149
  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 已提交
1150
**Parameters**
W
wusongqing 已提交
1151

W
wusongqing 已提交
1152 1153 1154
  | 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 已提交
1155

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

W
wusongqing 已提交
1158 1159 1160
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1161

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

G
ge-yafang 已提交
1164
  ```js
W
wusongqing 已提交
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181
  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 已提交
1182
**Parameters**
W
wusongqing 已提交
1183

W
wusongqing 已提交
1184 1185 1186 1187
  | 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 已提交
1188

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

G
ge-yafang 已提交
1191
  ```js
W
wusongqing 已提交
1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218
  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 已提交
1219
**Parameters**
W
wusongqing 已提交
1220

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

W
wusongqing 已提交
1225
**Return value**
W
wusongqing 已提交
1226

W
wusongqing 已提交
1227 1228 1229
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1230

W
wusongqing 已提交
1231
**Example**
W
wusongqing 已提交
1232

G
ge-yafang 已提交
1233
  ```js
W
wusongqing 已提交
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259
  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 已提交
1260
**Parameters**
W
wusongqing 已提交
1261

W
wusongqing 已提交
1262 1263 1264 1265
  | 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 已提交
1266

W
wusongqing 已提交
1267
**Example**
W
wusongqing 已提交
1268

G
ge-yafang 已提交
1269
  ```js
W
wusongqing 已提交
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286
  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 已提交
1287
**Parameters**
W
wusongqing 已提交
1288

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

W
wusongqing 已提交
1293
**Return value**
W
wusongqing 已提交
1294

W
wusongqing 已提交
1295 1296 1297
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1298

W
wusongqing 已提交
1299
**Example**
W
wusongqing 已提交
1300

G
ge-yafang 已提交
1301
  ```js
W
wusongqing 已提交
1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317
  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 已提交
1318
**Parameters**
W
wusongqing 已提交
1319

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

W
wusongqing 已提交
1324
**Example**
W
wusongqing 已提交
1325

G
ge-yafang 已提交
1326
  ```js
W
wusongqing 已提交
1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343
  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 已提交
1344
**Return value**
W
wusongqing 已提交
1345

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

W
wusongqing 已提交
1350
**Example**
W
wusongqing 已提交
1351

G
ge-yafang 已提交
1352
  ```js
W
wusongqing 已提交
1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368
  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 已提交
1369
**Parameters**
W
wusongqing 已提交
1370

W
wusongqing 已提交
1371 1372 1373 1374
  | 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 已提交
1375

W
wusongqing 已提交
1376
**Example**
W
wusongqing 已提交
1377

G
ge-yafang 已提交
1378
  ```js
W
wusongqing 已提交
1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392
  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 已提交
1393
**Parameters**
W
wusongqing 已提交
1394

W
wusongqing 已提交
1395 1396 1397 1398
  | 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 已提交
1399

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

W
wusongqing 已提交
1402
  ```js
W
wusongqing 已提交
1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414
  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 已提交
1415
**Parameters**
W
wusongqing 已提交
1416

W
wusongqing 已提交
1417 1418
  | Name  | Type                                   | Mandatory| Description                                                        |
  | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
1419
  | 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.|
W
wusongqing 已提交
1420
  | callback | Callback&lt;[AvoidArea](#avoidarea)&gt; | Yes  | Callback used to return the information.                                      |
W
wusongqing 已提交
1421

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

G
ge-yafang 已提交
1424
  ```js
W
wusongqing 已提交
1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438
  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 已提交
1439
**Parameters**
W
wusongqing 已提交
1440

W
wusongqing 已提交
1441 1442
  | Name  | Type                                   | Mandatory| Description                                                        |
  | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
1443
  | 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.|
W
wusongqing 已提交
1444
  | callback | Callback&lt;[AvoidArea](#avoidarea)&gt; | No  | Callback used to return the information.                                      |
W
wusongqing 已提交
1445

W
wusongqing 已提交
1446
**Example**
W
wusongqing 已提交
1447

W
wusongqing 已提交
1448
  ```js
W
wusongqing 已提交
1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462
  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.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

W
wusongqing 已提交
1463
**Parameters**
W
wusongqing 已提交
1464

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

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

G
ge-yafang 已提交
1472
  ```js
W
wusongqing 已提交
1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488
  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.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

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

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

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

W
wusongqing 已提交
1498
  ```js
W
wusongqing 已提交
1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510
  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 已提交
1511
**Parameters**
W
wusongqing 已提交
1512

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

W
wusongqing 已提交
1517
**Example**
W
wusongqing 已提交
1518

G
ge-yafang 已提交
1519
  ```js
W
wusongqing 已提交
1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536
  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 已提交
1537
**Return value**
W
wusongqing 已提交
1538

W
wusongqing 已提交
1539
  | Type                  | Description                                                        |
W
wusongqing 已提交
1540
  | ---------------------- | ------------------------------------------------------------ |
W
wusongqing 已提交
1541
  | Promise&lt;boolean&gt; | Promise used to return whether the wide color gamut mode is supported.|
W
wusongqing 已提交
1542

W
wusongqing 已提交
1543
**Example**
W
wusongqing 已提交
1544

W
wusongqing 已提交
1545
  ```js
W
wusongqing 已提交
1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561
  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 已提交
1562
**Parameters**
W
wusongqing 已提交
1563

W
wusongqing 已提交
1564 1565 1566 1567
  | 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 已提交
1568

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

G
ge-yafang 已提交
1571
  ```js
W
wusongqing 已提交
1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588
  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 已提交
1589
**Parameters**
W
wusongqing 已提交
1590

W
wusongqing 已提交
1591 1592 1593
  | Name    | Type                     | Mandatory| Description        |
  | ---------- | ------------------------- | ---- | ------------ |
  | colorSpace | [ColorSpace](#colorspace) | Yes  | Color gamut mode.|
W
wusongqing 已提交
1594

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

W
wusongqing 已提交
1597 1598 1599
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1600

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

G
ge-yafang 已提交
1603
  ```js
W
wusongqing 已提交
1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619
  let promise = windowClass.isSupportWideGamut(window.ColorSpace.WIDE_GAMUT);
  promise.then((data)=> {
      console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set window colorspacet. Cause: ' + JSON.stringify(err));
  });
  ```

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

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

W
wusongqing 已提交
1626
**Example**
W
wusongqing 已提交
1627

G
ge-yafang 已提交
1628
  ```js
W
wusongqing 已提交
1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645
  windowClass.getColorSpace((err, data) => {
      if (err.code) {
          console.error('Failed to get window color space. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data))
  })
  ```

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

W
wusongqing 已提交
1648 1649 1650
  | Type                                    | Description                                     |
  | ---------------------------------------- | ----------------------------------------- |
  | Promise&lt;[ColorSpace](#colorspace)&gt; | Promise used to return the color gamut mode obtained.|
W
wusongqing 已提交
1651

W
wusongqing 已提交
1652
**Example**
W
wusongqing 已提交
1653

G
ge-yafang 已提交
1654
  ```js
W
wusongqing 已提交
1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672
  let promise = windowClass.getColorSpace();
  promise.then((data)=> {
      console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set window colorspacet. Cause: ' + JSON.stringify(err));
  });
  ```

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

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

W
wusongqing 已提交
1673
**Parameters**
W
wusongqing 已提交
1674

W
wusongqing 已提交
1675 1676 1677 1678
  | Name  | Type                     | Mandatory| Description                                                        |
  | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
  | color    | string                    | Yes  | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.|
  | callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                                                  |
W
wusongqing 已提交
1679

W
wusongqing 已提交
1680
**Example**
W
wusongqing 已提交
1681

G
ge-yafang 已提交
1682
  ```js
W
wusongqing 已提交
1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702
  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.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

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

W
wusongqing 已提交
1705 1706 1707
  | Name| Type  | Mandatory| Description                                                        |
  | ------ | ------ | ---- | ------------------------------------------------------------ |
  | color  | string | Yes  | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.|
W
wusongqing 已提交
1708

W
wusongqing 已提交
1709
**Return value**
W
wusongqing 已提交
1710

W
wusongqing 已提交
1711 1712 1713
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1714

W
wusongqing 已提交
1715
**Example**
W
wusongqing 已提交
1716

G
ge-yafang 已提交
1717
  ```js
W
wusongqing 已提交
1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736
  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.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

W
wusongqing 已提交
1737
**Parameters**
W
wusongqing 已提交
1738

W
wusongqing 已提交
1739 1740 1741 1742
  | 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 已提交
1743

W
wusongqing 已提交
1744
**Example**
W
wusongqing 已提交
1745

G
ge-yafang 已提交
1746
  ```js
W
wusongqing 已提交
1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766
  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.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

W
wusongqing 已提交
1767
**Parameters**
W
wusongqing 已提交
1768

W
wusongqing 已提交
1769 1770 1771
  | Name    | Type  | Mandatory| Description                                |
  | ---------- | ------ | ---- | ------------------------------------ |
  | brightness | number | Yes  | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.|
W
wusongqing 已提交
1772

W
wusongqing 已提交
1773
**Return value**
W
wusongqing 已提交
1774

W
wusongqing 已提交
1775 1776 1777
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1778

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

G
ge-yafang 已提交
1781
  ```js
W
wusongqing 已提交
1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800
  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));
  });
  ```

### setDimBehind<sup>7+</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 defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

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

W
wusongqing 已提交
1803 1804 1805 1806
  | 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.                                        |
W
wusongqing 已提交
1807

W
wusongqing 已提交
1808
**Example**
W
wusongqing 已提交
1809

G
ge-yafang 已提交
1810
  ```js
W
wusongqing 已提交
1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829
  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>7+</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 defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

W
wusongqing 已提交
1830
**Parameters**
W
wusongqing 已提交
1831

W
wusongqing 已提交
1832 1833 1834
  | 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.|
W
wusongqing 已提交
1835

W
wusongqing 已提交
1836
**Return value**
W
wusongqing 已提交
1837

W
wusongqing 已提交
1838 1839 1840
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1841

W
wusongqing 已提交
1842
**Example**
W
wusongqing 已提交
1843

G
ge-yafang 已提交
1844
  ```js
W
wusongqing 已提交
1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862
  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));
  });
  ```

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

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

W
wusongqing 已提交
1863
**Parameters**
W
wusongqing 已提交
1864

W
wusongqing 已提交
1865 1866 1867 1868
  | 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 已提交
1869

W
wusongqing 已提交
1870
**Example**
W
wusongqing 已提交
1871

G
ge-yafang 已提交
1872
  ```js
W
wusongqing 已提交
1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892
  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.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

W
wusongqing 已提交
1893
**Parameters**
W
wusongqing 已提交
1894

W
wusongqing 已提交
1895 1896 1897
  | Name     | Type   | Mandatory| Description                        |
  | ----------- | ------- | ---- | ---------------------------- |
  | isFocusable | boolean | Yes  | Whether the window can gain focus.|
W
wusongqing 已提交
1898

W
wusongqing 已提交
1899
**Return value**
W
wusongqing 已提交
1900

W
wusongqing 已提交
1901 1902 1903
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1904

W
wusongqing 已提交
1905
**Example**
W
wusongqing 已提交
1906

G
ge-yafang 已提交
1907
  ```js
W
wusongqing 已提交
1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926
  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.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

W
wusongqing 已提交
1927
**Parameters**
W
wusongqing 已提交
1928

W
wusongqing 已提交
1929 1930 1931 1932
  | 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 已提交
1933

W
wusongqing 已提交
1934
**Example**
W
wusongqing 已提交
1935

G
ge-yafang 已提交
1936
  ```js
W
wusongqing 已提交
1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956
  var isKeepScreenOn = true;
  windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => {
      if (err.code) {
          console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
  });
  ```

### setKeepScreenOn

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

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

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

W
wusongqing 已提交
1957
**Parameters**
W
wusongqing 已提交
1958

W
wusongqing 已提交
1959 1960 1961
  | Name        | Type   | Mandatory| Description                    |
  | -------------- | ------- | ---- | ------------------------ |
  | isKeepScreenOn | boolean | Yes  | Whether to keep the screen always on.|
W
wusongqing 已提交
1962

W
wusongqing 已提交
1963
**Return value**
W
wusongqing 已提交
1964

W
wusongqing 已提交
1965 1966 1967
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1968

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

G
ge-yafang 已提交
1971
  ```js
W
wusongqing 已提交
1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
  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));
  });
  ```

### setOutsideTouchable<sup>7+</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 defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

W
wusongqing 已提交
1991
**Parameters**
W
wusongqing 已提交
1992

W
wusongqing 已提交
1993 1994 1995 1996
  | 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.      |
W
wusongqing 已提交
1997

W
wusongqing 已提交
1998
**Example**
W
wusongqing 已提交
1999

G
ge-yafang 已提交
2000
  ```js
W
wusongqing 已提交
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019
  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>7+</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 defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

W
wusongqing 已提交
2020
**Parameters**
W
wusongqing 已提交
2021

W
wusongqing 已提交
2022 2023 2024
  | 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.|
W
wusongqing 已提交
2025

W
wusongqing 已提交
2026
**Return value**
W
wusongqing 已提交
2027

W
wusongqing 已提交
2028 2029 2030
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
2031

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

G
ge-yafang 已提交
2034
  ```js
W
wusongqing 已提交
2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052
  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));
  });
  ```

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

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

W
wusongqing 已提交
2053
**Parameters**
W
wusongqing 已提交
2054

W
wusongqing 已提交
2055 2056 2057 2058
  | 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 已提交
2059

W
wusongqing 已提交
2060
**Example**
W
wusongqing 已提交
2061

G
ge-yafang 已提交
2062
  ```js
W
wusongqing 已提交
2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083
  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.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

W
wusongqing 已提交
2084
**Parameters**
W
wusongqing 已提交
2085

W
wusongqing 已提交
2086 2087 2088
  | Name       | Type   | Mandatory| Description                |
  | ------------- | ------- | ---- | -------------------- |
  | isPrivacyMode | boolean | Yes  | Whether the window is in privacy mode.|
W
wusongqing 已提交
2089

W
wusongqing 已提交
2090
**Return value**
W
wusongqing 已提交
2091

W
wusongqing 已提交
2092 2093 2094
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
2095

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

G
ge-yafang 已提交
2098
  ```js
W
wusongqing 已提交
2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117
  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.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

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

W
wusongqing 已提交
2120 2121 2122 2123
  | 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 已提交
2124

W
wusongqing 已提交
2125
**Example**
W
wusongqing 已提交
2126

G
ge-yafang 已提交
2127
  ```js
W
wusongqing 已提交
2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148
  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.

This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.

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

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

W
wusongqing 已提交
2151 2152 2153
  | Name     | Type   | Mandatory| Description                |
  | ----------- | ------- | ---- | -------------------- |
  | isTouchable | boolean | Yes  | Whether the window is touchable.|
W
wusongqing 已提交
2154

W
wusongqing 已提交
2155
**Return value**
W
wusongqing 已提交
2156

W
wusongqing 已提交
2157 2158 2159
  | Type               | Description                                           |
  | ------------------- | ----------------------------------------------- |
  | Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
2160

W
wusongqing 已提交
2161
**Example**
W
wusongqing 已提交
2162

G
ge-yafang 已提交
2163
  ```js
W
wusongqing 已提交
2164 2165 2166 2167 2168 2169 2170 2171 2172
  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 已提交
2173
## WindowStageEventType<sup>9+</sup>
W
wusongqing 已提交
2174 2175 2176 2177 2178

Describes the lifecycle of a window stage.

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

W
wusongqing 已提交
2179 2180 2181 2182 2183 2184
| 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 已提交
2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197

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

W
wusongqing 已提交
2200 2201 2202
  | Type                            | Description                                                      |
  | -------------------------------- | ---------------------------------------------------------- |
  | Promise&lt;[Window](#window)&gt; | Promise used to return the main window.|
W
wusongqing 已提交
2203

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

G
ge-yafang 已提交
2206
  ```ts
W
wusongqing 已提交
2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229
  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 已提交
2230
**Parameters**
W
wusongqing 已提交
2231

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

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

G
ge-yafang 已提交
2238
  ```ts
W
wusongqing 已提交
2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261
  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 已提交
2262

W
wusongqing 已提交
2263
**Parameters**
W
wusongqing 已提交
2264

W
wusongqing 已提交
2265 2266 2267
  | Name| Type  | Mandatory| Description          |
  | ------ | ------ | ---- | -------------- |
  | name   | String | Yes  | Name of the subwindow.|
G
ge-yafang 已提交
2268

W
wusongqing 已提交
2269
**Return value**
W
wusongqing 已提交
2270

W
wusongqing 已提交
2271 2272 2273
  | Type                            | Description                                             |
  | -------------------------------- | ------------------------------------------------- |
  | Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
G
ge-yafang 已提交
2274

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

G
ge-yafang 已提交
2277
  ```ts
W
wusongqing 已提交
2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300
  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 已提交
2301
**Parameters**
W
wusongqing 已提交
2302

W
wusongqing 已提交
2303 2304 2305 2306
  | 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 已提交
2307

W
wusongqing 已提交
2308
**Example**
W
wusongqing 已提交
2309

G
ge-yafang 已提交
2310
  ```ts
W
wusongqing 已提交
2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334
  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 已提交
2335

W
wusongqing 已提交
2336
**Return value**
W
wusongqing 已提交
2337

W
wusongqing 已提交
2338 2339 2340
  | Type                                         | Description                                                        |
  | --------------------------------------------- | ------------------------------------------------------------ |
  | Promise&lt;Array&lt;[Window](#window)&gt;&gt; | Promise used to return all the subwindows.|
W
wusongqing 已提交
2341

W
wusongqing 已提交
2342
**Example**
W
wusongqing 已提交
2343

G
ge-yafang 已提交
2344
  ```ts
W
wusongqing 已提交
2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366
  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 已提交
2367

W
wusongqing 已提交
2368
**Parameters**
W
wusongqing 已提交
2369

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

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

G
ge-yafang 已提交
2376
  ```ts
W
wusongqing 已提交
2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398
  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 已提交
2399
**System capability**: SystemCapability.WindowManager.WindowManager.Coretype with the value **windowSizeChange**
W
wusongqing 已提交
2400

W
wusongqing 已提交
2401
**Parameters**
W
wusongqing 已提交
2402

W
wusongqing 已提交
2403 2404 2405 2406
  | 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 已提交
2407

W
wusongqing 已提交
2408
**Example**
W
wusongqing 已提交
2409

G
ge-yafang 已提交
2410
  ```ts
W
wusongqing 已提交
2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423
  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 已提交
2424

W
wusongqing 已提交
2425 2426 2427 2428 2429 2430 2431
### 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 已提交
2432

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

W
wusongqing 已提交
2435 2436
  | Name  | Type                                                        | Mandatory| Description                                                        |
  | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
2437
  | type     | string                                                       | Yes  | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.|
W
wusongqing 已提交
2438
  | callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | Yes  | Callback used to return the information.                                      |
W
wusongqing 已提交
2439

W
wusongqing 已提交
2440
**Example**
W
wusongqing 已提交
2441

G
ge-yafang 已提交
2442
  ```ts
W
wusongqing 已提交
2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460
  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 已提交
2461

W
wusongqing 已提交
2462
**Parameters**
W
wusongqing 已提交
2463

W
wusongqing 已提交
2464 2465
  | Name  | Type                                                        | Mandatory| Description                                                        |
  | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
2466
  | type     | string                                                       | Yes  | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.|
W
wusongqing 已提交
2467
  | callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | No  | Callback used to return the information.                                      |
G
ge-yafang 已提交
2468

W
wusongqing 已提交
2469
**Example**
W
wusongqing 已提交
2470

G
ge-yafang 已提交
2471
  ```ts
W
wusongqing 已提交
2472 2473 2474 2475 2476 2477 2478 2479
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
          var type = 'windowStageEvent';
          windowStage.off(type);
      }
  }
  ```