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

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

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

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

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

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

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

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

W
wusongqing 已提交
21
| Name             | Default Value | Description              |
W
wusongqing 已提交
22 23 24
| ----------------- | ------ | ------------------ |
| TYPE_APP          | 0      | Application subwindow.  |
| TYPE_SYSTEM_ALERT | 1      | System alert window.|
W
wusongqing 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37
| TYPE_INPUT_METHOD<sup>9+</sup> | 2      | Input method window.|
| TYPE_STATUS_BAR<sup>9+</sup>   | 3      | Status bar.|
| TYPE_PANEL<sup>9+</sup>        | 4      | Notification panel.|
| TYPE_KEYGUARD<sup>9+</sup>     | 5      | Lock screen.|
| TYPE_VOLUME_OVERLAY<sup>9+</sup> | 6      | Volume bar.|
| TYPE_NAVIGATION_BAR<sup>9+</sup> | 7      | Navigation bar.|
| TYPE_FLOAT<sup>9+</sup> | 8      | Floating window.|
| TYPE_WALLPAPER<sup>9+</sup> | 9      | Wallpaper.|
| TYPE_DESKTOP<sup>9+</sup> | 10      | Home screen.|
| TYPE_LAUNCHER_RECENT<sup>9+</sup> | 11      | Recent tasks screen.|
| TYPE_LAUNCHER_DOCK<sup>9+</sup> | 12      | Dock bar on the home screen.|
| TYPE_VOICE_INTERACTION<sup>9+</sup> | 13      | Voice assistant.|
| TYPE_POINTER<sup>9+</sup> | 14      | Mouse.|
Z
zengyawen 已提交
38

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

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

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

W
wusongqing 已提交
45
| Name       | Default Value | Description              |
W
wusongqing 已提交
46 47 48
| ----------- | ------ | ------------------ |
| TYPE_SYSTEM | 0      | Default area of the system.|
| TYPE_CUTOUT | 1      | Notch.  |
W
wusongqing 已提交
49

W
wusongqing 已提交
50
## WindowMode<sup>7+</sup>
W
wusongqing 已提交
51 52 53 54 55 56 57

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 已提交
58
| Name      | Default Value | Description                         |
W
wusongqing 已提交
59 60 61 62 63 64
| ---------- | ------ | ----------------------------- |
| 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 已提交
65

W
wusongqing 已提交
66
## SystemBarProperties
Z
zengyawen 已提交
67 68 69

Describes the properties of the status bar and navigation bar.

W
wusongqing 已提交
70 71
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
72 73
| Name                                  | Type| Readable| Writable| Description                                                        |
| -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
74
| statusBarColor                         | string   | Yes  | Yes  | Background color of the status bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **\#00FF00** or **\#FF00FF00**.|
W
wusongqing 已提交
75 76
| isStatusBarLightIcon<sup>7+</sup>      | boolean  | No  | Yes  | Whether any icon on the status bar is highlighted.                                  |
| statusBarContentColor<sup>8+</sup>     | string   | No  | Yes  | Color of the text on the status bar.                                            |
W
wusongqing 已提交
77
| navigationBarColor                     | string   | Yes  | Yes  | Background color of the navigation bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **\#00FF00** or **\#FF00FF00**.|
W
wusongqing 已提交
78 79
| 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 已提交
80

W
wusongqing 已提交
81
## SystemBarRegionTint<sup>8+</sup>
W
wusongqing 已提交
82 83 84 85 86 87 88

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 已提交
89 90
| Name           | Type                 | Readable| Writable| Description                                                        |
| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
91
| 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 已提交
92 93
| isEnable        | boolean                   | Yes  | Yes  | Whether the system bar is displayed.                                        |
| region          | [Rect](#rect)             | Yes  | Yes  | Current position and size of the system bar.                                    |
W
wusongqing 已提交
94
| backgroundColor | string                    | Yes  | Yes  | Background color of the system bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **\#00FF00** or **\#FF00FF00**.|
W
wusongqing 已提交
95
| contentColor    | string                    | Yes  | Yes  | Color of the text on the system bar.                                            |
W
wusongqing 已提交
96

W
wusongqing 已提交
97
## SystemBarTintState<sup>8+</sup>
W
wusongqing 已提交
98 99 100 101 102 103 104

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

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

W
wusongqing 已提交
112
Describes the rectangular area of the window.
Z
zengyawen 已提交
113

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

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

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

Describes the area where the window cannot be displayed.

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

W
wusongqing 已提交
129 130 131 132 133 134
| 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 已提交
135

W
wusongqing 已提交
136
## Size<sup>7+</sup>
Z
zengyawen 已提交
137 138 139

Describes the window size.

W
wusongqing 已提交
140 141
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
142 143 144 145
| Name  | Type| Readable| Writable| Description      |
| ------ | -------- | ---- | ---- | ---------- |
| width  | number   | Yes  | Yes  | Window width.|
| height | number   | Yes  | Yes  | Window height.|
W
wusongqing 已提交
146

W
wusongqing 已提交
147
## WindowProperties
Z
zengyawen 已提交
148 149 150

Describes the window properties.

W
wusongqing 已提交
151
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
152

W
wusongqing 已提交
153 154 155 156 157 158 159 160 161
| Name                           | Type                 | Readable| Writable| Description                                        |
| ------------------------------- | ------------------------- | ---- | ---- | -------------------------------------------- |
| windowRect<sup>7+</sup>         | [Rect](#rect)             | Yes  | Yes  | Window size.                                  |
| type<sup>7+</sup>               | [WindowType](#windowtype) | Yes  | Yes  | Window type.                                  |
| isFullScreen                    | boolean                   | Yes  | Yes  | Whether the window is displayed in full screen mode. The default value is **false**.                     |
| isLayoutFullScreen<sup>7+</sup> | boolean                   | Yes  | Yes  | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is **false**.             |
| focusable<sup>7+</sup>          | boolean                   | Yes  | No  | Whether the window can gain focus. The default value is **true**.                |
| touchable<sup>7+</sup>          | boolean                   | Yes  | No  | Whether the window is touchable. The default value is **true**.                |
| brightness                      | number                    | Yes  | Yes  | Screen brightness. The value ranges from 0 to 1. The value **1** indicates the maximum brightness. |
W
wusongqing 已提交
162
| dimBehindValue<sup>(deprecated)</sup>     | number                    | Yes  | Yes  | Dimness of the window that is not on top. The value ranges from 0 to 1. The value **1** indicates the maximum dimness.<br>This attribute is supported since API version 7 and deprecated since API version 9.<br> |
W
wusongqing 已提交
163 164 165 166
| isKeepScreenOn                  | boolean                   | Yes  | Yes  | Whether the screen is always on. The default value is **false**.                 |
| isPrivacyMode<sup>7+</sup>      | boolean                   | Yes  | Yes  | Whether the window is in privacy mode. The default value is **false**.                     |
| isRoundCorner<sup>7+</sup>      | boolean                   | Yes  | Yes  | Whether the window has rounded corners. The default value is **false**.               |
| isTransparent<sup>7+</sup>      | boolean                   | Yes  | Yes  | Whether the window is transparent. The default value is **false**.                 |
W
wusongqing 已提交
167

W
wusongqing 已提交
168
## ColorSpace<sup>8+</sup>
W
wusongqing 已提交
169 170 171 172 173

Describes the color gamut mode.

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

W
wusongqing 已提交
174
| Name      | Default Value | Description          |
W
wusongqing 已提交
175 176 177
| ---------- | ------ | -------------- |
| DEFAULT    | 0      | Default color gamut mode.|
| WIDE_GAMUT | 1      | Wide color gamut mode.  |
W
wusongqing 已提交
178

W
wusongqing 已提交
179
## window.create<sup>7+</sup>
W
wusongqing 已提交
180 181 182 183 184

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

W
wusongqing 已提交
187 188
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
189
**Parameters**
W
wusongqing 已提交
190

W
wusongqing 已提交
191 192 193 194 195
| 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 已提交
196

W
wusongqing 已提交
197
**Example**
W
wusongqing 已提交
198

G
ge-yafang 已提交
199
  ```js
W
wusongqing 已提交
200 201 202 203 204 205 206 207 208 209 210 211
   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 已提交
212
## window.create<sup>7+</sup>
W
wusongqing 已提交
213 214 215 216 217

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

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

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

W
wusongqing 已提交
220 221
**System capability**: SystemCapability.WindowManager.WindowManager.Core

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

W
wusongqing 已提交
224 225 226 227
| Name| Type                     | Mandatory| Description      |
| ------ | ------------------------- | ---- | ---------- |
| id     | string                    | Yes  | Window ID.  |
| type   | [WindowType](#windowtype) | Yes  | Window type.|
W
wusongqing 已提交
228

W
wusongqing 已提交
229
**Return value**
W
wusongqing 已提交
230

W
wusongqing 已提交
231 232 233
| Type                            | Description                                             |
| -------------------------------- | ------------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
W
wusongqing 已提交
234

W
wusongqing 已提交
235
**Example**
W
wusongqing 已提交
236

G
ge-yafang 已提交
237
  ```js
W
wusongqing 已提交
238 239 240 241 242 243 244
   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 已提交
245
   });
W
wusongqing 已提交
246
  ```
Z
zengyawen 已提交
247

W
wusongqing 已提交
248 249 250 251
## window.create<sup>8+</sup>

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

W
wusongqing 已提交
252
Creates a subwindow (in API version 8) or a system window (from API version 9). This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
253 254 255

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

W
wusongqing 已提交
256
**Parameters**
W
wusongqing 已提交
257

W
wusongqing 已提交
258 259
| Name  | Type                                  | Mandatory| Description                                                        |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
260
| ctx      | Context                                | Yes  | Current application context.<br>For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).<br>For the definition of **Context** of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md).|
W
wusongqing 已提交
261 262 263
| 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 已提交
264

W
wusongqing 已提交
265
**Example**
W
wusongqing 已提交
266

G
ge-yafang 已提交
267
  ```js
W
wusongqing 已提交
268 269 270 271 272 273
   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 已提交
274
      windowClass = data;
W
wusongqing 已提交
275 276 277 278
      console.info('Window created. Data: ' + JSON.stringify(data))
      windowClass.resetSize(500, 1000);
  });
  ```
Z
zengyawen 已提交
279

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

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

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

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

W
wusongqing 已提交
288
**Parameters**
E
ester.zhou 已提交
289

W
wusongqing 已提交
290 291
| Name| Type                     | Mandatory| Description                                                        |
| ------ | ------------------------- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
292
| ctx    | Context                   | Yes  | Current application context.<br>For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).<br>For the definition of **Context** of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md).|
W
wusongqing 已提交
293 294
| id     | string                    | Yes  | Window ID.                                                    |
| type   | [WindowType](#windowtype) | Yes  | Window type.                                                  |
W
wusongqing 已提交
295

W
wusongqing 已提交
296
**Return value**
E
ester.zhou 已提交
297

W
wusongqing 已提交
298 299 300
| Type                            | Description                                           |
| -------------------------------- | ----------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the window created.|
E
ester.zhou 已提交
301

W
wusongqing 已提交
302
**Example**
W
wusongqing 已提交
303

G
ge-yafang 已提交
304
  ```js
W
wusongqing 已提交
305 306 307 308 309 310 311 312 313 314
   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 已提交
315
## window.find<sup>7+</sup>
W
wusongqing 已提交
316 317 318 319 320 321 322

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 已提交
323
**Parameters**
W
wusongqing 已提交
324

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

W
wusongqing 已提交
330
**Example**
W
wusongqing 已提交
331

G
ge-yafang 已提交
332
  ```js
W
wusongqing 已提交
333 334 335 336 337 338 339 340
   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 已提交
341 342 343
  });
  ```

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

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

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

W
wusongqing 已提交
350
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
351

W
wusongqing 已提交
352
**Parameters**
W
wusongqing 已提交
353

W
wusongqing 已提交
354 355 356
| Name| Type  | Mandatory| Description    |
| ------ | ------ | ---- | -------- |
| id     | string | Yes  | Window ID.|
W
wusongqing 已提交
357

W
wusongqing 已提交
358
**Return value**
W
wusongqing 已提交
359

W
wusongqing 已提交
360 361 362
| Type                            | Description                                           |
| -------------------------------- | ----------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the window found.|
W
wusongqing 已提交
363

W
wusongqing 已提交
364
**Example**
W
wusongqing 已提交
365

G
ge-yafang 已提交
366
  ```js
W
wusongqing 已提交
367 368 369 370 371 372 373 374 375
   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 已提交
376

W
wusongqing 已提交
377
## window.getTopWindow
W
wusongqing 已提交
378 379 380 381 382

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

W
wusongqing 已提交
385
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Z
zengyawen 已提交
386

W
wusongqing 已提交
387
**Parameters**
Z
zengyawen 已提交
388

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

W
wusongqing 已提交
393
**Example**
Z
zengyawen 已提交
394

G
ge-yafang 已提交
395
  ```js
W
wusongqing 已提交
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
  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 已提交
413
This API is deprecated since API version 8. You are advised to use [window.getTopWindow<sup>8+</sup>](#windowgettopwindow8) instead.
W
wusongqing 已提交
414

W
wusongqing 已提交
415 416
**System capability**: SystemCapability.WindowManager.WindowManager.Core

W
wusongqing 已提交
417
**Return value**
W
wusongqing 已提交
418

W
wusongqing 已提交
419 420 421
| Type                            | Description                                                     |
| -------------------------------- | --------------------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
W
wusongqing 已提交
422

W
wusongqing 已提交
423
**Example**
W
wusongqing 已提交
424

G
ge-yafang 已提交
425
  ```js
W
wusongqing 已提交
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
   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 已提交
444
**Parameters**
W
wusongqing 已提交
445

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

W
wusongqing 已提交
451
**Example**
W
wusongqing 已提交
452

G
ge-yafang 已提交
453
  ```js
W
wusongqing 已提交
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
  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 已提交
473
**Parameters**
W
wusongqing 已提交
474

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

W
wusongqing 已提交
479
**Return value**
W
wusongqing 已提交
480

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

W
wusongqing 已提交
485
**Example**
W
wusongqing 已提交
486

G
ge-yafang 已提交
487
  ```js
W
wusongqing 已提交
488 489 490 491 492 493 494 495 496 497 498 499 500 501
   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 已提交
502
Enables listening for properties changes of the status bar and navigation bar.
W
wusongqing 已提交
503 504 505 506 507

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

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

W
wusongqing 已提交
508
**Parameters**
W
wusongqing 已提交
509

W
wusongqing 已提交
510 511 512 513
| Name  | Type                                                     | Mandatory| Description                                                        |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | string                                                    | Yes  | Type of event to listen for. The value is fixed at **systemBarTintChange**, indicating the property change event of the status bar and navigation bar.|
| callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | Yes  | Callback used to return the information.                                      |
W
wusongqing 已提交
514

W
wusongqing 已提交
515
**Example**
W
wusongqing 已提交
516

G
ge-yafang 已提交
517
  ```js
W
wusongqing 已提交
518
  var type = 'systemBarTintChange';
E
ester.zhou 已提交
519
  windowClass.on(type, (data) => {
W
wusongqing 已提交
520
      console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
E
ester.zhou 已提交
521 522
  });
  ```
Z
zengyawen 已提交
523

W
wusongqing 已提交
524 525 526
## off('systemBarTintChange')<sup>8+</sup>

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

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

W
wusongqing 已提交
530 531 532
This is a system API and cannot be called by third-party applications.

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

W
wusongqing 已提交
534
**Parameters**
Z
zengyawen 已提交
535

W
wusongqing 已提交
536 537 538 539
| Name  | Type                                                     | Mandatory| Description                                                        |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | string                                                    | Yes  | Type of event to listen for. The value is fixed at **systemBarTintChange**, indicating the property change event of the status bar and navigation bar.|
| callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | No  | Callback used to return the information.                                      |
Z
zengyawen 已提交
540

W
wusongqing 已提交
541
**Example**
Z
zengyawen 已提交
542

G
ge-yafang 已提交
543
  ```js
W
wusongqing 已提交
544
  var type = 'systemBarTintChange';
E
ester.zhou 已提交
545 546
  windowClass.off(type);
  ```
W
wusongqing 已提交
547 548 549

## Window

W
wusongqing 已提交
550
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 已提交
551 552 553 554 555 556 557 558 559 560 561

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

W
wusongqing 已提交
564 565 566
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.|
W
wusongqing 已提交
567

W
wusongqing 已提交
568
**Example**
W
wusongqing 已提交
569

G
ge-yafang 已提交
570
  ```js
W
wusongqing 已提交
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
  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 已提交
590
**Return value**
W
wusongqing 已提交
591

W
wusongqing 已提交
592 593 594
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
595

W
wusongqing 已提交
596
**Example**
W
wusongqing 已提交
597

G
ge-yafang 已提交
598
  ```js
W
wusongqing 已提交
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614
   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 已提交
615
**Parameters**
W
wusongqing 已提交
616

W
wusongqing 已提交
617 618 619
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.|
W
wusongqing 已提交
620

W
wusongqing 已提交
621
**Example**
W
wusongqing 已提交
622

G
ge-yafang 已提交
623
  ```js
W
wusongqing 已提交
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640
  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 已提交
641
**Return value**
W
wusongqing 已提交
642

W
wusongqing 已提交
643 644 645
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
646

W
wusongqing 已提交
647
**Example**
W
wusongqing 已提交
648

G
ge-yafang 已提交
649
  ```js
W
wusongqing 已提交
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665
   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 已提交
666
**Parameters**
W
wusongqing 已提交
667

W
wusongqing 已提交
668 669 670
| Name  | Type                     | Mandatory| Description      |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.|
W
wusongqing 已提交
671

W
wusongqing 已提交
672
**Example**
W
wusongqing 已提交
673

G
ge-yafang 已提交
674
  ```js
W
wusongqing 已提交
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691
  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 已提交
692
**Return value**
W
wusongqing 已提交
693

W
wusongqing 已提交
694 695 696
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
697

W
wusongqing 已提交
698
**Example**
W
wusongqing 已提交
699

G
ge-yafang 已提交
700
  ```js
W
wusongqing 已提交
701 702 703 704 705 706 707 708 709 710 711 712
   let promise = windowClass.destroy();
   promise.then((data)=> {
      console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data))
   }).catch((err)=>{
      console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
   })
  ```

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

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

W
wusongqing 已提交
713
Moves this window. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
714 715 716

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

W
wusongqing 已提交
717
**Parameters**
W
wusongqing 已提交
718

W
wusongqing 已提交
719 720 721 722 723
| Name  | Type                     | Mandatory| Description                                             |
| -------- | ------------------------- | ---- | ------------------------------------------------- |
| x        | number                    | Yes  | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.|
| y        | number                    | Yes  | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                                       |
W
wusongqing 已提交
724

W
wusongqing 已提交
725
**Example**
W
wusongqing 已提交
726

G
ge-yafang 已提交
727
  ```js
W
wusongqing 已提交
728 729 730 731 732 733 734 735 736 737 738 739 740 741
  windowClass.moveTo(300, 300, (err, data)=>{
      if (err.code) {
          console.error('Failed to move the window. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Window moved. Data: ' + JSON.stringify(data))
  
  });
  ```

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

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

W
wusongqing 已提交
742
Moves this window. This API uses a promise to return the result.
W
wusongqing 已提交
743 744 745

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

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

W
wusongqing 已提交
748 749 750 751
| Name| Type  | Mandatory| Description                                             |
| ------ | ------ | ---- | ------------------------------------------------- |
| x      | number | Yes  | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.|
| y      | number | Yes  | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.|
W
wusongqing 已提交
752

W
wusongqing 已提交
753
**Return value**
W
wusongqing 已提交
754

W
wusongqing 已提交
755 756 757
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
758

W
wusongqing 已提交
759
**Example**
W
wusongqing 已提交
760

G
ge-yafang 已提交
761
  ```js
W
wusongqing 已提交
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777
   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 已提交
778
**Parameters**
W
wusongqing 已提交
779

W
wusongqing 已提交
780 781 782 783 784
| Name  | Type                     | Mandatory| Description                      |
| -------- | ------------------------- | ---- | -------------------------- |
| width    | number                    | Yes  | New width of the window, in px.|
| height   | number                    | Yes  | New height of the window, in px.|
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                |
W
wusongqing 已提交
785

W
wusongqing 已提交
786
**Example**
W
wusongqing 已提交
787

G
ge-yafang 已提交
788
  ```js
W
wusongqing 已提交
789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805
  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 已提交
806
**Parameters**
W
wusongqing 已提交
807

W
wusongqing 已提交
808 809 810 811
| Name| Type  | Mandatory| Description                      |
| ------ | ------ | ---- | -------------------------- |
| width  | number | Yes  | New width of the window, in px.|
| height | number | Yes  | New height of the window, in px.|
W
wusongqing 已提交
812

W
wusongqing 已提交
813
**Return value**
W
wusongqing 已提交
814

W
wusongqing 已提交
815 816 817
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
818

W
wusongqing 已提交
819
**Example**
W
wusongqing 已提交
820

G
ge-yafang 已提交
821
  ```js
W
wusongqing 已提交
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839
   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 已提交
840
**Parameters**
W
wusongqing 已提交
841

W
wusongqing 已提交
842 843 844 845
| 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 已提交
846

W
wusongqing 已提交
847
**Example**
W
wusongqing 已提交
848

G
ge-yafang 已提交
849
  ```js
W
wusongqing 已提交
850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869
  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 已提交
870
**Parameters**
W
wusongqing 已提交
871

W
wusongqing 已提交
872 873 874
| Name| Type                     | Mandatory| Description      |
| ------ | ------------------------- | ---- | ---------- |
| type   | [WindowType](#windowtype) | Yes  | Window type.|
W
wusongqing 已提交
875

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

W
wusongqing 已提交
878 879 880
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
881

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

G
ge-yafang 已提交
884
  ```js
W
wusongqing 已提交
885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901
   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 已提交
902
**Parameters**
W
wusongqing 已提交
903

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

W
wusongqing 已提交
908
**Example**
W
wusongqing 已提交
909

G
ge-yafang 已提交
910
  ```js
W
wusongqing 已提交
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927
  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 已提交
928
**Return value**
W
wusongqing 已提交
929

W
wusongqing 已提交
930 931 932
| Type                                                | Description                                 |
| ---------------------------------------------------- | ------------------------------------- |
| Promise&lt;[WindowProperties](#windowproperties)&gt; | Promise used to return the window properties.|
W
wusongqing 已提交
933

W
wusongqing 已提交
934
**Example**
W
wusongqing 已提交
935

W
wusongqing 已提交
936
  ```js
W
wusongqing 已提交
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952
   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 已提交
953
**Parameters**
W
wusongqing 已提交
954

W
wusongqing 已提交
955 956 957 958
| 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 已提交
959

W
wusongqing 已提交
960
**Example**
W
wusongqing 已提交
961

G
ge-yafang 已提交
962
  ```js
W
wusongqing 已提交
963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980
  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 已提交
981
**Parameters**
W
wusongqing 已提交
982

W
wusongqing 已提交
983 984 985
| 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 已提交
986

W
wusongqing 已提交
987
**Return value**
W
wusongqing 已提交
988

W
wusongqing 已提交
989 990 991
| Type                                  | Description                                         |
| -------------------------------------- | --------------------------------------------- |
| Promise&lt;[AvoidArea](#avoidarea)&gt; | Promise used to return the area.|
W
wusongqing 已提交
992

W
wusongqing 已提交
993
**Example**
W
wusongqing 已提交
994

G
ge-yafang 已提交
995
  ```js
W
wusongqing 已提交
996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011
   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 已提交
1012
**Parameters**
W
wusongqing 已提交
1013

W
wusongqing 已提交
1014 1015 1016 1017
| 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 已提交
1018

W
wusongqing 已提交
1019
**Example**
W
wusongqing 已提交
1020

G
ge-yafang 已提交
1021
  ```js
W
wusongqing 已提交
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039
  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 已提交
1040
**Parameters**
W
wusongqing 已提交
1041

W
wusongqing 已提交
1042 1043 1044
| 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 已提交
1045

W
wusongqing 已提交
1046
**Return value**
W
wusongqing 已提交
1047

W
wusongqing 已提交
1048 1049 1050
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1051

W
wusongqing 已提交
1052
**Example**
W
wusongqing 已提交
1053

G
ge-yafang 已提交
1054
  ```js
W
wusongqing 已提交
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067
  var isFullScreen = true;
  let promise = windowClass.setFullScreen(isFullScreen);
  promise.then((data)=> {
      console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
  });
  ```

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

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

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

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

W
wusongqing 已提交
1072
**Parameters**
W
wusongqing 已提交
1073

W
wusongqing 已提交
1074 1075 1076 1077
| Name            | Type                     | Mandatory| Description                                                        |
| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ |
| isLayoutFullScreen | boolean                   | Yes  | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.|
| callback           | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                                                  |
W
wusongqing 已提交
1078

W
wusongqing 已提交
1079
**Example**
W
wusongqing 已提交
1080

G
ge-yafang 已提交
1081
  ```js
W
wusongqing 已提交
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095
  var isLayoutFullScreen= true;
  windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => {
      if (err.code) {
          console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data))
  });
  ```

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

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

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

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

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

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

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

W
wusongqing 已提交
1108 1109 1110
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1111

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

G
ge-yafang 已提交
1114
  ```js
W
wusongqing 已提交
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131
  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 已提交
1132
**Parameters**
W
wusongqing 已提交
1133

W
wusongqing 已提交
1134 1135 1136 1137
| 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 已提交
1138

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

G
ge-yafang 已提交
1141
  ```js
W
wusongqing 已提交
1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159
  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 已提交
1160
**Parameters**
W
wusongqing 已提交
1161

W
wusongqing 已提交
1162 1163 1164
| 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 已提交
1165

W
wusongqing 已提交
1166
**Return value**
W
wusongqing 已提交
1167

W
wusongqing 已提交
1168 1169 1170
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1171

W
wusongqing 已提交
1172
**Example**
W
wusongqing 已提交
1173

G
ge-yafang 已提交
1174
  ```js
W
wusongqing 已提交
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191
  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 已提交
1192
**Parameters**
W
wusongqing 已提交
1193

W
wusongqing 已提交
1194 1195 1196 1197
| 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 已提交
1198

W
wusongqing 已提交
1199
**Example**
W
wusongqing 已提交
1200

G
ge-yafang 已提交
1201
  ```js
W
wusongqing 已提交
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228
  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 已提交
1229
**Parameters**
W
wusongqing 已提交
1230

W
wusongqing 已提交
1231 1232 1233
| Name             | Type                                       | Mandatory| Description                |
| ------------------- | ------------------------------------------- | ---- | -------------------- |
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes  | Properties of the status bar and navigation bar.|
W
wusongqing 已提交
1234

W
wusongqing 已提交
1235
**Return value**
W
wusongqing 已提交
1236

W
wusongqing 已提交
1237 1238 1239
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1240

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

G
ge-yafang 已提交
1243
  ```js
W
wusongqing 已提交
1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269
  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 已提交
1270
**Parameters**
W
wusongqing 已提交
1271

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

W
wusongqing 已提交
1277
**Example**
W
wusongqing 已提交
1278

G
ge-yafang 已提交
1279
  ```js
W
wusongqing 已提交
1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296
  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 已提交
1297
**Parameters**
W
wusongqing 已提交
1298

W
wusongqing 已提交
1299 1300 1301
| Name| Type  | Mandatory| Description                |
| ------ | ------ | ---- | -------------------- |
| path   | string | Yes  | Path of the page from which the content will be loaded.|
G
ge-yafang 已提交
1302

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

W
wusongqing 已提交
1305 1306 1307
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1308

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

G
ge-yafang 已提交
1311
  ```js
W
wusongqing 已提交
1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327
  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 已提交
1328
**Parameters**
W
wusongqing 已提交
1329

W
wusongqing 已提交
1330 1331 1332
| Name  | Type                        | Mandatory| Description                            |
| -------- | ---------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return whether the window is displayed.|
W
wusongqing 已提交
1333

W
wusongqing 已提交
1334
**Example**
W
wusongqing 已提交
1335

G
ge-yafang 已提交
1336
  ```js
W
wusongqing 已提交
1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353
  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 已提交
1354
**Return value**
W
wusongqing 已提交
1355

W
wusongqing 已提交
1356 1357 1358
| Type                  | Description                                                 |
| ---------------------- | ----------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return whether the window is displayed.|
W
wusongqing 已提交
1359

W
wusongqing 已提交
1360
**Example**
W
wusongqing 已提交
1361

G
ge-yafang 已提交
1362
  ```js
W
wusongqing 已提交
1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378
  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 已提交
1379
**Parameters**
W
wusongqing 已提交
1380

W
wusongqing 已提交
1381 1382 1383 1384
| 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 已提交
1385

W
wusongqing 已提交
1386
**Example**
W
wusongqing 已提交
1387

G
ge-yafang 已提交
1388
  ```js
W
wusongqing 已提交
1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402
  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 已提交
1403
**Parameters**
W
wusongqing 已提交
1404

W
wusongqing 已提交
1405 1406 1407 1408
| 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 已提交
1409

W
wusongqing 已提交
1410
**Example**
W
wusongqing 已提交
1411

W
wusongqing 已提交
1412
  ```js
W
wusongqing 已提交
1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424
  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 已提交
1425
**Parameters**
W
wusongqing 已提交
1426

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

W
wusongqing 已提交
1432
**Example**
W
wusongqing 已提交
1433

G
ge-yafang 已提交
1434
  ```js
W
wusongqing 已提交
1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448
  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 已提交
1449
**Parameters**
W
wusongqing 已提交
1450

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

W
wusongqing 已提交
1456
**Example**
W
wusongqing 已提交
1457

W
wusongqing 已提交
1458
  ```js
W
wusongqing 已提交
1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470
  var type = 'systemAvoidAreaChange';
  windowClass.off(type);
  ```

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

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

Enables listening for keyboard height changes.

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

W
wusongqing 已提交
1471
**Parameters**
W
wusongqing 已提交
1472

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

W
wusongqing 已提交
1478
**Example**
W
wusongqing 已提交
1479

G
ge-yafang 已提交
1480
  ```js
W
wusongqing 已提交
1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494
  var type = 'keyboardHeightChange';
  windowClass.on(type, (data) => {
      console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
  });
  ```

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

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

Disables listening for keyboard height changes.

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

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

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

W
wusongqing 已提交
1502
**Example**
W
wusongqing 已提交
1503

W
wusongqing 已提交
1504
  ```js
W
wusongqing 已提交
1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516
  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 已提交
1517
**Parameters**
W
wusongqing 已提交
1518

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

W
wusongqing 已提交
1523
**Example**
W
wusongqing 已提交
1524

G
ge-yafang 已提交
1525
  ```js
W
wusongqing 已提交
1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542
  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 已提交
1543
**Return value**
W
wusongqing 已提交
1544

W
wusongqing 已提交
1545 1546 1547
| Type                  | Description                                                        |
| ---------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return whether the wide color gamut mode is supported.|
W
wusongqing 已提交
1548

W
wusongqing 已提交
1549
**Example**
W
wusongqing 已提交
1550

W
wusongqing 已提交
1551
  ```js
W
wusongqing 已提交
1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567
  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 已提交
1568
**Parameters**
W
wusongqing 已提交
1569

W
wusongqing 已提交
1570 1571 1572 1573
| 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 已提交
1574

W
wusongqing 已提交
1575
**Example**
W
wusongqing 已提交
1576

G
ge-yafang 已提交
1577
  ```js
W
wusongqing 已提交
1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594
  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 已提交
1595
**Parameters**
W
wusongqing 已提交
1596

W
wusongqing 已提交
1597 1598 1599
| Name    | Type                     | Mandatory| Description        |
| ---------- | ------------------------- | ---- | ------------ |
| colorSpace | [ColorSpace](#colorspace) | Yes  | Color gamut mode.|
W
wusongqing 已提交
1600

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

W
wusongqing 已提交
1603 1604 1605
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
1606

W
wusongqing 已提交
1607
**Example**
W
wusongqing 已提交
1608

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

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

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

W
wusongqing 已提交
1632
**Example**
W
wusongqing 已提交
1633

G
ge-yafang 已提交
1634
  ```js
W
wusongqing 已提交
1635 1636
  windowClass.getColorSpace((err, data) => {
      if (err.code) {
W
wusongqing 已提交
1637
          console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err));
W
wusongqing 已提交
1638 1639
          return;
      }
W
wusongqing 已提交
1640
      console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data))
W
wusongqing 已提交
1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651
  })
  ```

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

W
wusongqing 已提交
1654 1655 1656
| Type                                    | Description                                     |
| ---------------------------------------- | ----------------------------------------- |
| Promise&lt;[ColorSpace](#colorspace)&gt; | Promise used to return the color gamut mode obtained.|
W
wusongqing 已提交
1657

W
wusongqing 已提交
1658
**Example**
W
wusongqing 已提交
1659

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

### setBackgroundColor

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

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

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

W
wusongqing 已提交
1677
**Parameters**
W
wusongqing 已提交
1678

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

W
wusongqing 已提交
1684
**Example**
W
wusongqing 已提交
1685

G
ge-yafang 已提交
1686
  ```js
W
wusongqing 已提交
1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704
  var color = '#00ff33';
  windowClass.setBackgroundColor(color, (err, data) => {
      if (err.code) {
          console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data));
  });
  ```

### setBackgroundColor

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

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

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

W
wusongqing 已提交
1705
**Parameters**
W
wusongqing 已提交
1706

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

W
wusongqing 已提交
1711
**Return value**
W
wusongqing 已提交
1712

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

W
wusongqing 已提交
1717
**Example**
W
wusongqing 已提交
1718

G
ge-yafang 已提交
1719
  ```js
W
wusongqing 已提交
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.

**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
  var brightness = 1;
  windowClass.setBrightness(brightness, (err, data) => {
      if (err.code) {
          console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data));
  });
  ```

### setBrightness

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

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

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

W
wusongqing 已提交
1765
**Parameters**
W
wusongqing 已提交
1766

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

W
wusongqing 已提交
1771
**Return value**
W
wusongqing 已提交
1772

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

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

G
ge-yafang 已提交
1779
  ```js
W
wusongqing 已提交
1780 1781 1782 1783 1784 1785 1786 1787 1788
  var brightness = 1;
  let promise = windowClass.setBrightness(brightness);
  promise.then((data)=> {
      console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
  });
  ```

W
wusongqing 已提交
1789 1790 1791 1792 1793 1794
### setDimBehind<sup>(deprecated)</sup>

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

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

W
wusongqing 已提交
1795
> **NOTE**
W
wusongqing 已提交
1796
> 
W
wusongqing 已提交
1797
> This API is supported since API version 7 and deprecated since API version 9.
W
wusongqing 已提交
1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825

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

**Parameters**

| Name        | Type                     | Mandatory| Description                                              |
| -------------- | ------------------------- | ---- | -------------------------------------------------- |
| dimBehindValue | number                    | Yes  | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest.|
| callback       | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.                                        |

**Example**

  ```js
  windowClass.setDimBehind(0.5, (err, data) => {
      if (err.code) {
          console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data));
  });
  ```

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

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

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

W
wusongqing 已提交
1826
> **NOTE**
W
wusongqing 已提交
1827
> 
W
wusongqing 已提交
1828
> This API is supported since API version 7 and deprecated since API version 9.
W
wusongqing 已提交
1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854

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

**Parameters**

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

**Return value**

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

**Example**

  ```js
  let promise = windowClass.setDimBehind(0.5);
  promise.then((data)=> {
      console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
  });
  ```

W
wusongqing 已提交
1855 1856 1857 1858 1859 1860 1861 1862
### setFocusable<sup>7+</sup>

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

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

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

W
wusongqing 已提交
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
  var isFocusable= true;
  windowClass.setFocusable(isFocusable, (err, data) => {
      if (err.code) {
          console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
  });
  ```

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

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

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

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

W
wusongqing 已提交
1891
**Parameters**
W
wusongqing 已提交
1892

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

W
wusongqing 已提交
1897
**Return value**
W
wusongqing 已提交
1898

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

W
wusongqing 已提交
1903
**Example**
W
wusongqing 已提交
1904

G
ge-yafang 已提交
1905
  ```js
W
wusongqing 已提交
1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922
  var isFocusable= true;
  let promise = windowClass.setFocusable(isFocusable);
  promise.then((data)=> {
      console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
  });
  ```

### setKeepScreenOn

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

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

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

W
wusongqing 已提交
1923
**Parameters**
W
wusongqing 已提交
1924

W
wusongqing 已提交
1925 1926 1927 1928
| 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 已提交
1929

W
wusongqing 已提交
1930
**Example**
W
wusongqing 已提交
1931

G
ge-yafang 已提交
1932
  ```js
W
wusongqing 已提交
1933 1934 1935 1936 1937 1938 1939 1940 1941 1942
  var isKeepScreenOn = true;
  windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => {
      if (err.code) {
          console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
  });
  ```

W
wusongqing 已提交
1943 1944 1945 1946 1947 1948
### setOutsideTouchable<sup>(deprecated)</sup>

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

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

W
wusongqing 已提交
1949
> **NOTE**
W
wusongqing 已提交
1950
> 
W
wusongqing 已提交
1951
> This API is supported since API version 7 and deprecated since API version 9.
W
wusongqing 已提交
1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979

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

**Parameters**

| Name   | Type                     | Mandatory| Description            |
| --------- | ------------------------- | ---- | ---------------- |
| touchable | boolean                   | Yes  | Whether the area outside the subwindow is touchable. The value **true** means that such an area is touchable, and **false** means the opposite.|
| callback  | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the execution result.      |

**Example**

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

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

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

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

W
wusongqing 已提交
1980
> **NOTE**
W
wusongqing 已提交
1981
> 
W
wusongqing 已提交
1982
> This API is supported since API version 7 and deprecated since API version 9.
W
wusongqing 已提交
1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008

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

**Parameters**

| Name   | Type   | Mandatory| Description            |
| --------- | ------- | ---- | ---------------- |
| touchable | boolean | Yes  | Whether the area outside the subwindow is touchable. The value **true** means that such an area is touchable, and **false** means the opposite.|

**Return value**

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

**Example**

  ```js
  let promise = windowClass.setOutsideTouchable(true);
  promise.then((data)=> {
      console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
  });
  ```

W
wusongqing 已提交
2009 2010 2011 2012 2013 2014 2015 2016
### setKeepScreenOn

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

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

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

W
wusongqing 已提交
2017
**Parameters**
W
wusongqing 已提交
2018

W
wusongqing 已提交
2019 2020 2021
| Name        | Type   | Mandatory| Description                    |
| -------------- | ------- | ---- | ------------------------ |
| isKeepScreenOn | boolean | Yes  | Whether to keep the screen always on.|
W
wusongqing 已提交
2022

W
wusongqing 已提交
2023
**Return value**
W
wusongqing 已提交
2024

W
wusongqing 已提交
2025 2026 2027
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
2028

W
wusongqing 已提交
2029
**Example**
W
wusongqing 已提交
2030

G
ge-yafang 已提交
2031
  ```js
W
wusongqing 已提交
2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048
  var isKeepScreenOn= true;
  let promise = windowClass.setKeepScreenOn(isKeepScreenOn);
  promise.then((data)=> {
      console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
  });
  ```

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

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

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

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

W
wusongqing 已提交
2049
**Parameters**
W
wusongqing 已提交
2050

W
wusongqing 已提交
2051 2052 2053 2054
| 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 已提交
2055

W
wusongqing 已提交
2056
**Example**
W
wusongqing 已提交
2057

G
ge-yafang 已提交
2058
  ```js
W
wusongqing 已提交
2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077
  var isPrivacyMode = true;
  windowClass.setPrivacyMode(isPrivacyMode, (err, data) => {
      if (err.code) {
          console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data));
  
  });
  ```

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

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

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

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

W
wusongqing 已提交
2078
**Parameters**
W
wusongqing 已提交
2079

W
wusongqing 已提交
2080 2081 2082
| Name       | Type   | Mandatory| Description                |
| ------------- | ------- | ---- | -------------------- |
| isPrivacyMode | boolean | Yes  | Whether the window is in privacy mode.|
W
wusongqing 已提交
2083

W
wusongqing 已提交
2084
**Return value**
W
wusongqing 已提交
2085

W
wusongqing 已提交
2086 2087 2088
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
2089

W
wusongqing 已提交
2090
**Example**
W
wusongqing 已提交
2091

G
ge-yafang 已提交
2092
  ```js
W
wusongqing 已提交
2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109
  var isPrivacyMode = true;
  let promise = windowClass.setPrivacyMode(isPrivacyMode);
  promise.then((data)=> {
      console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data))
  }).catch((err)=>{
      console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
  });
  ```

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

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

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

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

W
wusongqing 已提交
2110
**Parameters**
W
wusongqing 已提交
2111

W
wusongqing 已提交
2112 2113 2114 2115
| 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 已提交
2116

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

G
ge-yafang 已提交
2119
  ```js
W
wusongqing 已提交
2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138
  var isTouchable = true;
  windowClass.setTouchable(isTouchable, (err, data) => {
      if (err.code) {
          console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
          return;
      }
      console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data));
  
  });
  ```

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

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

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

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

W
wusongqing 已提交
2139
**Parameters**
W
wusongqing 已提交
2140

W
wusongqing 已提交
2141 2142 2143
| Name     | Type   | Mandatory| Description                |
| ----------- | ------- | ---- | -------------------- |
| isTouchable | boolean | Yes  | Whether the window is touchable.|
W
wusongqing 已提交
2144

W
wusongqing 已提交
2145
**Return value**
W
wusongqing 已提交
2146

W
wusongqing 已提交
2147 2148 2149
| Type               | Description                                           |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
W
wusongqing 已提交
2150

W
wusongqing 已提交
2151
**Example**
W
wusongqing 已提交
2152

G
ge-yafang 已提交
2153
  ```js
W
wusongqing 已提交
2154 2155 2156 2157 2158 2159 2160 2161 2162
  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 已提交
2163
## WindowStageEventType<sup>9+</sup>
W
wusongqing 已提交
2164 2165 2166 2167 2168

Describes the lifecycle of a window stage.

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

W
wusongqing 已提交
2169
| Name      | Default Value | Description    |
W
wusongqing 已提交
2170 2171 2172 2173 2174
| ---------- | ------ | -------- |
| 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 已提交
2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187

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

W
wusongqing 已提交
2190 2191 2192
| Type                            | Description                                                      |
| -------------------------------- | ---------------------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the main window.|
W
wusongqing 已提交
2193

W
wusongqing 已提交
2194
**Example**
W
wusongqing 已提交
2195

G
ge-yafang 已提交
2196
  ```ts
W
wusongqing 已提交
2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219
  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 已提交
2220
**Parameters**
W
wusongqing 已提交
2221

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

W
wusongqing 已提交
2226
**Example**
W
wusongqing 已提交
2227

G
ge-yafang 已提交
2228
  ```ts
W
wusongqing 已提交
2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251
  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 已提交
2252

W
wusongqing 已提交
2253
**Parameters**
W
wusongqing 已提交
2254

W
wusongqing 已提交
2255 2256 2257
| Name| Type  | Mandatory| Description          |
| ------ | ------ | ---- | -------------- |
| name   | String | Yes  | Name of the subwindow.|
G
ge-yafang 已提交
2258

W
wusongqing 已提交
2259
**Return value**
W
wusongqing 已提交
2260

W
wusongqing 已提交
2261 2262 2263
| Type                            | Description                                             |
| -------------------------------- | ------------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
G
ge-yafang 已提交
2264

W
wusongqing 已提交
2265
**Example**
W
wusongqing 已提交
2266

G
ge-yafang 已提交
2267
  ```ts
W
wusongqing 已提交
2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290
  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 已提交
2291
**Parameters**
W
wusongqing 已提交
2292

W
wusongqing 已提交
2293 2294 2295 2296
| 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 已提交
2297

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

G
ge-yafang 已提交
2300
  ```ts
W
wusongqing 已提交
2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324
  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 已提交
2325

W
wusongqing 已提交
2326
**Return value**
W
wusongqing 已提交
2327

W
wusongqing 已提交
2328 2329 2330
| Type                                         | Description                                                        |
| --------------------------------------------- | ------------------------------------------------------------ |
| Promise&lt;Array&lt;[Window](#window)&gt;&gt; | Promise used to return all the subwindows.|
W
wusongqing 已提交
2331

W
wusongqing 已提交
2332
**Example**
W
wusongqing 已提交
2333

G
ge-yafang 已提交
2334
  ```ts
W
wusongqing 已提交
2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356
  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 已提交
2357

W
wusongqing 已提交
2358
**Parameters**
W
wusongqing 已提交
2359

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

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

G
ge-yafang 已提交
2366
  ```ts
W
wusongqing 已提交
2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388
  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 已提交
2389
**System capability**: SystemCapability.WindowManager.WindowManager.Coretype with the value **windowSizeChange**
W
wusongqing 已提交
2390

W
wusongqing 已提交
2391
**Parameters**
W
wusongqing 已提交
2392

W
wusongqing 已提交
2393 2394 2395 2396
| 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 已提交
2397

W
wusongqing 已提交
2398
**Example**
W
wusongqing 已提交
2399

G
ge-yafang 已提交
2400
  ```ts
W
wusongqing 已提交
2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413
  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 已提交
2414

W
wusongqing 已提交
2415 2416 2417 2418 2419 2420 2421
### 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 已提交
2422

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

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

W
wusongqing 已提交
2430
**Example**
W
wusongqing 已提交
2431

G
ge-yafang 已提交
2432
  ```ts
W
wusongqing 已提交
2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450
  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 已提交
2451

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

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

W
wusongqing 已提交
2459
**Example**
W
wusongqing 已提交
2460

G
ge-yafang 已提交
2461
  ```ts
W
wusongqing 已提交
2462 2463 2464 2465 2466 2467 2468 2469
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
          var type = 'windowStageEvent';
          windowStage.off(type);
      }
  }
  ```
W
wusongqing 已提交
2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494

### setShowOnLockScreen('showOnLockScreen')<sup>9+</sup>

setShowOnLockScreen(showOnLockScreen: boolean): void

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

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

**Parameters**

| Name          | Type   | Mandatory| Description                        |
| ---------------- | ------- | ---- | ---------------------------- |
| showOnLockScreen | boolean | Yes  | Whether to display the window on the lock screen.|

**Example**

```ts
class myAbility extends Ability {
    onWindowStageCreate(windowStage) {
        console.log('onWindowStageCreate');
        windowStage.setShowOnLockScreen(true);
    }
}
```