1# @ohos.window (Window) (System API) 2<!--Kit: ArkUI--> 3<!--Subsystem: Window--> 4<!--Owner: @waterwin--> 5<!--Designer: @nyankomiya--> 6<!--Tester: @qinliwen0417--> 7<!--Adviser: @ge-yafang--> 8 9The Window module provides basic window management capabilities, such as creating and destroying the current window, setting properties for the current window, and managing and scheduling windows. 10 11This module provides the following common window-related functions: 12 13- [Window](arkts-apis-window-Window.md): window instance, which is the basic unit managed by the window manager. 14- [WindowStage](#windowstage9): window manager that manages windows. 15 16> **NOTE** 17> 18> - 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. 19> 20> - This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.window (Window)](arkts-apis-window.md). 21 22## Modules to Import 23 24```ts 25import { window } from '@kit.ArkUI'; 26``` 27 28## WindowType<sup>7+</sup> 29 30 31Enumerates the window types. 32 33 34| Name | Value| Description | 35|-------------------------------------| ------ |----------------------------------------------------------------------------------------| 36| TYPE_INPUT_METHOD<sup>(deprecated)</sup> | 2 | Input method window.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>Note: This API is supported since API version 9 and deprecated since API version 13. There is no alternative window type. To control the input method, call [Input method framework APIs](../../inputmethod/inputmethod-application-guide.md).<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 37| TYPE_STATUS_BAR<sup>9+</sup> | 3 | Status bar.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 38| TYPE_PANEL<sup>9+</sup> | 4 | Notification panel.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 39| TYPE_KEYGUARD<sup>9+</sup> | 5 | Lock screen.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 40| TYPE_VOLUME_OVERLAY<sup>9+</sup> | 6 | Volume bar.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 41| TYPE_NAVIGATION_BAR<sup>9+</sup> | 7 | Navigation bar.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 42| TYPE_WALLPAPER<sup>9+</sup> | 9 | Wallpaper.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 43| TYPE_DESKTOP<sup>9+</sup> | 10 | Home screen.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 44| TYPE_LAUNCHER_RECENT<sup>9+</sup> | 11 | Recent tasks screen.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 45| TYPE_LAUNCHER_DOCK<sup>9+</sup> | 12 | Dock bar on the home screen.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 46| TYPE_VOICE_INTERACTION<sup>9+</sup> | 13 | Voice assistant.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 47| TYPE_POINTER<sup>9+</sup> | 14 | Mouse.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 48| TYPE_FLOAT_CAMERA<sup>9+</sup> | 15 | Floating camera window.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 49| TYPE_SCREENSHOT<sup>9+</sup> | 17 | Screenshot window.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 50| TYPE_SYSTEM_TOAST<sup>11+</sup> | 18 | Toast displayed at the top.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 51| TYPE_DIVIDER<sup>11+</sup> | 19 | Divider.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 52| TYPE_GLOBAL_SEARCH<sup>11+</sup> | 20 | Window used for global search.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 53| TYPE_HANDWRITE<sup>12+</sup> | 21 | Stylus window.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.Window.SessionManager| 54| TYPE_WALLET_SWIPE_CARD<sup>15+</sup>| 22 | Wallet swipe card window.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.Window.SessionManager| 55| TYPE_SCREEN_CONTROL<sup>15+</sup> | 23 | Top-level window used for locking touch input, which intercepts screen touch and click events.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.Window.SessionManager| 56| TYPE_FLOAT_NAVIGATION<sup>17+</sup> | 24 | Floating window with a three-button navigation bar.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.Window.SessionManager| 57| TYPE_DYNAMIC<sup>20+</sup> | 25 | System window that allows for adjustable z-levels.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.Window.SessionManager| 58| TYPE_MUTISCREEN_COLLABORATION<sup>20+</sup> | 26 | Window for multi-screen collaboration.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.Window.SessionManager| 59 60## Configuration<sup>9+</sup> 61 62Defines the parameters for creating a child window or system window. 63 64**System API**: This is a system API. 65 66**System capability**: SystemCapability.Window.SessionManager 67 68| Name| Type| Mandatory| Description | 69| ---------- | --------- | ---- | -------------- | 70| zIndex<sup>20+</sup> | number | No| Z-level of the system window. This parameter is valid only when [WindowType](#windowtype7) is set to **TYPE_DYNAMIC**.| 71| defaultDensityEnabled<sup>20+</sup> | boolean| No| Whether the window should use the default density of the system. If the default density is used, the window does not re-layout when the system display size changes.<br>If this parameter is set to **true** for a system window, the window uses the default density and is not affected by [setDefaultDensityEnabled()](arkts-apis-window-WindowStage.md#setdefaultdensityenabled12) or [setCustomDensity()](arkts-apis-window-WindowStage.md#setcustomdensity15) settings for the main window or [setDefaultDensityEnabled()](#setDefaultDensityEnabled20) settings for the current window.<br>If this parameter is set to **false**, the window does not use the default density and is affected by those settings.<br>The default value is **false**.| 72 73## WindowMode<sup>7+</sup> 74 75Enumerates the window modes. 76 77**System API**: This is a system API. 78 79**System capability**: SystemCapability.WindowManager.WindowManager.Core 80 81| Name | Value | Description | 82| ---------- | ---- | ----------------------------- | 83| UNDEFINED | 1 | The window mode is not defined by the application. | 84| FULLSCREEN | 2 | The application is displayed in full screen. | 85| PRIMARY | 3 | The application is displayed in the primary window in split-screen mode. | 86| SECONDARY | 4 | The application is displayed in the secondary window in split-screen mode. | 87| FLOATING | 5 | The application is displayed in a floating window.| 88 89## WindowLayoutMode<sup>9+</sup> 90 91Enumerates the window layout modes. 92 93**System API**: This is a system API. 94 95**System capability**: SystemCapability.WindowManager.WindowManager.Core 96 97| Name | Value | Description | 98| ---------- | ---- | ----------------------------- | 99| WINDOW_LAYOUT_MODE_CASCADE | 0 | Cascade mode. | 100| WINDOW_LAYOUT_MODE_TILE | 1 | Tile mode. | 101 102 103## BlurStyle<sup>9+</sup> 104 105Enumerates the window blur styles. 106 107**System API**: This is a system API. 108 109**System capability**: SystemCapability.WindowManager.WindowManager.Core 110 111| Name | Value | Description | 112| ------- | ---- | -------------------- | 113| OFF | 0 | Blur disabled. | 114| THIN | 1 | Thin blur.| 115| REGULAR | 2 | Regular blur.| 116| THICK | 3 | Thick blur.| 117 118## AnimationType<sup>20+</sup> 119 120Enumerates the types of window animations. 121 122**System API**: This is a system API. 123 124**System capability**: SystemCapability.Window.SessionManager 125 126| Name | Value | Description | 127| ------- | ---- | -------------------------- | 128| FADE_IN | 1 | Fade-in animation, which takes effect during window display.| 129 130## SystemBarRegionTint<sup>8+</sup> 131 132Describes the callback for a single system bar. 133 134**System API**: This is a system API. 135 136**System capability**: SystemCapability.WindowManager.WindowManager.Core 137 138| Name | Type | Read-Only| Optional| Description | 139| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | 140| type | [WindowType](#windowtype7) | No | No | Type of the system bar whose properties are changed. Only the status bar and navigation bar are supported.| 141| isEnable | boolean | No | Yes | Whether the system bar is displayed. **true** if displayed, **false** otherwise. The default value is **true**.| 142| region | [Rect](arkts-apis-window-i.md#rect7) | No | Yes | Current position and size of the system bar. The default value is {0,0,0,0}. | 143| backgroundColor | string | No | Yes | Background color of the system bar. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**. The default value is **0x66000000**.| 144| contentColor | string | No | Yes | Color of the text on the system bar. The default value is **0xE5FFFFFF**. | 145 146## SystemBarTintState<sup>8+</sup> 147 148Describes the callback for the current system bar. 149 150**System API**: This is a system API. 151 152**System capability**: SystemCapability.WindowManager.WindowManager.Core 153 154| Name | Type | Read-Only| Optional| Description | 155| ---------- | --------------------------------------------------- | ---- | ---- | ---------------------------- | 156| displayId | number | No | No | ID of the current physical screen. The value must be an integer. | 157| regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | No | No | All system bar information that has been changed.| 158 159## ScaleOptions<sup>9+</sup> 160 161Describes the scale parameters. 162 163**System API**: This is a system API. 164 165**System capability**: SystemCapability.WindowManager.WindowManager.Core 166 167| Name | Type| Read-Only| Optional| Description | 168| ------ | -------- | ---- | ---- | --------------------------------------------| 169| x | number | No | Yes | Scale factor along the x-axis. The value is a floating-point number, and the default value is **1.0**. | 170| y | number | No | Yes | Scale factor along the y-axis. The value is a floating-point number, and the default value is **1.0**. | 171| pivotX | number | No | Yes | X coordinate of the scale center. The value is a floating-point number in the range [0.0, 1.0], and the default value is **0.5**.| 172| pivotY | number | No | Yes | Y coordinate of the scale center. The value is a floating-point number in the range [0.0, 1.0], and the default value is **0.5**.| 173 174## RotateOptions<sup>9+</sup> 175 176Describes the rotation parameters. 177 178**System API**: This is a system API. 179 180**System capability**: SystemCapability.WindowManager.WindowManager.Core 181 182| Name | Type| Read-Only| Optional| Description | 183| ------ | -------- | ---- |---- |---------------------------------------------| 184| x | number | No | Yes | Rotation angle around the x-axis. The value is a floating-point number, and the default value is **0.0**. | 185| y | number | No | Yes | Rotation angle around the y-axis. The value is a floating-point number, and the default value is **0.0**. | 186| z | number | No | Yes | Rotation angle around the z-axis. The value is a floating-point number, and the default value is **0.0**. | 187| pivotX | number | No | Yes | X coordinate of the rotation center. The value is a floating-point number in the range [0.0, 1.0], and the default value is **0.5**.| 188| pivotY | number | No | Yes | Y coordinate of the rotation center. The value is a floating-point number in the range [0.0, 1.0], and the default value is **0.5**. | 189 190## TranslateOptions<sup>9+</sup> 191 192Describes the translation parameters. 193 194**System API**: This is a system API. 195 196**System capability**: SystemCapability.WindowManager.WindowManager.Core 197 198| Name| Type| Read-Only| Optional| Description | 199| ---- | -------- | ---- | ---- | ---------------------------- | 200| x | number | No | Yes | Distance to translate along the x-axis. The value is a floating-point number, the default value is 0.0, and the unit is px.| 201| y | number | No | Yes | Distance to translate along the y-axis. The value is a floating-point number, the default value is 0.0, and the unit is px.| 202| z | number | No | Yes | Distance to translate along the z-axis. The value is a floating-point number, the default value is 0.0, and the unit is px.| 203 204 205## StartAnimationSystemParams<sup>20+</sup> 206 207Describes the parameters for the startup animation. 208 209The configuration does not take effect for inter-application transitions, where the default animation of the system is used. 210 211The configuration is valid only for phones or tablets not in free windows mode. 212 213The configuration is valid only for full-screen applications. 214 215**System API**: This is a system API. 216 217**System capability**: SystemCapability.Window.SessionManager 218 219| Name | Type | Read-Only| Optional| Description | 220| ---------------- | ----------------------------------------------------------------------- | ---- | ---- | ------------------------------------------------------------ | 221| type | [AnimationType](#animationtype20) | No | No | Type of the window animation.| 222| animationConfig | [WindowAnimationConfig](arkts-apis-window-i.md#windowanimationconfig20) | No | Yes | Configuration for the window animation. The default animation curve is **WindowAnimationCurve.LINEAR**, and the duration is **0**. | 223 224## WindowCreateParams<sup>20+</sup> 225 226Describes the window parameters during application startup. 227 228**System API**: This is a system API. 229 230**System capability**: SystemCapability.Window.SessionManager 231| Name | Type | Read-Only| Optional| Description | 232| ---------------- | ----------------------------------------------------------------------- | ---- | ---- | ------------------------------------------------------------ | 233| systemAnimationParams | [StartAnimationSystemParams](#startanimationsystemparams20) | No | Yes | Parameters for the startup animation. The default value is **undefined**. If this parameter is not set, the default animation of the system is used.| 234 235## window.minimizeAll<sup>9+</sup> 236minimizeAll(id: number, callback: AsyncCallback<void>): void 237 238Minimizes all windows on a display. This API uses an asynchronous callback to return the result. 239 240**System API**: This is a system API. 241 242**System capability**: SystemCapability.WindowManager.WindowManager.Core 243 244**Parameters** 245 246| Name | Type | Mandatory| Description | 247| -------- | ------------------------- | ---- | -------------- | 248| id | number | Yes | ID of the [display](js-apis-display.md#display). The value must be an integer.| 249| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 250 251**Error codes** 252 253For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 254 255| ID| Error Message| 256| ------- | -------------------------------------------- | 257| 202 | Permission verification failed. A non-system application calls a system API. | 258| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 259| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 260| 1300003 | This window manager service works abnormally. | 261 262**Example** 263 264```ts 265import { display } from '@kit.ArkUI'; 266import { BusinessError } from '@kit.BasicServicesKit'; 267 268let displayClass: display.Display | null = null; 269displayClass = display.getDefaultDisplaySync(); 270 271try { 272 if (!displayClass) { 273 console.error('displayClass is null'); 274 } else { 275 window.minimizeAll(displayClass.id, (err: BusinessError) => { 276 const errCode: number = err?.code; 277 if (errCode) { 278 console.error(`Failed to minimize all windows. Cause code: ${err?.code}, message: ${err?.message}`); 279 return; 280 } 281 console.info('Succeeded in minimizing all windows.'); 282 }); 283 } 284} catch (exception) { 285 console.error(`Failed to minimize all windows. Cause code: ${exception.code}, message: ${exception.message}`); 286} 287``` 288 289## window.minimizeAll<sup>9+</sup> 290minimizeAll(id: number): Promise<void> 291 292Minimizes all windows on a display. This API uses a promise to return the result. 293 294**System API**: This is a system API. 295 296**System capability**: SystemCapability.WindowManager.WindowManager.Core 297 298**Parameters** 299 300| Name | Type | Mandatory| Description | 301| -------- | ------------------------- | ---- | -------------- | 302| id | number | Yes | ID of the [display](js-apis-display.md#display). The value must be an integer.| 303 304**Return value** 305 306| Type | Description | 307| ------------------- | ------------------------- | 308| Promise<void> | Promise that returns no value.| 309 310**Error codes** 311 312For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 313 314| ID| Error Message| 315| ------- | -------------------------------------------- | 316| 202 | Permission verification failed. A non-system application calls a system API. | 317| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 318| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 319| 1300003 | This window manager service works abnormally. | 320 321**Example** 322 323```ts 324import { display } from '@kit.ArkUI'; 325import { BusinessError } from '@kit.BasicServicesKit'; 326 327let displayClass: display.Display | null = null; 328displayClass = display.getDefaultDisplaySync(); 329 330try { 331 let promise = window.minimizeAll(displayClass.id); 332 promise.then(() => { 333 console.info('Succeeded in minimizing all windows.'); 334 }).catch((err: BusinessError) => { 335 console.error(`Failed to minimize all windows. Cause code: ${err.code}, message: ${err.message}`); 336 }); 337} catch (exception) { 338 console.error(`Failed to minimize all windows. Cause code: ${exception.code}, message: ${exception.message}`); 339} 340``` 341 342## window.toggleShownStateForAllAppWindows<sup>9+</sup> 343toggleShownStateForAllAppWindows(callback: AsyncCallback<void>): void 344 345Hides or restores the application's windows during quick multi-window switching. This API uses an asynchronous callback to return the result. 346 347**System API**: This is a system API. 348 349**System capability**: SystemCapability.WindowManager.WindowManager.Core 350 351**Parameters** 352 353| Name | Type | Mandatory| Description | 354| -------- | ------------------------- | ---- | -------------- | 355| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 356 357**Error codes** 358 359For details about the error codes, see [Window Error Codes](errorcode-window.md). 360 361| ID| Error Message| 362| ------- | -------------------------------------------- | 363| 202 | Permission verification failed. A non-system application calls a system API. | 364| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 365| 1300003 | This window manager service works abnormally. | 366 367**Example** 368 369```ts 370import { BusinessError } from '@kit.BasicServicesKit'; 371 372window.toggleShownStateForAllAppWindows((err: BusinessError) => { 373 const errCode: number = err.code; 374 if (errCode) { 375 console.error(`Failed to toggle shown state for all app windows. Cause code: ${err.code}, message: ${err.message}`); 376 return; 377 } 378 console.info('Succeeded in toggling shown state for all app windows.'); 379}); 380``` 381 382## window.toggleShownStateForAllAppWindows<sup>9+</sup> 383toggleShownStateForAllAppWindows(): Promise<void> 384 385Hides or restores the application's windows during quick multi-window switching. This API uses a promise to return the result. 386 387**System API**: This is a system API. 388 389**System capability**: SystemCapability.WindowManager.WindowManager.Core 390 391**Return value** 392 393| Type | Description | 394| ------------------- | ------------------------- | 395| Promise<void> | Promise that returns no value.| 396 397**Error codes** 398 399For details about the error codes, see [Window Error Codes](errorcode-window.md). 400 401| ID| Error Message| 402| ------- | -------------------------------------------- | 403| 202 | Permission verification failed. A non-system application calls a system API. | 404| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 405| 1300003 | This window manager service works abnormally. | 406 407**Example** 408 409```ts 410import { BusinessError } from '@kit.BasicServicesKit'; 411 412let promise = window.toggleShownStateForAllAppWindows(); 413promise.then(() => { 414 console.info('Succeeded in toggling shown state for all app windows.'); 415}).catch((err: BusinessError) => { 416 console.error(`Failed to toggle shown state for all app windows. Cause code: ${err.code}, message: ${err.message}`); 417}); 418``` 419 420## window.setWindowLayoutMode<sup>9+</sup> 421setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback<void>): void 422 423Sets the window layout mode. This API uses an asynchronous callback to return the result. 424 425**System API**: This is a system API. 426 427**System capability**: SystemCapability.WindowManager.WindowManager.Core 428 429**Parameters** 430 431| Name | Type | Mandatory| Description | 432| -------- | ------------------------- | ---- | -------------- | 433| mode | [WindowLayoutMode](#windowlayoutmode9) | Yes | Window layout mode to set.| 434| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 435 436**Error codes** 437 438For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 439 440| ID| Error Message| 441| ------- | -------------------------------------------- | 442| 202 | Permission verification failed. A non-system application calls a system API. | 443| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 444| 1300003 | This window manager service works abnormally. | 445 446**Example** 447 448```ts 449import { BusinessError } from '@kit.BasicServicesKit'; 450 451try { 452 window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (err: BusinessError) => { 453 const errCode: number = err.code; 454 if (errCode) { 455 console.error(`Failed to set window layout mode. Cause code: ${err.code}, message: ${err.message}`); 456 return; 457 } 458 console.info('Succeeded in setting window layout mode.'); 459 }); 460} catch (exception) { 461 console.error(`Failed to set window layout mode. Cause code: ${exception.code}, message: ${exception.message}`); 462} 463``` 464 465## window.setWindowLayoutMode<sup>9+</sup> 466setWindowLayoutMode(mode: WindowLayoutMode): Promise<void> 467 468Sets the window layout mode. This API uses a promise to return the result. 469 470**System API**: This is a system API. 471 472**System capability**: SystemCapability.WindowManager.WindowManager.Core 473 474**Parameters** 475 476| Name | Type | Mandatory| Description | 477| -------- | ------------------------- | ---- | -------------- | 478| mode | [WindowLayoutMode](#windowlayoutmode9) | Yes | Window layout mode to set.| 479 480**Return value** 481 482| Type | Description | 483| ------------------- | ------------------------- | 484| Promise<void> | Promise that returns no value.| 485 486**Error codes** 487 488For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 489 490| ID| Error Message| 491| ------- | -------------------------------------------- | 492| 202 | Permission verification failed. A non-system application calls a system API. | 493| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 494| 1300003 | This window manager service works abnormally. | 495 496**Example** 497 498```ts 499import { BusinessError } from '@kit.BasicServicesKit'; 500 501try { 502 let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE); 503 promise.then(() => { 504 console.info('Succeeded in setting window layout mode.'); 505 }).catch((err: BusinessError) => { 506 console.error(`Failed to set window layout mode. Cause code: ${err.code}, message: ${err.message}`); 507 }); 508} catch (exception) { 509 console.error(`Failed to set window layout mode. Cause code: ${exception.code}, message: ${exception.message}`); 510} 511``` 512 513## window.on('systemBarTintChange')<sup>8+</sup> 514 515on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): void 516 517Subscribes to the property change event of the status bar and navigation bar. 518 519**System API**: This is a system API. 520 521**System capability**: SystemCapability.WindowManager.WindowManager.Core 522 523**Parameters** 524 525| Name | Type | Mandatory| Description | 526| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | 527| type | string | Yes | Event type. The value is fixed at **'systemBarTintChange'**, indicating the property change event of the status bar and navigation bar.| 528| callback | Callback<[SystemBarTintState](#systembartintstate8)> | Yes | Callback used to return the properties of the status bar and navigation bar. | 529 530**Error codes** 531 532For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 533 534| ID| Error Message| 535| ------- | -------------------------------- | 536| 202 | Permission verification failed. A non-system application calls a system API. | 537| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 538 539**Example** 540 541```ts 542try { 543 window.on('systemBarTintChange', (data) => { 544 console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data)); 545 }); 546} catch (exception) { 547 console.error(`Failed to enable the listener for systemBarTint changes. Cause code: ${exception.code}, message: ${exception.message}`); 548} 549``` 550 551## window.off('systemBarTintChange')<sup>8+</sup> 552 553off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >): void 554 555Unsubscribes from the property change event of the status bar and navigation bar. 556 557**System API**: This is a system API. 558 559**System capability**: SystemCapability.WindowManager.WindowManager.Core 560 561**Parameters** 562 563| Name | Type | Mandatory| Description | 564| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | 565| type | string | Yes | Event type. The value is fixed at **'systemBarTintChange'**, indicating the property change event of the status bar and navigation bar.| 566| callback | Callback<[SystemBarTintState](#systembartintstate8)> | No | Callback used to return the properties of the status bar and navigation bar. If a value is passed in, the corresponding subscription is canceled. If no value is passed in, all subscriptions to the specified event are canceled. | 567 568**Error codes** 569 570For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 571 572| ID| Error Message| 573| ------- | -------------------------------- | 574| 202 | Permission verification failed. A non-system application calls a system API. | 575| 401 | Parameter error. Possible cause: 1. Incorrect parameter types; 2. Parameter verification failed. | 576 577**Example** 578 579```ts 580const callback = (systemBarTintState: window.SystemBarTintState) => { 581 // ... 582} 583try { 584 window.on('systemBarTintChange', callback); 585 586 window.off('systemBarTintChange', callback); 587 // Unregister all the callbacks that have been registered through on(). 588 window.off('systemBarTintChange'); 589} catch (exception) { 590 console.error(`Failed to enable or disable the listener for systemBarTint changes. Cause code: ${exception.code}, message: ${exception.message}`); 591} 592``` 593 594## window.on('gestureNavigationEnabledChange')<sup>10+</sup> 595 596on(type: 'gestureNavigationEnabledChange', callback: Callback<boolean>): void 597 598Subscribes to the gesture navigation status change event. 599 600**System API**: This is a system API. 601 602**System capability**: SystemCapability.WindowManager.WindowManager.Core 603 604**Parameters** 605 606| Name | Type | Mandatory| Description | 607| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- | 608| type | string | Yes | Event type. The value is fixed at **'gestureNavigationEnabledChange'**, indicating the gesture navigation status change event. | 609| callback | Callback<boolean> | Yes | Callback used to return the gesture navigation status. **true** if enabled, **false** otherwise.| 610 611**Error codes** 612 613For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 614 615| ID| Error Message| 616| ------- | -------------------------------------------- | 617| 202 | Permission verification failed. A non-system application calls a system API. | 618| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 619| 1300002 | This window state is abnormal. | 620| 1300003 | This window manager service works abnormally. | 621 622**Example** 623 624```ts 625try { 626 window.on('gestureNavigationEnabledChange', (data) => { 627 console.info(`Succeeded in enabling the listener for gesture navigation status changes. Data: ${data}`); 628 }); 629} catch (exception) { 630 console.error(`Failed to enable the listener for gesture navigation status changes. Cause code: ${exception.code}, message: ${exception.message}`); 631} 632``` 633 634## window.off('gestureNavigationEnabledChange')<sup>10+</sup> 635 636off(type: 'gestureNavigationEnabledChange', callback?: Callback<boolean>): void 637 638Unsubscribes from the gesture navigation status change event. 639 640**System API**: This is a system API. 641 642**System capability**: SystemCapability.WindowManager.WindowManager.Core 643 644**Parameters** 645 646| Name | Type | Mandatory| Description | 647| -------- | ----------------------- | -- | ------------------------------------------------------------ | 648| type | string | Yes| Event type. The value is fixed at **'gestureNavigationEnabledChange'**, indicating the gesture navigation status change event.| 649| callback | Callback<boolean> | No| Callback function that has been used for the subscription. If a value is passed in, the corresponding subscription is canceled. If no value is passed in, all subscriptions to the specified event are canceled.| 650 651**Error codes** 652 653For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 654 655| ID| Error Message| 656| ------- | -------------------------------------------- | 657| 202 | Permission verification failed. A non-system application calls a system API. | 658| 401 | Parameter error. Possible cause: 1. Incorrect parameter types; 2. Parameter verification failed. | 659| 1300002 | This window state is abnormal. | 660| 1300003 | This window manager service works abnormally. | 661 662**Example** 663 664```ts 665const callback = (bool: boolean) => { 666 // ... 667} 668try { 669 window.on('gestureNavigationEnabledChange', callback); 670 window.off('gestureNavigationEnabledChange', callback); 671 // Unregister all the callbacks that have been registered through on(). 672 window.off('gestureNavigationEnabledChange'); 673} catch (exception) { 674 console.error(`Failed to enable or disable the listener for gesture navigation status changes. Cause code: ${exception.code}, message: ${exception.message}`); 675} 676``` 677 678## window.on('waterMarkFlagChange')<sup>10+</sup> 679 680on(type: 'waterMarkFlagChange', callback: Callback<boolean>): void 681 682Subscribes to the watermark status change event. 683 684**System API**: This is a system API. 685 686**System capability**: SystemCapability.WindowManager.WindowManager.Core 687 688**Parameters** 689 690| Name | Type | Mandatory| Description | 691| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- | 692| type | string | Yes | Event type. The value is fixed at **'waterMarkFlagChange'**, indicating the watermark status change event. | 693| callback | Callback<boolean> | Yes | Callback used to return the watermark status. **true** if enabled, **false** otherwise.| 694 695**Error codes** 696 697For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 698 699| ID| Error Message| 700| ------- | -------------------------------------------- | 701| 202 | Permission verification failed. A non-system application calls a system API. | 702| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed. | 703| 1300002 | This window state is abnormal. | 704| 1300003 | This window manager service works abnormally. | 705 706**Example** 707 708```ts 709try { 710 window.on('waterMarkFlagChange', (data) => { 711 console.info(`Succeeded in enabling the listener for watermark flag changes. Data: ${data}`); 712 }); 713} catch (exception) { 714 console.error(`Failed to enable the listener for watermark flag changes. Cause code: ${exception.code}, message: ${exception.message}`); 715} 716``` 717 718## window.off('waterMarkFlagChange')<sup>10+</sup> 719 720off(type: 'waterMarkFlagChange', callback?: Callback<boolean>): void 721 722Unsubscribes from the watermark status change event. 723 724**System API**: This is a system API. 725 726**System capability**: SystemCapability.WindowManager.WindowManager.Core 727 728**Parameters** 729 730| Name | Type | Mandatory| Description | 731| -------- | ----------------------- | -- | ------------------------------------------------------------ | 732| type | string | Yes| Event type. The value is fixed at **'waterMarkFlagChange'**, indicating the watermark status change event.| 733| callback | Callback<boolean> | No| Callback function that has been used for the subscription. If a value is passed in, the corresponding subscription is canceled. If no value is passed in, all subscriptions to the specified event are canceled.| 734 735**Error codes** 736 737For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 738 739| ID| Error Message| 740| ------- | -------------------------------------------- | 741| 202 | Permission verification failed. A non-system application calls a system API. | 742| 401 | Parameter error. Possible cause: 1. Incorrect parameter types; 2. Parameter verification failed. | 743| 1300002 | This window state is abnormal. | 744| 1300003 | This window manager service works abnormally. | 745 746**Example** 747 748```ts 749const callback = (bool: boolean) => { 750 // ... 751} 752try { 753 window.on('waterMarkFlagChange', callback); 754 window.off('waterMarkFlagChange', callback); 755 // Unregister all the callbacks that have been registered through on(). 756 window.off('waterMarkFlagChange'); 757} catch (exception) { 758 console.error(`Failed to enable or disable the listener for watermark flag changes. Cause code: ${exception.code}, message: ${exception.message}`); 759} 760``` 761 762## window.setGestureNavigationEnabled<sup>10+</sup> 763setGestureNavigationEnabled(enable: boolean, callback: AsyncCallback<void>): void 764 765Enables or disables gesture navigation. This API uses an asynchronous callback to return the result. 766 767For security purposes, the system does not interfere with the disabling and enabling of gesture navigation. If an application exits abnormally after it disables gesture navigation and wants to restore gesture navigation, it must implement automatic launch and call this API again to enable gesture navigation. 768 769**System API**: This is a system API. 770 771**System capability**: SystemCapability.WindowManager.WindowManager.Core 772 773**Parameters** 774 775| Name | Type | Mandatory| Description | 776| -------- | ------------------------- | ---- | -------------- | 777| enable | boolean | Yes | Whether to enable gesture navigation. **true** to enable, **false** otherwise.| 778| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 779 780**Error codes** 781 782For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 783 784| ID| Error Message| 785| ------- | --------------------------------------------- | 786| 202 | Permission verification failed. A non-system application calls a system API. | 787| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 788| 1300002 | This window state is abnormal. | 789| 1300003 | This window manager service works abnormally. | 790 791**Example** 792 793```ts 794import { BusinessError } from '@kit.BasicServicesKit'; 795 796try { 797 window.setGestureNavigationEnabled(true, (err: BusinessError) => { 798 const errCode: number = err.code; 799 if (errCode) { 800 console.error(`Failed to set gesture navigation enabled. Cause code: ${err.code}, message: ${err.message}`); 801 return; 802 } 803 console.info('Succeeded in setting gesture navigation enabled.'); 804 }); 805} catch (exception) { 806 console.error(`Failed to set gesture navigation enabled. Cause code: ${exception.code}, message: ${exception.message}`); 807} 808``` 809 810## window.setGestureNavigationEnabled<sup>10+</sup> 811setGestureNavigationEnabled(enable: boolean): Promise<void> 812 813Enables or disables gesture navigation. This API uses a promise to return the result. 814 815For security purposes, the system does not interfere with the disabling and enabling of gesture navigation. If an application exits abnormally after it disables gesture navigation and wants to restore gesture navigation, it must implement automatic launch and call this API again to enable gesture navigation. 816 817**System API**: This is a system API. 818 819**System capability**: SystemCapability.WindowManager.WindowManager.Core 820 821**Parameters** 822 823| Name| Type | Mandatory | Description | 824| ------ | ------- | ---- | -------------------- | 825| enable | boolean | Yes | Whether to enable gesture navigation. **true** to enable, **false** otherwise.| 826 827**Return value** 828 829| Type | Description | 830| ------------------- | ------------------------- | 831| Promise<void> | Promise that returns no value.| 832 833**Error codes** 834 835For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 836 837| ID| Error Message| 838| ------- | -------------------------------------------- | 839| 202 | Permission verification failed. A non-system application calls a system API. | 840| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 841| 1300002 | This window state is abnormal. | 842| 1300003 | This window manager service works abnormally. | 843 844**Example** 845 846```ts 847import { BusinessError } from '@kit.BasicServicesKit'; 848 849try { 850 let promise = window.setGestureNavigationEnabled(true); 851 promise.then(() => { 852 console.info('Succeeded in setting gesture navigation enabled.'); 853 }).catch((err: BusinessError) => { 854 console.error(`Failed to set gesture navigation enabled. Cause code: ${err.code}, message: ${err.message}`); 855 }); 856} catch (exception) { 857 console.error(`Failed to set gesture navigation enabled. Cause code: ${exception.code}, message: ${exception.message}`); 858} 859``` 860 861## window.setWaterMarkImage<sup>10+</sup> 862setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean, callback: AsyncCallback<void>): void 863 864Controls whether a watermark image is displayed on the screen. This API uses an asynchronous callback to return the result. 865 866**System API**: This is a system API. 867 868**System capability**: SystemCapability.WindowManager.WindowManager.Core 869 870**Parameters** 871 872| Name | Type | Mandatory| Description | 873| -------- | ------------------------- | ---- | -------------- | 874| pixelMap | [image.PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md) | Yes| Watermark image, which can be obtained by calling [createPixelMap](../apis-image-kit/arkts-apis-image-f.md#imagecreatepixelmap8).| 875| enable | boolean | Yes | Whether to display the watermark image. **true** to display, **false** otherwise. After the watermark image is displayed, you need to set this parameter to **false** to disable the watermark display.| 876| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 877 878**Error codes** 879 880For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 881 882| ID| Error Message| 883| ------- | --------------------------------------------- | 884| 202 | Permission verification failed. A non-system application calls a system API. | 885| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 886| 1300003 | This window manager service works abnormally. | 887 888**Example** 889 890```ts 891import { image } from '@kit.ImageKit'; 892import { BusinessError } from '@kit.BasicServicesKit'; 893 894let enable: boolean = true; 895let color: ArrayBuffer = new ArrayBuffer(0); 896let initializationOptions: image.InitializationOptions = { 897 size: { 898 height: 100, 899 width: 100 900 } 901}; 902image.createPixelMap(color, initializationOptions).then((pixelMap: image.PixelMap) => { 903 console.info('Succeeded in creating pixelmap.'); 904 try { 905 window.setWaterMarkImage(pixelMap, enable, (err: BusinessError) => { 906 const errCode: number = err.code; 907 if (errCode) { 908 console.error(`Failed to show watermark image. Cause code: ${err.code}, message: ${err.message}`); 909 return; 910 } 911 console.info('Succeeded in showing watermark image.'); 912 }); 913 } catch (exception) { 914 console.error(`Failed to show watermark image. Cause code: ${exception.code}, message: ${exception.message}`); 915 } 916}).catch((err: BusinessError) => { 917 console.error(`Failed to create PixelMap. Cause code: ${err.code}, message: ${err.message}`); 918}); 919``` 920 921## window.setWaterMarkImage<sup>10+</sup> 922setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean): Promise<void> 923 924Controls whether a watermark image is displayed on the screen. This API uses a promise to return the result. 925 926**System API**: This is a system API. 927 928**System capability**: SystemCapability.WindowManager.WindowManager.Core 929 930**Parameters** 931 932| Name| Type | Mandatory | Description | 933| ------ | --------------------------- | ---- | -------------------- | 934| pixelMap | [image.PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md) | Yes| Watermark image, which can be obtained by calling [createPixelMap](../apis-image-kit/arkts-apis-image-f.md#imagecreatepixelmap8).| 935| enable | boolean | Yes | Whether to display the watermark image. **true** to display, **false** otherwise. After the watermark image is displayed, you need to set this parameter to **false** to disable the watermark display.| 936 937**Return value** 938 939| Type | Description | 940| ------------------- | ------------------------- | 941| Promise<void> | Promise that returns no value.| 942 943**Error codes** 944 945For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 946 947| ID| Error Message| 948| ------- | -------------------------------------------- | 949| 202 | Permission verification failed. A non-system application calls a system API. | 950| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 951| 1300003 | This window manager service works abnormally. | 952 953**Example** 954 955```ts 956import { image } from '@kit.ImageKit'; 957import { BusinessError } from '@kit.BasicServicesKit'; 958 959let enable: boolean = true; 960let color: ArrayBuffer = new ArrayBuffer(0); 961let initializationOptions: image.InitializationOptions = { 962 size: { 963 height: 100, 964 width: 100 965 } 966}; 967image.createPixelMap(color, initializationOptions).then((pixelMap: image.PixelMap) => { 968 console.info('Succeeded in creating pixelmap.'); 969 try { 970 let promise = window.setWaterMarkImage(pixelMap, enable); 971 promise.then(() => { 972 console.info('Succeeded in showing watermark image.'); 973 }).catch((err: BusinessError) => { 974 console.error(`Failed to show watermark image. Cause code: ${err.code}, message: ${err.message}`); 975 }); 976 } catch (exception) { 977 console.error(`Failed to show watermark image. Cause code: ${exception.code}, message: ${exception.message}`); 978 } 979}).catch((err: BusinessError) => { 980 console.error(`Failed to create PixelMap. Cause code: ${err.code}, message: ${err.message}`); 981}); 982``` 983 984## window.getSnapshot<sup>12+</sup> 985 986getSnapshot(windowId: number): Promise<image.PixelMap> 987 988Obtains a snapshot of the same size as the specified window. This API uses a promise to return the result. 989 990**System API**: This is a system API. 991 992**System capability**: SystemCapability.WindowManager.WindowManager.Core 993 994**Parameters** 995| Name | Type | Mandatory | Description | 996| -------- | ------ | ----- | ------------ | 997| windowId | number | Yes | Window ID. You can call [getWindowProperties](arkts-apis-window-Window.md#getwindowproperties9) to obtain the window properties, in which **id** is the window ID.| 998 999**Return value** 1000| Type | Description | 1001| ----------------------- | ------------------------------- | 1002| Promise<[image.PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md)> | Promise used to return the window screenshot.| 1003 1004**Error codes** 1005For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1006 1007| ID| Error Message | 1008| -------- | -------------------------------------------- | 1009| 202 | Permission verification failed. A non-system application calls a system API. | 1010| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed. | 1011| 1300002 | This window state is abnormal. | 1012| 1300003 | This window manager service works abnormally. | 1013| 1300004 | This operation is not accessible. | 1014 1015**Example** 1016```ts 1017import { BusinessError } from '@kit.BasicServicesKit'; 1018import { image } from '@kit.ImageKit'; 1019 1020try { 1021 // This is only an example. Use getWindowProperties to obtain the window ID. 1022 let windowId: number = 40; 1023 let promise = window.getSnapshot(windowId); 1024 promise.then((pixelMap: image.PixelMap) => { 1025 console.info('Succeeded in getting snapshot window. Pixel bytes number:' + pixelMap.getPixelBytesNumber()); 1026 pixelMap.release(); 1027 }).catch((err: BusinessError) =>{ 1028 console.error(`Failed to get snapshot. Cause code: ${err.code}, message: ${err.message}`); 1029 }); 1030} catch (exception) { 1031 console.error(`Failed to get snapshot. Cause code: ${exception.code}, message: ${exception.message}`); 1032} 1033``` 1034 1035## window.notifyScreenshotEvent<sup>20+</sup> 1036 1037notifyScreenshotEvent(eventType: ScreenshotEventType): Promise<void> 1038 1039Notifies a screenshot event. This API uses a promise to return the result. 1040 1041**System API**: This is a system API. 1042 1043**System capability**: SystemCapability.WindowManager.WindowManager.Core 1044 1045**Parameters** 1046 1047| Name | Type | Mandatory | Description | 1048| -------- | ------ | ----- | ------------ | 1049| eventType | [ScreenshotEventType](arkts-apis-window-e.md#screenshoteventtype20) | Yes | Type of the screenshot event.| 1050 1051**Return value** 1052 1053| Type | Description | 1054| ----------------------- | ------------------------------- | 1055| Promise<void> | Promise that returns no value.| 1056 1057**Error codes** 1058 1059For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1060 1061| ID| Error Message | 1062| -------- | -------------------------------------------- | 1063| 202 | Permission verification failed. A non-system application calls a system API. | 1064| 1300003 | This window manager service works abnormally. | 1065| 1300016 | Parameter error. Possible cause: 1. Invalid parameter range. | 1066 1067**Example** 1068 1069```ts 1070import { BusinessError } from '@kit.BasicServicesKit'; 1071 1072try { 1073 let eventType: window.ScreenshotEventType = window.ScreenshotEventType.SYSTEM_SCREENSHOT; 1074 let promise = window.notifyScreenshotEvent(eventType); 1075 promise.then(() => { 1076 console.info(`Succeeded in notifying screenshot event type.`); 1077 }).catch((err: BusinessError) =>{ 1078 console.error(`Failed to notify screenshot event type. Cause code: ${err.code}, message: ${err.message}`); 1079 }); 1080} catch (exception) { 1081 console.error(`Failed to notify screenshot event type. Cause code: ${exception.code}, message: ${exception.message}`); 1082} 1083``` 1084 1085## window.getTopNavDestinationName<sup>20+</sup> 1086 1087getTopNavDestinationName(windowId: number): Promise<string> 1088 1089Obtains the name of [NavDestination](arkui-ts/ts-basic-components-navdestination.md) in the current top-level [Navigation](arkui-ts/ts-basic-components-navigation.md) component of the specified foreground window. This API uses a promise to return the result. 1090 1091**System API**: This is a system API. 1092 1093**System capability**: SystemCapability.Window.SessionManager 1094 1095**Parameters** 1096 1097| Name| Type | Mandatory| Description | 1098| ------ | ---------- |----|---------------------------------------------------------------------------| 1099| windowId | number| Yes | ID of the window to query. This parameter must be an integer greater than 0. If it is less than or equal to 0, error code 1300016 is returned. If the specified window does not exist or is not in the foreground, error code 1300002 is returned.| 1100 1101**Return value** 1102 1103| Type | Description | 1104| -------------------------------- |-------------------------| 1105| Promise<string> | Promise used to return the [NavDestination](arkui-ts/ts-basic-components-navdestination.md) name obtained.<br>If there are nested [Navigation](arkui-ts/ts-basic-components-navigation.md) components or multiple [Navigation](arkui-ts/ts-basic-components-navigation.md) components on the current page, the information of the most recently created [Navigation](arkui-ts/ts-basic-components-navigation.md) component is queried.<br>If the page does not have the [Navigation](arkui-ts/ts-basic-components-navigation.md) component or the [Navigation](arkui-ts/ts-basic-components-navigation.md) component does not have [NavDestination](arkui-ts/ts-basic-components-navdestination.md), an empty string is returned.| 1106 1107**Error codes** 1108 1109For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1110 1111| ID | Error Message| 1112|----------| ------------------------------ | 1113| 202 | Permission verification failed, non-system application uses system API. | 1114| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 1115| 1300002 | This window state is abnormal. | 1116| 1300003 | This window manager service works abnormally. | 1117| 1300016 | Parameter error. Possible cause: 1. Invalid parameter range. | 1118 1119**Example** 1120```ts 1121import { window } from '@kit.ArkUI'; 1122import { BusinessError } from '@kit.BasicServicesKit'; 1123 1124try { 1125 let windowId = 10; 1126 let promise = window.getTopNavDestinationName(windowId); 1127 promise.then((data) => { 1128 console.info(`Succeeded, data: ${data}`); 1129 }).catch((err: BusinessError) => { 1130 console.error(`Failed, cause code: ${err.code}, message: ${err.message}`); 1131 }); 1132} catch (exception) { 1133 console.error(`Failed, exception code: ${exception.code}, message: ${exception.message}`); 1134} 1135``` 1136 1137## Window 1138 1139Represents a window instance, which is the basic unit managed by the window manager. 1140 1141In the following API examples, you must use [getLastWindow()](arkts-apis-window-f.md#windowgetlastwindow9), [createWindow()](arkts-apis-window-f.md#windowcreatewindow9), or [findWindow()](arkts-apis-window-f.md#windowfindwindow9) to obtain a Window instance (named windowClass in this example) and then call a method in this instance. 1142 1143### hide<sup>7+</sup> 1144 1145hide (callback: AsyncCallback<void>): void 1146 1147Hides this window. This API uses an asynchronous callback to return the result. This API takes effect only for a system window or an application child window. 1148 1149**System API**: This is a system API. 1150 1151**System capability**: SystemCapability.WindowManager.WindowManager.Core 1152 1153**Parameters** 1154 1155| Name | Type | Mandatory| Description | 1156| -------- | ------------------------- | ---- | ---------- | 1157| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1158 1159**Error codes** 1160 1161For details about the error codes, see [Window Error Codes](errorcode-window.md). 1162 1163| ID| Error Message| 1164| ------- | ------------------------------ | 1165| 202 | Permission verification failed. A non-system application calls a system API. | 1166| 1300002 | This window state is abnormal. | 1167 1168**Example** 1169 1170```ts 1171import { BusinessError } from '@kit.BasicServicesKit'; 1172 1173windowClass.hide((err: BusinessError) => { 1174 const errCode: number = err.code; 1175 if (errCode) { 1176 console.error(`Failed to hide the window. Cause code: ${err.code}, message: ${err.message}`); 1177 return; 1178 } 1179 console.info('Succeeded in hiding the window.'); 1180}); 1181``` 1182 1183### hide<sup>7+</sup> 1184 1185hide(): Promise<void> 1186 1187Hides this window. This API uses a promise to return the result. This API takes effect only for a system window or an application child window. 1188 1189**System API**: This is a system API. 1190 1191**System capability**: SystemCapability.WindowManager.WindowManager.Core 1192 1193**Return value** 1194 1195| Type | Description | 1196| ------------------- | ------------------------- | 1197| Promise<void> | Promise that returns no value.| 1198 1199**Error codes** 1200 1201For details about the error codes, see [Window Error Codes](errorcode-window.md). 1202 1203| ID| Error Message| 1204| ------- | ------------------------------ | 1205| 202 | Permission verification failed. A non-system application calls a system API. | 1206| 1300002 | This window state is abnormal. | 1207 1208**Example** 1209 1210```ts 1211import { BusinessError } from '@kit.BasicServicesKit'; 1212 1213let promise = windowClass.hide(); 1214promise.then(() => { 1215 console.info('Succeeded in hiding the window.'); 1216}).catch((err: BusinessError) => { 1217 console.error(`Failed to hide the window. Cause code: ${err.code}, message: ${err.message}`); 1218}); 1219``` 1220 1221### hideWithAnimation<sup>9+</sup> 1222 1223hideWithAnimation(callback: AsyncCallback<void>): void 1224 1225Hides this window and plays an animation during the process. This API uses an asynchronous callback to return the result. This API takes effect only for a system window. 1226 1227**System API**: This is a system API. 1228 1229**System capability**: SystemCapability.WindowManager.WindowManager.Core 1230 1231**Parameters** 1232 1233| Name | Type | Mandatory| Description | 1234| -------- | ------------------------- | ---- | ---------- | 1235| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1236 1237**Error codes** 1238 1239For details about the error codes, see [Window Error Codes](errorcode-window.md). 1240 1241| ID| Error Message| 1242| ------- | -------------------------------------------- | 1243| 202 | Permission verification failed. A non-system application calls a system API. | 1244| 1300002 | This window state is abnormal. | 1245| 1300003 | This window manager service works abnormally. | 1246| 1300004 | Unauthorized operation. | 1247 1248**Example** 1249 1250```ts 1251import { BusinessError } from '@kit.BasicServicesKit'; 1252 1253windowClass.hideWithAnimation((err: BusinessError) => { 1254 const errCode: number = err.code; 1255 if (errCode) { 1256 console.error(`Failed to hide the window with animation. Cause code: ${err.code}, message: ${err.message}`); 1257 return; 1258 } 1259 console.info('Succeeded in hiding the window with animation.'); 1260}); 1261``` 1262 1263### hideWithAnimation<sup>9+</sup> 1264 1265hideWithAnimation(): Promise<void> 1266 1267Hides this window and plays an animation during the process. This API uses a promise to return the result. This API takes effect only for a system window. 1268 1269**System API**: This is a system API. 1270 1271**System capability**: SystemCapability.WindowManager.WindowManager.Core 1272 1273**Return value** 1274 1275| Type | Description | 1276| ------------------- | ------------------------- | 1277| Promise<void> | Promise that returns no value.| 1278 1279**Error codes** 1280 1281For details about the error codes, see [Window Error Codes](errorcode-window.md). 1282 1283| ID| Error Message| 1284| ------- | -------------------------------------------- | 1285| 202 | Permission verification failed. A non-system application calls a system API. | 1286| 1300002 | This window state is abnormal. | 1287| 1300003 | This window manager service works abnormally. | 1288| 1300004 | Unauthorized operation. | 1289 1290**Example** 1291 1292```ts 1293import { BusinessError } from '@kit.BasicServicesKit'; 1294 1295let promise = windowClass.hideWithAnimation(); 1296promise.then(() => { 1297 console.info('Succeeded in hiding the window with animation.'); 1298}).catch((err: BusinessError) => { 1299 console.error(`Failed to hide the window with animation. Cause code: ${err.code}, message: ${err.message}`); 1300}); 1301``` 1302 1303### showWithAnimation<sup>9+</sup> 1304 1305showWithAnimation(callback: AsyncCallback<void>): void 1306 1307Shows this window and plays an animation during the process. This API uses an asynchronous callback to return the result. This API takes effect only for a system window. 1308 1309**System API**: This is a system API. 1310 1311**System capability**: SystemCapability.WindowManager.WindowManager.Core 1312 1313**Parameters** 1314 1315| Name | Type | Mandatory| Description | 1316| -------- | ------------------------- | ---- | ---------- | 1317| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1318 1319**Error codes** 1320 1321For details about the error codes, see [Window Error Codes](errorcode-window.md). 1322 1323| ID| Error Message| 1324| ------- | -------------------------------------------- | 1325| 202 | Permission verification failed. A non-system application calls a system API. | 1326| 1300002 | This window state is abnormal. | 1327| 1300003 | This window manager service works abnormally. | 1328| 1300004 | Unauthorized operation. | 1329 1330**Example** 1331 1332```ts 1333import { BusinessError } from '@kit.BasicServicesKit'; 1334 1335windowClass.showWithAnimation((err: BusinessError) => { 1336 const errCode: number = err.code; 1337 if (errCode) { 1338 console.error(`Failed to show the window with animation. Cause code: ${err.code}, message: ${err.message}`); 1339 return; 1340 } 1341 console.info('Succeeded in showing the window with animation.'); 1342}); 1343``` 1344 1345### showWithAnimation<sup>9+</sup> 1346 1347showWithAnimation(): Promise<void> 1348 1349Shows this window and plays an animation during the process. This API uses a promise to return the result. This API takes effect only for a system window. 1350 1351**System API**: This is a system API. 1352 1353**System capability**: SystemCapability.WindowManager.WindowManager.Core 1354 1355**Return value** 1356 1357| Type | Description | 1358| ------------------- | ------------------------- | 1359| Promise<void> | Promise that returns no value.| 1360 1361**Error codes** 1362 1363For details about the error codes, see [Window Error Codes](errorcode-window.md). 1364 1365| ID| Error Message| 1366| ------- | -------------------------------------------- | 1367| 202 | Permission verification failed. A non-system application calls a system API. | 1368| 1300002 | This window state is abnormal. | 1369| 1300003 | This window manager service works abnormally. | 1370| 1300004 | Unauthorized operation. | 1371 1372**Example** 1373 1374```ts 1375import { BusinessError } from '@kit.BasicServicesKit'; 1376 1377let promise = windowClass.showWithAnimation(); 1378promise.then(() => { 1379 console.info('Succeeded in showing the window with animation.'); 1380}).catch((err: BusinessError) => { 1381 console.error(`Failed to show the window with animation. Cause code: ${err.code}, message: ${err.message}`); 1382}); 1383``` 1384 1385### setWindowMode<sup>9+</sup> 1386 1387setWindowMode(mode: WindowMode, callback: AsyncCallback<void>): void 1388 1389Sets the mode of the main window. This API uses an asynchronous callback to return the result. 1390 1391**System API**: This is a system API. 1392 1393**System capability**: SystemCapability.WindowManager.WindowManager.Core 1394 1395**Parameters** 1396 1397| Name| Type| Mandatory| Description| 1398| -------- | -------------------------- | -- | --------- | 1399| mode | [WindowMode](#windowmode7) | Yes| Window mode to set.| 1400| callback | AsyncCallback<void> | Yes| Callback used to return the result.| 1401 1402**Error codes** 1403 1404For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1405 1406| ID| Error Message| 1407| ------- | -------------------------------------------- | 1408| 202 | Permission verification failed. A non-system application calls a system API. | 1409| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1410| 1300002 | This window state is abnormal. | 1411| 1300003 | This window manager service works abnormally. | 1412 1413**Example** 1414 1415```ts 1416// EntryAbility.ets 1417import { UIAbility } from '@kit.AbilityKit'; 1418import { BusinessError } from '@kit.BasicServicesKit'; 1419 1420export default class EntryAbility extends UIAbility { 1421 // ... 1422 onWindowStageCreate(windowStage: window.WindowStage): void { 1423 console.info('onWindowStageCreate'); 1424 let windowClass: window.Window | undefined = undefined; 1425 windowStage.getMainWindow((err: BusinessError, data) => { 1426 const errCode: number = err.code; 1427 if (errCode) { 1428 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 1429 return; 1430 } 1431 windowClass = data; 1432 let mode = window.WindowMode.FULLSCREEN; 1433 try { 1434 windowClass.setWindowMode(mode, (err: BusinessError) => { 1435 const errCode: number = err.code; 1436 if (errCode) { 1437 console.error(`Failed to set the window mode. Cause code: ${err.code}, message: ${err.message}`); 1438 return; 1439 } 1440 console.info('Succeeded in setting the window mode.'); 1441 }); 1442 } catch (exception) { 1443 console.error(`Failed to set the window mode. Cause code: ${exception.code}, message: ${exception.message}`); 1444 } 1445 }); 1446 } 1447} 1448``` 1449 1450### setWindowMode<sup>9+</sup> 1451 1452setWindowMode(mode: WindowMode): Promise<void> 1453 1454Sets the mode of the main window. This API uses a promise to return the result. 1455 1456**System API**: This is a system API. 1457 1458**System capability**: SystemCapability.WindowManager.WindowManager.Core 1459 1460**Parameters** 1461 1462| Name| Type| Mandatory| Description| 1463| -------- | -------------------------- | -- | --------- | 1464| mode | [WindowMode](#windowmode7) | Yes| Window mode to set.| 1465 1466**Return value** 1467 1468| Type| Description| 1469| ------------------- | ----------------------- | 1470| Promise<void> | Promise that returns no value.| 1471 1472**Error codes** 1473 1474For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1475 1476| ID| Error Message| 1477| ------- | -------------------------------------------- | 1478| 202 | Permission verification failed. A non-system application calls a system API. | 1479| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1480| 1300002 | This window state is abnormal. | 1481| 1300003 | This window manager service works abnormally. | 1482 1483**Example** 1484 1485```ts 1486// EntryAbility.ets 1487import { UIAbility } from '@kit.AbilityKit'; 1488import { BusinessError } from '@kit.BasicServicesKit'; 1489 1490export default class EntryAbility extends UIAbility { 1491 // ... 1492 onWindowStageCreate(windowStage: window.WindowStage): void { 1493 console.info('onWindowStageCreate'); 1494 let windowClass: window.Window | undefined = undefined; 1495 windowStage.getMainWindow((err: BusinessError, data) => { 1496 const errCode: number = err.code; 1497 if (errCode) { 1498 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 1499 return; 1500 } 1501 windowClass = data; 1502 let mode = window.WindowMode.FULLSCREEN; 1503 try { 1504 let promise = windowClass.setWindowMode(mode); 1505 promise.then(() => { 1506 console.info('Succeeded in setting the window mode.'); 1507 }).catch((err: BusinessError) => { 1508 console.error(`Failed to set the window mode. Cause code: ${err.code}, message: ${err.message}`); 1509 }); 1510 } catch (exception) { 1511 console.error(`Failed to set the window mode. Cause code: ${exception.code}, message: ${exception.message}`); 1512 } 1513 }); 1514 } 1515} 1516``` 1517 1518### bindDialogTarget<sup>9+</sup> 1519 1520bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>, callback: AsyncCallback<void>): void 1521 1522Binds the modal window to the target window, and adds a callback to listen for modal window destruction events. This API uses an asynchronous callback to return the result. 1523 1524**System API**: This is a system API. 1525 1526**System capability**: SystemCapability.WindowManager.WindowManager.Core 1527 1528**Parameters** 1529 1530| Name | Type | Mandatory| Description | 1531| ----------- | ------------------------- | ---- | -------------------- | 1532| token | [rpc.RemoteObject](../apis-ipc-kit/js-apis-rpc.md#remoteobject) | Yes | Token of the target window.| 1533| deathCallback | Callback<void> | Yes | Callback used to listen for modal window destruction events.| 1534| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1535 1536**Error codes** 1537 1538For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1539 1540| ID| Error Message| 1541| ------- | -------------------------------------------- | 1542| 202 | Permission verification failed. A non-system application calls a system API. | 1543| 401 | Parameter error. Possible cause: Incorrect parameter types. | 1544| 1300002 | This window state is abnormal. | 1545| 1300003 | This window manager service works abnormally. | 1546 1547**Example** 1548 1549```ts 1550import { rpc } from '@kit.IPCKit'; 1551import { BusinessError } from '@kit.BasicServicesKit'; 1552 1553class MyDeathRecipient { 1554 onRemoteDied() { 1555 console.log('server died'); 1556 } 1557} 1558 1559class TestRemoteObject extends rpc.RemoteObject { 1560 constructor(descriptor: string) { 1561 super(descriptor); 1562 } 1563 1564 addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { 1565 return true; 1566 } 1567 1568 removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { 1569 return true; 1570 } 1571 1572 isObjectDead(): boolean { 1573 return false; 1574 } 1575} 1576 1577let token: TestRemoteObject = new TestRemoteObject('testObject'); 1578let config: window.Configuration = { name: "test", windowType: window.WindowType.TYPE_DIALOG, ctx: getContext() }; 1579try { 1580 window.createWindow(config, (err: BusinessError, data) => { 1581 let errCode: number = err?.code; 1582 if (errCode) { 1583 console.error(`Failed to create the window. Cause code: ${err?.code}, message: ${err?.message}`); 1584 return; 1585 } 1586 if (!data) { 1587 console.error('data is null'); 1588 return; 1589 } 1590 data.bindDialogTarget(token, () => { 1591 console.info('Dialog Window Need Destroy.'); 1592 }, (err: BusinessError) => { 1593 let errCode: number = err?.code; 1594 if (errCode) { 1595 console.error(`Failed to bind dialog target. Cause code: ${err?.code}, message: ${err?.message}`); 1596 return; 1597 } 1598 console.info('Succeeded in binding dialog target.'); 1599 }); 1600 }); 1601} catch (exception) { 1602 console.error(`Failed to bind dialog target. Cause code: ${exception.code}, message: ${exception.message}`); 1603} 1604``` 1605 1606### bindDialogTarget<sup>9+</sup> 1607 1608bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>): Promise<void> 1609 1610Binds the modal window to the target window, and adds a callback to listen for modal window destruction events. This API uses a promise to return the result. 1611 1612**System API**: This is a system API. 1613 1614**System capability**: SystemCapability.WindowManager.WindowManager.Core 1615 1616**Parameters** 1617 1618| Name | Type | Mandatory| Description | 1619| ----------- | ------------------------- | ---- | -------------------- | 1620| token | [rpc.RemoteObject](../apis-ipc-kit/js-apis-rpc.md#remoteobject) | Yes | Token of the target window.| 1621| deathCallback | Callback<void> | Yes | Callback used to listen for modal window destruction events.| 1622 1623**Return value** 1624 1625| Type | Description | 1626| ------------------- | ------------------------- | 1627| Promise<void> | Promise that returns no value.| 1628 1629**Error codes** 1630 1631For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1632 1633| ID| Error Message| 1634| ------- | -------------------------------------------- | 1635| 202 | Permission verification failed. A non-system application calls a system API. | 1636| 401 | Parameter error. Possible cause: Incorrect parameter types. | 1637| 1300002 | This window state is abnormal. | 1638| 1300003 | This window manager service works abnormally. | 1639 1640**Example** 1641 1642```ts 1643import { rpc } from '@kit.IPCKit'; 1644import { BusinessError } from '@kit.BasicServicesKit'; 1645 1646class MyDeathRecipient { 1647 onRemoteDied() { 1648 console.log('server died'); 1649 } 1650} 1651 1652class TestRemoteObject extends rpc.RemoteObject { 1653 constructor(descriptor: string) { 1654 super(descriptor); 1655 } 1656 1657 addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { 1658 return true; 1659 } 1660 1661 removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { 1662 return true; 1663 } 1664 1665 isObjectDead(): boolean { 1666 return false; 1667 } 1668} 1669 1670let token: TestRemoteObject = new TestRemoteObject('testObject'); 1671let config: window.Configuration = { 1672 name: "test", 1673 windowType: window.WindowType.TYPE_DIALOG, 1674 ctx: getContext() 1675}; 1676try { 1677 window.createWindow(config, (err: BusinessError, data) => { 1678 const errCode: number = err?.code; 1679 if (errCode) { 1680 console.error(`Failed to create the window. Cause code: ${err?.code}, message: ${err?.message}`); 1681 return; 1682 } 1683 if (!data) { 1684 console.error('data is null'); 1685 return; 1686 } 1687 let promise = data.bindDialogTarget(token, () => { 1688 console.info('Dialog Window Need Destroy.'); 1689 }); 1690 promise.then(() => { 1691 console.info('Succeeded in binding dialog target.'); 1692 }).catch((err: BusinessError) => { 1693 console.error(`Failed to bind dialog target. Cause code: ${err?.code}, message: ${err?.message}`); 1694 }); 1695 }); 1696} catch (exception) { 1697 console.error(`Failed to bind dialog target. Cause code: ${exception.code}, message: ${exception.message}`); 1698} 1699``` 1700 1701### bindDialogTarget<sup>9+</sup> 1702 1703bindDialogTarget(requestInfo: dialogRequest.RequestInfo, deathCallback: Callback<void>, callback: AsyncCallback<void>): void 1704 1705Binds the modal window to the target window, and adds a callback to listen for modal window destruction events. This API uses an asynchronous callback to return the result. 1706 1707**System API**: This is a system API. 1708 1709**System capability**: SystemCapability.WindowManager.WindowManager.Core 1710 1711**Parameters** 1712 1713| Name | Type | Mandatory| Description | 1714| ----------- | ------------------------- | ---- | -------------------- | 1715| requestInfo | [dialogRequest.RequestInfo](../apis-ability-kit/js-apis-app-ability-dialogRequest.md#requestinfo) | Yes | **RequestInfo** of the target window.| 1716| deathCallback | Callback<void> | Yes | Callback used to listen for modal window destruction events.| 1717| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1718 1719**Error codes** 1720 1721For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1722 1723| ID| Error Message| 1724| ------- | -------------------------------------------- | 1725| 202 | Permission verification failed. A non-system application calls a system API. | 1726| 401 | Parameter error. Possible cause: Incorrect parameter types. | 1727| 1300002 | This window state is abnormal. | 1728| 1300003 | This window manager service works abnormally. | 1729 1730**Example** 1731 1732```ts 1733import { dialogRequest, Want, ServiceExtensionAbility } from '@kit.AbilityKit'; 1734import { BusinessError } from '@kit.BasicServicesKit'; 1735 1736export default class ServiceExtAbility extends ServiceExtensionAbility { 1737 onRequest(want: Want, startId: number) { 1738 console.info('onRequest'); 1739 let config: window.Configuration = { 1740 name: "test", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context 1741 }; 1742 try { 1743 window.createWindow(config, (err: BusinessError, data) => { 1744 let errCode: number = err?.code; 1745 if (errCode) { 1746 console.error(`Failed to create the window. Cause code: ${err?.code}, message: ${err?.message}`); 1747 return; 1748 } 1749 if (!data) { 1750 console.error('data is null'); 1751 return; 1752 } 1753 let requestInfo = dialogRequest.getRequestInfo(want); 1754 data.bindDialogTarget(requestInfo, () => { 1755 console.info('Dialog Window Need Destroy.'); 1756 }, (err: BusinessError) => { 1757 let errCode: number = err?.code; 1758 if (errCode) { 1759 console.error(`Failed to bind dialog target. Cause code: ${err?.code}, message: ${err?.message}`); 1760 return; 1761 } 1762 console.info('Succeeded in binding dialog target.'); 1763 }); 1764 }); 1765 } catch (err) { 1766 console.error(`Failed to bind dialog target. Cause code: ${err?.code}, message: ${err?.message}`) 1767 } 1768 } 1769} 1770``` 1771 1772### bindDialogTarget<sup>9+</sup> 1773 1774bindDialogTarget(requestInfo: dialogRequest.RequestInfo, deathCallback: Callback<void>): Promise<void> 1775 1776Binds the modal window to the target window, and adds a callback to listen for modal window destruction events. This API uses a promise to return the result. 1777 1778**System API**: This is a system API. 1779 1780**System capability**: SystemCapability.WindowManager.WindowManager.Core 1781 1782**Parameters** 1783 1784| Name | Type | Mandatory| Description | 1785| ----------- | ------------------------- | ---- | -------------------- | 1786| requestInfo | [dialogRequest.RequestInfo](../apis-ability-kit/js-apis-app-ability-dialogRequest.md#requestinfo) | Yes | **RequestInfo** of the target window.| 1787| deathCallback | Callback<void> | Yes | Callback used to listen for modal window destruction events.| 1788 1789**Return value** 1790 1791| Type | Description | 1792| ------------------- | ------------------------- | 1793| Promise<void> | Promise that returns no value.| 1794 1795**Error codes** 1796 1797For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1798 1799| ID| Error Message| 1800| ------- | -------------------------------------------- | 1801| 202 | Permission verification failed. A non-system application calls a system API. | 1802| 401 | Parameter error. Possible cause: Incorrect parameter types. | 1803| 1300002 | This window state is abnormal. | 1804| 1300003 | This window manager service works abnormally. | 1805 1806**Example** 1807 1808```ts 1809import { dialogRequest, Want, ServiceExtensionAbility } from '@kit.AbilityKit'; 1810import { BusinessError } from '@kit.BasicServicesKit'; 1811 1812export default class ServiceExtAbility extends ServiceExtensionAbility { 1813 onRequest(want: Want, startId: number) { 1814 console.info('onRequest'); 1815 let config: window.Configuration = { 1816 name: "test", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context 1817 }; 1818 try { 1819 window.createWindow(config, (err: BusinessError, data) => { 1820 const errCode: number = err?.code; 1821 if (errCode) { 1822 console.error(`Failed to create the window. Cause code: ${err?.code}, message: ${err?.message}`); 1823 return; 1824 } 1825 if (!data) { 1826 console.error('data is null'); 1827 return; 1828 } 1829 let requestInfo = dialogRequest.getRequestInfo(want); 1830 let promise = data.bindDialogTarget(requestInfo, () => { 1831 console.info('Dialog Window Need Destroy.'); 1832 }); 1833 promise.then(() => { 1834 console.info('Succeeded in binding dialog target.'); 1835 }).catch((err: BusinessError) => { 1836 console.error(`Failed to bind dialog target. Cause code: ${err?.code}, message: ${err?.message}`); 1837 }); 1838 }); 1839 } catch (err) { 1840 console.error(`Failed to bind dialog target. Cause code: ${err?.code}, message: ${err?.message}`) 1841 } 1842 } 1843} 1844``` 1845 1846### setWakeUpScreen<sup>9+</sup> 1847 1848setWakeUpScreen(wakeUp: boolean): void 1849 1850Wakes up the screen. 1851 1852**System API**: This is a system API. 1853 1854**System capability**: SystemCapability.WindowManager.WindowManager.Core 1855 1856**Parameters** 1857 1858| Name | Type | Mandatory| Description | 1859| ---------------- | ------- | ---- | ---------------------------- | 1860| wakeUp | boolean | Yes | Whether to wake up the screen. **true** to wake up, **false** otherwise. | 1861 1862**Error codes** 1863 1864For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1865 1866| ID| Error Message| 1867| ------- | -------------------------------------------- | 1868| 202 | Permission verification failed. A non-system application calls a system API. | 1869| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 1870| 1300002 | This window state is abnormal. | 1871| 1300003 | This window manager service works abnormally. | 1872 1873**Example** 1874 1875```ts 1876let wakeUp: boolean = true; 1877try { 1878 windowClass.setWakeUpScreen(wakeUp); 1879} catch (exception) { 1880 console.error(`Failed to wake up the screen. Cause code: ${exception.code}, message: ${exception.message}`); 1881} 1882``` 1883 1884### setSnapshotSkip<sup>9+</sup> 1885setSnapshotSkip(isSkip: boolean): void 1886 1887Sets whether to ignore this window during screen capture, recording, or casting. This API is typically used in situations where you want to prevent screen capture, recording, or casting. 1888 1889If you want the window to always be ignored during screen capture, recording, or casting while it is in the foreground, listen for window lifecycle changes using [on('windowEvent')](arkts-apis-window-Window.md#onwindowevent10). Set **isSkip** to **false** when the window is in the background and **true** when it is in the foreground. 1890 1891**System API**: This is a system API. 1892 1893**System capability**: SystemCapability.WindowManager.WindowManager.Core 1894 1895**Parameters** 1896 1897| Name | Type | Mandatory| Description | 1898| ------------- | ------- | ---- | -------------------- | 1899| isSkip | boolean | Yes | Whether to ignore the window. The default value is **false**. **true** to ignore, **false** otherwise.<br>| 1900 1901**Error codes** 1902 1903For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1904 1905| ID| Error Message| 1906| ------- | ------------------------------ | 1907| 202 | Permission verification failed. A non-system application calls a system API. | 1908| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 1909| 1300002 | This window state is abnormal. | 1910 1911```ts 1912let isSkip: boolean = true; 1913try { 1914 windowClass.setSnapshotSkip(isSkip); 1915} catch (exception) { 1916 console.error(`Failed to Skip. Cause code: ${exception.code}, message: ${exception.message}`); 1917} 1918``` 1919 1920### setForbidSplitMove<sup>9+</sup> 1921 1922setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void 1923 1924Sets whether the main window is forbidden to move in split-screen mode. This API uses an asynchronous callback to return the result. 1925 1926**System API**: This is a system API. 1927 1928**System capability**: SystemCapability.WindowManager.WindowManager.Core 1929 1930**Parameters** 1931 1932| Name | Type | Mandatory| Description | 1933| ----------- | ------------------------- | ---- | -------------------- | 1934| isForbidSplitMove | boolean | Yes | Whether the window is forbidden to move in split-screen mode. **true** if forbidden, **false** otherwise.| 1935| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1936 1937**Error codes** 1938 1939For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1940 1941| ID| Error Message| 1942| ------- | -------------------------------------------- | 1943| 202 | Permission verification failed. A non-system application calls a system API. | 1944| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 1945| 1300002 | This window state is abnormal. | 1946| 1300003 | This window manager service works abnormally. | 1947 1948**Example** 1949 1950```ts 1951// EntryAbility.ets 1952import { UIAbility } from '@kit.AbilityKit'; 1953import { BusinessError } from '@kit.BasicServicesKit'; 1954 1955export default class EntryAbility extends UIAbility { 1956 // ... 1957 onWindowStageCreate(windowStage: window.WindowStage): void { 1958 console.info('onWindowStageCreate'); 1959 let windowClass: window.Window | undefined = undefined; 1960 windowStage.getMainWindow((err: BusinessError, data) => { 1961 const errCode: number = err.code; 1962 if (errCode) { 1963 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 1964 return; 1965 } 1966 windowClass = data; 1967 let isForbidSplitMove: boolean = true; 1968 try { 1969 windowClass.setForbidSplitMove(isForbidSplitMove, (err: BusinessError) => { 1970 const errCode: number = err.code; 1971 if (errCode) { 1972 console.error(`Failed to forbid window moving in split screen mode. Cause code: ${err.code}, message: ${err.message}`); 1973 return; 1974 } 1975 console.info('Succeeded in forbidding window moving in split screen mode.'); 1976 }); 1977 } catch (exception) { 1978 console.error(`Failed to forbid window moving in split screen mode. Cause code: ${exception.code}, message: ${exception.message}`); 1979 } 1980 }); 1981 } 1982} 1983``` 1984 1985### setForbidSplitMove<sup>9+</sup> 1986 1987setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> 1988 1989Sets whether the main window is forbidden to move in split-screen mode. This API uses a promise to return the result. 1990 1991**System API**: This is a system API. 1992 1993**System capability**: SystemCapability.WindowManager.WindowManager.Core 1994 1995**Parameters** 1996 1997| Name | Type | Mandatory| Description | 1998| ----------- | ------- | ---- | -------------------- | 1999| isForbidSplitMove | boolean | Yes | Whether the window is forbidden to move in split-screen mode. **true** if forbidden, **false** otherwise.| 2000 2001**Return value** 2002 2003| Type | Description | 2004| ------------------- | ------------------------- | 2005| Promise<void> | Promise that returns no value.| 2006 2007**Error codes** 2008 2009For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2010 2011| ID| Error Message| 2012| ------- | -------------------------------------------- | 2013| 202 | Permission verification failed. A non-system application calls a system API. | 2014| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2015| 1300002 | This window state is abnormal. | 2016| 1300003 | This window manager service works abnormally. | 2017 2018**Example** 2019 2020```ts 2021// EntryAbility.ets 2022import { UIAbility } from '@kit.AbilityKit'; 2023import { BusinessError } from '@kit.BasicServicesKit'; 2024 2025export default class EntryAbility extends UIAbility { 2026 // ... 2027 onWindowStageCreate(windowStage: window.WindowStage): void { 2028 console.info('onWindowStageCreate'); 2029 let windowClass: window.Window | undefined = undefined; 2030 windowStage.getMainWindow((err: BusinessError, data) => { 2031 const errCode: number = err.code; 2032 if (errCode) { 2033 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 2034 return; 2035 } 2036 windowClass = data; 2037 let isForbidSplitMove: boolean = true; 2038 try { 2039 let promise = windowClass.setForbidSplitMove(isForbidSplitMove); 2040 promise.then(() => { 2041 console.info('Succeeded in forbidding window moving in split screen mode.'); 2042 }).catch((err: BusinessError) => { 2043 console.error(`Failed to forbid window moving in split screen mode. Cause code: ${err.code}, message: ${err.message}`); 2044 }); 2045 } catch (exception) { 2046 console.error(`Failed to forbid window moving in split screen mode. Cause code: ${exception.code}, message: ${exception.message}`); 2047 } 2048 }); 2049 } 2050} 2051``` 2052 2053### opacity<sup>9+</sup> 2054 2055opacity(opacity: number): void 2056 2057Sets the opacity for this window. This API can be used only when you [customize an animation to be played during the display or hiding of a system window](../../windowmanager/system-window-stage.md#customizing-an-animation-to-be-played-during-the-display-or-hiding-of-a-system-window). 2058 2059**System API**: This is a system API. 2060 2061**System capability**: SystemCapability.WindowManager.WindowManager.Core 2062 2063**Parameters** 2064 2065| Name | Type | Mandatory| Description | 2066| ------- | ------ | ---- |----------------------------------------------------| 2067| opacity | number | Yes | Opacity. The value is a floating-point number in the range [0.0, 1.0]. The value **0.0** means completely transparent, and **1.0** means completely opaque.| 2068 2069**Error codes** 2070 2071For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2072 2073| ID| Error Message| 2074| ------- | ------------------------------ | 2075| 202 | Permission verification failed. A non-system application calls a system API. | 2076| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2077| 1300002 | This window state is abnormal. | 2078| 1300004 | Unauthorized operation. | 2079 2080**Example** 2081 2082```ts 2083try { 2084 windowClass.opacity(0.5); 2085} catch (exception) { 2086 console.error(`Failed to opacity. Cause code: ${exception.code}, message: ${exception.message}`); 2087} 2088``` 2089 2090### scale<sup>9+</sup> 2091 2092scale(scaleOptions: ScaleOptions): void 2093 2094Sets the scale parameters for this window. This API can be used only when you [customize an animation to be played during the display or hiding of a system window](../../windowmanager/system-window-stage.md#customizing-an-animation-to-be-played-during-the-display-or-hiding-of-a-system-window). 2095 2096**System API**: This is a system API. 2097 2098**System capability**: SystemCapability.WindowManager.WindowManager.Core 2099 2100**Parameters** 2101 2102| Name | Type | Mandatory| Description | 2103| ------------ | ------------------------------ | ---- | ---------- | 2104| scaleOptions | [ScaleOptions](#scaleoptions9) | Yes | Scale parameters to set.| 2105 2106**Error codes** 2107 2108For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2109 2110| ID| Error Message| 2111| ------- | ------------------------------ | 2112| 202 | Permission verification failed. A non-system application calls a system API. | 2113| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2114| 1300002 | This window state is abnormal. | 2115| 1300004 | Unauthorized operation. | 2116 2117**Example** 2118 2119```ts 2120let obj: window.ScaleOptions = { 2121 x: 2.0, 2122 y: 1.0, 2123 pivotX: 0.5, 2124 pivotY: 0.5 2125}; 2126try { 2127 windowClass.scale(obj); 2128} catch (exception) { 2129 console.error(`Failed to scale. Cause code: ${exception.code}, message: ${exception.message}`); 2130} 2131``` 2132 2133### rotate<sup>9+</sup> 2134 2135rotate(rotateOptions: RotateOptions): void 2136 2137Sets the rotation parameters for this window. This API can be used only when you [customize an animation to be played during the display or hiding of a system window](../../windowmanager/system-window-stage.md#customizing-an-animation-to-be-played-during-the-display-or-hiding-of-a-system-window). 2138 2139**System API**: This is a system API. 2140 2141**System capability**: SystemCapability.WindowManager.WindowManager.Core 2142 2143**Parameters** 2144 2145| Name | Type | Mandatory| Description | 2146| ------------- | -------------------------------- | ---- | ---------- | 2147| rotateOptions | [RotateOptions](#rotateoptions9) | Yes | Rotation parameters to set.| 2148 2149**Error codes** 2150 2151For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2152 2153| ID| Error Message| 2154| ------- | ------------------------------ | 2155| 202 | Permission verification failed. A non-system application calls a system API. | 2156| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2157| 1300002 | This window state is abnormal. | 2158| 1300004 | Unauthorized operation. | 2159 2160**Example** 2161 2162```ts 2163let obj: window.RotateOptions = { 2164 x: 1.0, 2165 y: 1.0, 2166 z: 45.0, 2167 pivotX: 0.5, 2168 pivotY: 0.5 2169}; 2170try { 2171 windowClass.rotate(obj); 2172} catch (exception) { 2173 console.error(`Failed to rotate. Cause code: ${exception.code}, message: ${exception.message}`); 2174} 2175``` 2176 2177### translate<sup>9+</sup> 2178 2179translate(translateOptions: TranslateOptions): void 2180 2181Sets the translation parameters for this window. This API can be used only when you [customize an animation to be played during the display or hiding of a system window](../../windowmanager/system-window-stage.md#customizing-an-animation-to-be-played-during-the-display-or-hiding-of-a-system-window). 2182 2183**System API**: This is a system API. 2184 2185**System capability**: SystemCapability.WindowManager.WindowManager.Core 2186 2187**Parameters** 2188 2189| Name | Type | Mandatory| Description | 2190| ---------------- | -------------------------------------- | ---- | -------------------- | 2191| translateOptions | [TranslateOptions](#translateoptions9) | Yes | Translation parameters. The unit is px.| 2192 2193**Error codes** 2194 2195For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2196 2197| ID| Error Message| 2198| ------- | ------------------------------ | 2199| 202 | Permission verification failed. A non-system application calls a system API. | 2200| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2201| 1300002 | This window state is abnormal. | 2202| 1300004 | Unauthorized operation. | 2203 2204**Example** 2205 2206```ts 2207let obj: window.TranslateOptions = { 2208 x: 100.0, 2209 y: 0.0, 2210 z: 0.0 2211}; 2212try { 2213 windowClass.translate(obj); 2214} catch (exception) { 2215 console.error(`Failed to translate. Cause code: ${exception.code}, message: ${exception.message}`); 2216} 2217``` 2218 2219### getTransitionController<sup>9+</sup> 2220 2221 getTransitionController(): TransitionController 2222 2223Obtains the transition animation controller. 2224 2225**System API**: This is a system API. 2226 2227**System capability**: SystemCapability.WindowManager.WindowManager.Core 2228 2229**Return value** 2230 2231| Type | Description | 2232| ---------------------------------------------- | ---------------- | 2233| [TransitionController](#transitioncontroller9) | Transition animation controller.| 2234 2235**Error codes** 2236 2237For details about the error codes, see [Window Error Codes](errorcode-window.md). 2238 2239| ID| Error Message| 2240| ------- | ------------------------------ | 2241| 202 | Permission verification failed. A non-system application calls a system API. | 2242| 1300002 | This window state is abnormal. | 2243| 1300004 | Unauthorized operation. | 2244 2245**Example** 2246 2247```ts 2248let controller = windowClass.getTransitionController(); // Obtain the transition animation controller. 2249``` 2250 2251### setBlur<sup>9+</sup> 2252 2253setBlur(radius: number): void 2254 2255Blurs this window. 2256 2257**System API**: This is a system API. 2258 2259**System capability**: SystemCapability.WindowManager.WindowManager.Core 2260 2261**Parameters** 2262 2263| Name| Type | Mandatory| Description | 2264| ------ | ------ | ---- |--------------------------------------------------| 2265| radius | number | Yes | Radius of the blur. The value is a floating-point number greater than or equal to 0.0, in px. The value **0.0** means that the blur is disabled for the window.| 2266 2267**Error codes** 2268 2269For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2270 2271| ID| Error Message| 2272| ------- | ------------------------------ | 2273| 202 | Permission verification failed. A non-system application calls a system API. | 2274| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2275| 1300002 | This window state is abnormal. | 2276| 1300004 | Unauthorized operation. | 2277 2278**Example** 2279 2280```ts 2281try { 2282 windowClass.setBlur(4.0); 2283} catch (exception) { 2284 console.error(`Failed to set blur. Cause code: ${exception.code}, message: ${exception.message}`); 2285} 2286``` 2287 2288### setBackdropBlur<sup>9+</sup> 2289 2290setBackdropBlur(radius: number): void 2291 2292Blurs the background of this window. 2293 2294The window background refers to the lower-layer area covered by the window, which is the same as the window size. 2295 2296To make the blur effect visible, you must set the window background transparent by calling [setWindowBackgroundColor](arkts-apis-window-Window.md#setwindowbackgroundcolor9). 2297 2298**System API**: This is a system API. 2299 2300**System capability**: SystemCapability.WindowManager.WindowManager.Core 2301 2302**Parameters** 2303 2304| Name| Type | Mandatory| Description | 2305| ------ | ------ | ---- |-------------------------------------------------------| 2306| radius | number | Yes | Radius of the blur. The value is a floating-point number greater than or equal to 0.0, in px. The value **0.0** means that the blur is disabled for the background of the window.| 2307 2308**Error codes** 2309 2310For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2311 2312| ID| Error Message| 2313| ------- | ------------------------------ | 2314| 202 | Permission verification failed. A non-system application calls a system API. | 2315| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2316| 1300002 | This window state is abnormal. | 2317| 1300004 | Unauthorized operation. | 2318 2319**Example** 2320 2321```ts 2322try { 2323 windowClass.setWindowBackgroundColor('#00FFFFFF'); 2324 windowClass.setBackdropBlur(4.0); 2325} catch (exception) { 2326 console.error(`Failed to set backdrop blur. Cause code: ${exception.code}, message: ${exception.message}`); 2327} 2328``` 2329 2330### setBackdropBlurStyle<sup>9+</sup> 2331 2332setBackdropBlurStyle(blurStyle: BlurStyle): void 2333 2334Sets the blur style for the background of this window. 2335 2336**System API**: This is a system API. 2337 2338**System capability**: SystemCapability.WindowManager.WindowManager.Core 2339 2340**Parameters** 2341 2342| Name | Type | Mandatory| Description | 2343| --------- | --------- | ---- | ---------------------- | 2344| blurStyle | [BlurStyle](#blurstyle9) | Yes | Blur style to set for the background of the window.| 2345 2346**Error codes** 2347 2348For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2349 2350| ID| Error Message| 2351| ------- | ------------------------------ | 2352| 202 | Permission verification failed. A non-system application calls a system API. | 2353| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2354| 1300002 | This window state is abnormal. | 2355| 1300004 | Unauthorized operation. | 2356 2357**Example** 2358 2359```ts 2360try { 2361 windowClass.setBackdropBlurStyle(window.BlurStyle.THIN); 2362} catch (exception) { 2363 console.error(`Failed to set backdrop blur style. Cause code: ${exception.code}, message: ${exception.message}`); 2364} 2365``` 2366 2367### setShadow<sup>9+</sup> 2368 2369setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void 2370 2371Sets the shadow for the window borders. 2372 2373**System API**: This is a system API. 2374 2375**System capability**: SystemCapability.WindowManager.WindowManager.Core 2376 2377**Parameters** 2378 2379| Name | Type | Mandatory| Description | 2380| ------- | ------ | ---- |-------------------------------------------------------------| 2381| radius | number | Yes | Radius of the shadow. The value is a floating-point number greater than or equal to 0.0, in px. The value **0.0** means that the shadow is disabled for the window borders. | 2382| color | string | No | Color of the shadow. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**.| 2383| offsetX | number | No | Offset of the shadow along the x-axis, in px. The value is a floating-point number. | 2384| offsetY | number | No | Offset of the shadow along the y-axis, in px. The value is a floating-point number. | 2385 2386**Error codes** 2387 2388For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2389 2390| ID| Error Message| 2391| ------- | ------------------------------ | 2392| 202 | Permission verification failed. A non-system application calls a system API. | 2393| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2394| 1300002 | This window state is abnormal. | 2395| 1300004 | Unauthorized operation. | 2396 2397**Example** 2398 2399```ts 2400try { 2401 windowClass.setShadow(4.0, '#FF00FF00', 2, 3); 2402} catch (exception) { 2403 console.error(`Failed to set shadow. Cause code: ${exception.code}, message: ${exception.message}`); 2404} 2405``` 2406 2407### setCornerRadius<sup>9+</sup> 2408 2409setCornerRadius(cornerRadius: number): void 2410 2411Sets the radius of the rounded corners for this window. 2412 2413**System API**: This is a system API. 2414 2415**System capability**: SystemCapability.WindowManager.WindowManager.Core 2416 2417**Parameters** 2418 2419| Name | Type | Mandatory| Description | 2420| ----------- | ------- | ---- |----------------------------------------------------| 2421| cornerRadius | number | Yes | Radius of the rounded corners. The value is a floating-point number greater than or equal to 0.0, in px. The value **0.0** means that the window does not use rounded corners.| 2422 2423**Error codes** 2424 2425For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2426 2427| ID| Error Message| 2428| ------- | ------------------------------ | 2429| 202 | Permission verification failed. A non-system application calls a system API. | 2430| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2431| 1300002 | This window state is abnormal. | 2432| 1300004 | Unauthorized operation. | 2433 2434**Example** 2435 2436```ts 2437try { 2438 windowClass.setCornerRadius(4.0); 2439} catch (exception) { 2440 console.error(`Failed to set corner radius. Cause code: ${exception.code}, message: ${exception.message}`); 2441} 2442``` 2443 2444### setTouchableAreas<sup>12+</sup> 2445 2446setTouchableAreas(rects: Array<Rect>): void 2447 2448Sets the touchable areas for this window. By default, the entire window is touchable. If a touchable area is set, touch events outside this area are transparently transmitted. The setting becomes invalid after the window rectangle changes. 2449 2450**System API**: This is a system API. 2451 2452**System capability**: SystemCapability.Window.SessionManager 2453 2454**Parameters** 2455 2456| Name | Type | Mandatory| Description | 2457| -------- | ------------------------- | ---- | ---------- | 2458| rects | Array<[Rect](arkts-apis-window-i.md#rect7)> | Yes | Touchable areas. The maximum number of touchable areas cannot exceed 10, and each touchable area cannot exceed the window area.| 2459 2460**Error codes** 2461 2462For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2463 2464| ID| Error Message| 2465| ------- | ------------------------------ | 2466| 202 | Permission verification failed. A non-system application calls a system API. | 2467| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2468| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 2469| 1300002 | This window state is abnormal. | 2470| 1300003 | This window manager service works abnormally. | | 2471 2472**Example** 2473 2474```ts 2475try { 2476 windowClass.setTouchableAreas([{left: 100, top: 100, width: 200, height:200}, 2477 {left: 400, top: 100, width: 200, height:200}]); 2478} catch (exception) { 2479 console.error(`Failed to set touchable areas. Cause code: ${exception.code}, message: ${exception.message}`); 2480} 2481``` 2482 2483### raiseToAppTop<sup>10+</sup> 2484 2485raiseToAppTop(callback: AsyncCallback<void>): void 2486 2487Raises the application child window to the top layer of the application. This API uses an asynchronous callback to return the result. 2488 2489Before calling this API, ensure that the child window has been created and [showWindow()](arkts-apis-window-Window.md#showwindow9) has been successfully executed. 2490 2491**System API**: This is a system API. 2492 2493**System capability**: SystemCapability.WindowManager.WindowManager.Core 2494 2495**Parameters** 2496 2497| Name | Type | Mandatory| Description | 2498| -------- | ------------------------- | ---- | ---------- | 2499| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 2500 2501**Error codes** 2502 2503For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2504 2505| ID| Error Message| 2506| ------- | ------------------------------ | 2507| 202 | Permission verification failed. A non-system application calls a system API. | 2508| 1300002 | This window state is abnormal. | 2509| 1300003 | This window manager service works abnormally. | 2510| 1300004 | Unauthorized operation. | 2511| 1300009 | The parent window is invalid. | 2512 2513**Example** 2514 2515```ts 2516// EntryAbility.ets 2517import { window } from '@kit.ArkUI'; 2518import { UIAbility } from '@kit.AbilityKit'; 2519import { BusinessError } from '@kit.BasicServicesKit'; 2520 2521export default class EntryAbility extends UIAbility { 2522 // ... 2523 onWindowStageCreate(windowStage: window.WindowStage): void { 2524 console.info('onWindowStageCreate'); 2525 // Create a child window. 2526 windowStage.createSubWindow('testSubWindow').then((subWindow) => { 2527 if (subWindow == null) { 2528 console.error('Failed to create the subWindow. Cause: The data is empty'); 2529 return; 2530 } 2531 subWindow.showWindow().then(() => { 2532 subWindow.raiseToAppTop((err: BusinessError) => { 2533 const errCode: number = err.code; 2534 if (errCode) { 2535 console.error(`Failed to raise the window to app top. Cause code: ${err.code}, message: ${err.message}`); 2536 return; 2537 } 2538 console.info('Succeeded in raising the window to app top.'); 2539 }); 2540 }); 2541 }); 2542 } 2543} 2544``` 2545 2546### setWaterMarkFlag<sup>10+</sup> 2547 2548setWaterMarkFlag(enable: boolean): Promise<void> 2549 2550Adds or deletes the watermark flag for this window. This API uses a promise to return the result. 2551 2552**System API**: This is a system API. 2553 2554**System capability**: SystemCapability.WindowManager.WindowManager.Core 2555 2556**Parameters** 2557 2558| Name| Type | Mandatory| Description | 2559| ------ | ------- | --- | ------------------------------------------------ | 2560| enable | boolean | Yes | Whether to add or delete the flag. **true** to add, **false** otherwise.| 2561 2562**Return value** 2563 2564| Type | Description | 2565| ------------------- | ------------------------- | 2566| Promise<void> | Promise that returns no value.| 2567 2568**Error codes** 2569 2570For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2571 2572| ID| Error Message| 2573| ------- | ---------------------------------------------- | 2574| 202 | Permission verification failed. A non-system application calls a system API. | 2575| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 2576| 1300002 | This window state is abnormal. | 2577| 1300003 | This window manager service works abnormally. | 2578| 1300008 | The display device is abnormal. | 2579 2580**Example** 2581 2582```ts 2583import { BusinessError } from '@kit.BasicServicesKit'; 2584 2585try { 2586 let enable = true; 2587 let promise = windowClass.setWaterMarkFlag(enable); 2588 promise.then(() => { 2589 console.info('Succeeded in setting water mark flag of window.'); 2590 }).catch((err: BusinessError) => { 2591 console.error(`Failed to set water mark flag of window. Cause code: ${err.code}, message: ${err.message}`); 2592 }); 2593} catch (exception) { 2594 console.error(`Failed to set water mark flag of window. Cause code: ${exception.code}, message: ${exception.message}`); 2595} 2596``` 2597 2598### setWaterMarkFlag<sup>10+</sup> 2599 2600setWaterMarkFlag(enable: boolean, callback: AsyncCallback<void>): void 2601 2602Adds or deletes the watermark flag for this window. This API uses an asynchronous callback to return the result. 2603 2604**System API**: This is a system API. 2605 2606**System capability**: SystemCapability.WindowManager.WindowManager.Core 2607 2608**Parameters** 2609 2610| Name | Type | Mandatory| Description | 2611| -------- | ------------------------- | --- | ----------------------------------------------- | 2612| enable | boolean | Yes | Whether to add or delete the flag. **true** to add, **false** otherwise.| 2613| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 2614 2615**Error codes** 2616 2617For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2618 2619| ID| Error Message| 2620| ------- | ---------------------------------------------- | 2621| 202 | Permission verification failed. A non-system application calls a system API. | 2622| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 2623| 1300002 | This window state is abnormal. | 2624| 1300003 | This window manager service works abnormally. | 2625| 1300008 | The display device is abnormal. | 2626 2627**Example** 2628 2629```ts 2630import { BusinessError } from '@kit.BasicServicesKit'; 2631 2632try { 2633 let enable: boolean = true; 2634 windowClass.setWaterMarkFlag(enable, (err: BusinessError) => { 2635 const errCode: number = err.code; 2636 if (errCode) { 2637 console.error(`Failed to set water mark flag of window. Cause code: ${err.code}, message: ${err.message}`); 2638 return; 2639 } 2640 console.info('Succeeded in setting water mark flag of window.'); 2641 }); 2642} catch (exception) { 2643 console.error(`Failed to set water mark flag of window. Cause code: ${exception.code}, message: ${exception.message}`); 2644} 2645``` 2646 2647### setHandwritingFlag<sup>12+</sup> 2648 2649setHandwritingFlag(enable: boolean): Promise<void> 2650 2651Adds or deletes the handwriting flag for this window. After this flag is added, the window responds to stylus events but not touch events. This API uses a promise to return the result. 2652 2653**System API**: This is a system API. 2654 2655**System capability**: SystemCapability.Window.SessionManager 2656 2657**Parameters** 2658 2659| Name| Type | Mandatory| Description | 2660| ------ | ------- | --- | ------------------------------------------------ | 2661| enable | boolean | Yes | Whether to add or delete the flag. **true** to add, **false** otherwise.| 2662 2663**Return value** 2664 2665| Type | Description | 2666| ------------------- | ------------------------- | 2667| Promise<void> | Promise that returns no value.| 2668 2669**Error codes** 2670 2671For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2672 2673| ID| Error Message| 2674| ------- | -------------------------------------------- | 2675| 202 | Permission verification failed. A non-system application calls a system API. | 2676| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2677| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 2678| 1300002 | This window state is abnormal. | 2679| 1300003 | This window manager service works abnormally. | 2680 2681**Example** 2682 2683```ts 2684import { BusinessError } from '@kit.BasicServicesKit'; 2685 2686try { 2687 let enable = true; 2688 let promise = windowClass.setHandwritingFlag(enable); 2689 promise.then(() => { 2690 console.info('Succeeded in setting handwriting flag of window.'); 2691 }).catch((err: BusinessError) => { 2692 console.error(`Failed to set handwriting flag of window. Cause code: ${err.code}, message: ${err.message}`); 2693 }); 2694} catch (exception) { 2695 console.error(`Failed to set handwriting flag of window. Cause code: ${exception.code}, message: ${exception.message}`); 2696} 2697``` 2698 2699### raiseAboveTarget<sup>10+</sup> 2700 2701raiseAboveTarget(windowId: number, callback: AsyncCallback<void>): void 2702 2703Raises a child window above a target child window. This API uses an asynchronous callback to return the result. 2704 2705Before calling this API, ensure that the child window to raise and the target child window have been created and [showWindow()](arkts-apis-window-Window.md#showwindow9) has been successfully executed for each. 2706 2707**System API**: This is a system API. 2708 2709**System capability**: SystemCapability.Window.SessionManager 2710 2711**Parameters** 2712 2713| Name | Type | Mandatory| Description | 2714| -------- | ------------------------- | ---- | ---------- | 2715| windowId | number | Yes | ID of the target child window, which is the value of **properties.id** in [properties](arkts-apis-window-i.md#windowproperties) obtained through [getWindowProperties](arkts-apis-window-Window.md#getwindowproperties9).| 2716| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 2717 2718**Error codes** 2719 2720For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2721 2722| ID| Error Message| 2723| ------- | ---------------------------------------------- | 2724| 202 | Permission verification failed. A non-system application calls a system API. | 2725| 401 | Parameter error. Possible cause: Mandatory parameters are left unspecified. | 2726| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 2727| 1300002 | This window state is abnormal. | 2728| 1300003 | This window manager service works abnormally. | 2729| 1300004 | Unauthorized operation. | 2730| 1300009 | The parent window is invalid. | 2731 2732**Example** 2733 2734```ts 2735// EntryAbility.ets 2736import { window } from '@kit.ArkUI'; 2737import { UIAbility } from '@kit.AbilityKit'; 2738import { BusinessError } from '@kit.BasicServicesKit'; 2739 2740export default class EntryAbility extends UIAbility { 2741 // ... 2742 onWindowStageCreate(windowStage: window.WindowStage): void { 2743 console.info('onWindowStageCreate'); 2744 let windowClass: window.Window; 2745 // Create a child window. 2746 try { 2747 windowStage.createSubWindow("testSubWindow").then((data) => { 2748 if (data == null) { 2749 console.error("Failed to create the subWindow. Cause: The data is empty"); 2750 return; 2751 } 2752 windowClass = data; 2753 windowClass.showWindow().then(() => { 2754 // The windowClass must be obtained above the targetWindow. 2755 let targetWindow: window.Window = windowClass; 2756 let properties = targetWindow.getWindowProperties(); 2757 let targetId = properties.id; 2758 windowClass.raiseAboveTarget(targetId, (err: BusinessError) => { 2759 if (err.code) { 2760 console.error(`Failed to raise the subWindow to target subWindow top. Cause code: ${err.code}, message: ${err.message}`); 2761 return; 2762 } 2763 console.info('Succeeded in raising the subWindow to target subWindow top.'); 2764 }); 2765 }); 2766 }); 2767 } catch (exception) { 2768 console.error(`Failed to create the subWindow. Cause code: ${exception.code}, message: ${exception.message}`); 2769 } 2770 } 2771} 2772``` 2773 2774### raiseAboveTarget<sup>10+</sup> 2775 2776raiseAboveTarget(windowId: number): Promise<void> 2777 2778Raises a child window above a target child window. This API uses a promise to return the result. 2779 2780Before calling this API, ensure that the child window to raise and the target child window have been created and [showWindow()](arkts-apis-window-Window.md#showwindow9) has been successfully executed for each. 2781 2782**System API**: This is a system API. 2783 2784**System capability**: SystemCapability.Window.SessionManager 2785 2786**Parameters** 2787 2788| Name | Type | Mandatory| Description | 2789| -------- | ------------------------- | ---- | ---------- | 2790| windowId | number | Yes | ID of the target child window, which is the value of **properties.id** in [properties](arkts-apis-window-i.md#windowproperties) obtained through [getWindowProperties](arkts-apis-window-Window.md#getwindowproperties9).| 2791 2792**Return value** 2793 2794| Type | Description | 2795| ------------------- | ------------------------- | 2796| Promise<void> | Promise that returns no value.| 2797 2798**Error codes** 2799 2800For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2801 2802| ID| Error Message| 2803| ------- | ------------------------------ | 2804| 202 | Permission verification failed. A non-system application calls a system API. | 2805| 401 | Parameter error. Possible cause: Mandatory parameters are left unspecified. | 2806| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 2807| 1300002 | This window state is abnormal. | 2808| 1300003 | This window manager service works abnormally. | 2809| 1300004 | Unauthorized operation. | 2810| 1300009 | The parent window is invalid. | 2811 2812**Example** 2813 2814```ts 2815// EntryAbility.ets 2816import { window } from '@kit.ArkUI'; 2817import { UIAbility } from '@kit.AbilityKit'; 2818import { BusinessError } from '@kit.BasicServicesKit'; 2819 2820export default class EntryAbility extends UIAbility { 2821 // ... 2822 onWindowStageCreate(windowStage: window.WindowStage): void { 2823 console.info('onWindowStageCreate'); 2824 let windowClass: window.Window; 2825 // Create a child window. 2826 try { 2827 windowStage.createSubWindow("testSubWindow").then((data) => { 2828 if (data == null) { 2829 console.error("Failed to create the subWindow. Cause: The data is empty"); 2830 return; 2831 } 2832 windowClass = data; 2833 windowClass.showWindow().then(() => { 2834 // The windowClass must be obtained above the targetWindow. 2835 let targetWindow: window.Window = windowClass; 2836 let properties = targetWindow.getWindowProperties(); 2837 let targetId = properties.id; 2838 windowClass.raiseAboveTarget(targetId).then(()=> { 2839 console.info('Succeeded in raising the subWindow to target subWindow top.'); 2840 }).catch((err: BusinessError)=>{ 2841 console.error(`Failed to raise the subWindow to target subWindow top. Cause code: ${err.code}, message: ${err.message}`); 2842 }); 2843 }); 2844 }); 2845 } catch (exception) { 2846 console.error(`Failed to create the subWindow. Cause code: ${exception.code}, message: ${exception.message}`); 2847 } 2848 } 2849} 2850``` 2851 2852### raiseMainWindowAboveTarget<sup>20+</sup> 2853 2854raiseMainWindowAboveTarget(windowId: number): Promise<void> 2855 2856Moves the main window above another main window within the same application, with child windows following their parents' layer change. This API uses a promise to return the result. 2857 2858This API can be called only by the main window of a system application on 2-in-1 devices. 2859 2860You need to pass the ID of the target main window. Both the calling window and the target window must be in the same application process, displayed on the same physical screen, below the lock screen layer, not topmost, not modal, and have no application-modal child windows. 2861 2862- If the application's main window or its child windows currently have focus, calling this API to lower the layer will cause the window to lose focus automatically, and the highest-layered application window will gain focus. 2863 2864- If the main window calls this API to move above the current focused window, the highest-layered window among the raised main window and its child windows will gain focus. If the main window calls this API without moving above the current focused window, the focus remains unchanged. 2865 2866**System API**: This is a system API. 2867 2868**System capability**: SystemCapability.Window.SessionManager 2869 2870**Parameters** 2871 2872| Name | Type | Mandatory| Description | 2873| -------- | ------------------------- | ---- | ---------- | 2874| windowId | number | Yes | ID of the target main window. The value is an integer. It is the value of **properties.id** in [properties](arkts-apis-window-i.md#windowproperties) obtained through [getWindowProperties](arkts-apis-window-Window.md#getwindowproperties9).| 2875 2876**Return value** 2877 2878| Type | Description | 2879| ------------------- | ------------------------- | 2880| Promise<void> | Promise that returns no value.| 2881 2882**Error codes** 2883 2884For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2885 2886| ID| Error Message| 2887| ------- | ------------------------------ | 2888| 202 | Permission verification failed. A non-system application calls a system API. | 2889| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 2890| 1300002 | This window state is abnormal. | 2891| 1300003 | This window manager service works abnormally. | 2892| 1300004 | Unauthorized operation. | 2893| 1300016 | Parameter error. Possible cause: 1. Invalid Parameter range. 2. Invalid parameter length. | 2894 2895**Example** 2896 2897```ts 2898// EntryAbility.ets 2899import { UIAbility, Want, StartOptions, AbilityConstant } from '@kit.AbilityKit'; 2900import { BusinessError } from '@kit.BasicServicesKit'; 2901 2902export default class EntryAbility extends UIAbility { 2903 onWindowStageCreate(windowStage: window.WindowStage): void { 2904 windowStage.loadContent('pages/Index', (err) => { 2905 if (err.code) { 2906 console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}.`); 2907 return; 2908 } 2909 console.info('Succeeded in loading the content.'); 2910 try { 2911 let want: Want = { 2912 abilityName: "RaiseMainWindowAbility", 2913 bundleName: "com.example.myapplication" 2914 }; 2915 let options: StartOptions = { 2916 windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FLOATING 2917 }; 2918 this.context.startAbility(want, options); 2919 } catch (err) { 2920 console.error(`Failed to start the ability. Cause code: ${err.code}, message: ${err.message}.`); 2921 } 2922 setTimeout(async () => { 2923 let mainWindow: window.Window | null | undefined = windowStage.getMainWindowSync(); 2924 let targetId: number | null | undefined = AppStorage.get('higher_window_id'); 2925 mainWindow.raiseMainWindowAboveTarget(targetId).then(() => { 2926 console.info('Succeeded in raising main window above target.'); 2927 }).catch((err: BusinessError) => { 2928 console.error(`Failed to raise main window above target. Cause code: ${err.code}, message: ${err.message}.`) 2929 }); 2930 }, 3000) 2931 }); 2932 } 2933} 2934``` 2935```ts 2936// Create the RaiseMainWindowAbility.ets file in src/main/ets/raisemainwindowability. 2937import { UIAbility } from '@kit.AbilityKit'; 2938 2939export default class RaiseMainWindowAbility extends UIAbility { 2940 onWindowStageCreate(windowStage: window.WindowStage): void { 2941 AppStorage.setOrCreate('higher_window_id', windowStage.getMainWindowSync().getWindowProperties().id); 2942 windowStage.loadContent('pages/Index', (err) => { 2943 if (err.code) { 2944 console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}.`); 2945 return; 2946 } 2947 console.info('Succeeded in loading the content.'); 2948 }); 2949 } 2950} 2951``` 2952```json5 2953//module.json5 2954{ 2955 "module": { 2956 "name": "entry", 2957 "type": "entry", 2958 "description": "$string:module_desc", 2959 "mainElement": "EntryAbility", 2960 "deviceTypes": [ 2961 "phone", 2962 "tablet", 2963 "2in1" 2964 ], 2965 "deliveryWithInstall": true, 2966 "installationFree": false, 2967 "pages": "$profile:main_pages", 2968 "abilities": [ 2969 { 2970 "name": "EntryAbility", 2971 "srcEntry": "./ets/entryability/EntryAbility.ets", 2972 "description": "$string:EntryAbility_desc", 2973 "icon": "$media:layered_image", 2974 "label": "$string:EntryAbility_label", 2975 "startWindowIcon": "$media:startIcon", 2976 "startWindowBackground": "$color:start_window_background", 2977 "exported": true, 2978 "skills": [ 2979 { 2980 "entities": [ 2981 "entity.system.home" 2982 ], 2983 "actions": [ 2984 "action.system.home" 2985 ] 2986 } 2987 ] 2988 }, 2989 { 2990 "name": "RaiseMainWindowAbility", 2991 "launchType": "multiton", 2992 "srcEntry": "./ets/entryability/EntryAbility.ets", 2993 "description": "$string:EntryAbility_desc", 2994 "icon": "$media:layered_image", 2995 "label": "$string:EntryAbility_label", 2996 "startWindowIcon": "$media:startIcon", 2997 "startWindowBackground": "$color:start_window_background", 2998 "exported": true, 2999 "skills": [ 3000 { 3001 "entities": [ 3002 "entity.system.home" 3003 ], 3004 "actions": [ 3005 "action.system.home" 3006 ] 3007 } 3008 ] 3009 } 3010 ] 3011 } 3012} 3013``` 3014 3015### setRaiseByClickEnabled<sup>10+</sup> 3016 3017setRaiseByClickEnabled(enable: boolean, callback: AsyncCallback<void>): void 3018 3019Sets whether to enable a child window to raise itself by click. This API uses an asynchronous callback to return the result. 3020 3021Generally, when a user clicks a child window, the child window is displayed on the top. If the **enable** parameter is set to **false**, the child window is not displayed on the top when being clicked. 3022 3023Before calling this API, ensure that the child window has been created and [showWindow()](arkts-apis-window-Window.md#showwindow9) has been successfully executed. 3024 3025**System API**: This is a system API. 3026 3027**System capability**: SystemCapability.Window.SessionManager 3028 3029**Parameters** 3030 3031| Name | Type | Mandatory| Description | 3032| -------- | ------------------------- | ---- | ---------- | 3033| enable | boolean | Yes | Whether to enable a child window to raise itself by click. **true** to enable, **false** otherwise.| 3034| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 3035 3036**Error codes** 3037 3038For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3039 3040| ID| Error Message| 3041| ------- | ------------------------------ | 3042| 202 | Permission verification failed. A non-system application calls a system API. | 3043| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3044| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3045| 1300002 | This window state is abnormal. | 3046| 1300003 | This window manager service works abnormally. | 3047| 1300004 | Unauthorized operation. | 3048| 1300009 | The parent window is invalid. | 3049 3050**Example** 3051 3052```ts 3053// EntryAbility.ets 3054import { window } from '@kit.ArkUI'; 3055import { UIAbility } from '@kit.AbilityKit'; 3056import { BusinessError } from '@kit.BasicServicesKit'; 3057 3058export default class EntryAbility extends UIAbility { 3059 // ... 3060 onWindowStageCreate(windowStage: window.WindowStage): void { 3061 console.info('onWindowStageCreate'); 3062 // Create a child window. 3063 windowStage.createSubWindow("testSubWindow").then((subWindow) => { 3064 if (subWindow == null) { 3065 console.error('Failed to create the subWindow. Cause: The data is empty'); 3066 return; 3067 } 3068 subWindow.showWindow().then(() => { 3069 try { 3070 let enabled = false; 3071 subWindow.setRaiseByClickEnabled(enabled, (err) => { 3072 if (err.code) { 3073 console.error(`Failed to disable the raise-by-click function. Cause code: ${err.code}, message: ${err.message}`); 3074 return; 3075 } 3076 console.info('Succeeded in disabling the raise-by-click function.'); 3077 }); 3078 } catch (err) { 3079 console.error(`Failed to disable the raise-by-click function. Cause code: ${err.code}, message: ${err.message}`); 3080 } 3081 }); 3082 }); 3083 } 3084} 3085``` 3086 3087### hideNonSystemFloatingWindows<sup>11+</sup> 3088 3089hideNonSystemFloatingWindows(shouldHide: boolean, callback: AsyncCallback<void>): void 3090 3091Sets whether to hide non-system floating windows. This API takes effect only on non-2-in-1 devices. It uses an asynchronous callback to return the result. 3092 3093A non-system floating window is a floating window created by a non-system application. By default, the main window of a system application can be displayed together with a non-system floating window. This means that the main window may be blocked by an upper-layer non-system floating window. If the **shouldHide** parameter is set to **true**, all non-system floating windows are hidden, so that the main window will never be blocked by a non-system floating window. 3094 3095**System API**: This is a system API. 3096 3097**System capability**: SystemCapability.Window.SessionManager 3098 3099**Parameters** 3100 3101| Name | Type | Mandatory| Description | 3102| ----------- | ------------------------- | ---- | ---------- | 3103| shouldHide | boolean | Yes | Whether to hide non-system floating windows. **true** to hide, **false** otherwise.| 3104| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 3105 3106**Error codes** 3107 3108For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3109 3110| ID| Error Message| 3111| ------- | ------------------------------ | 3112| 202 | Permission verification failed. A non-system application calls a system API. | 3113| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3114| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3115| 1300002 | This window state is abnormal. | 3116| 1300003 | This window manager service works abnormally. | 3117| 1300004 | Unauthorized operation. | 3118 3119**Example** 3120 3121```ts 3122// EntryAbility.ets 3123import { UIAbility, Want } from '@kit.AbilityKit'; 3124 3125export default class EntryAbility extends UIAbility { 3126 onWindowStageCreate(windowStage: window.WindowStage) { 3127 // Load the page corresponding to the main window. 3128 windowStage.loadContent('pages/Index', (err) => { 3129 if (err.code) { 3130 console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}`); 3131 return; 3132 } 3133 console.info('Succeeded in loading the content.'); 3134 }); 3135 3136 // Obtain the main window. 3137 let mainWindow: window.Window | undefined = undefined; 3138 windowStage.getMainWindow((err, data) => { 3139 if (err.code) { 3140 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 3141 return; 3142 } 3143 mainWindow = data; 3144 console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); 3145 3146 let shouldHide = true; 3147 try { 3148 // Call hideNonSystemFloatingWindows with the callback parameter. 3149 mainWindow.hideNonSystemFloatingWindows(shouldHide, (err) => { 3150 if (err.code) { 3151 console.error(`Failed to hide the non-system floating windows. Cause code: ${err.code}, message: ${err.message}`); 3152 return; 3153 } 3154 console.info('Succeeded in hiding the non-system floating windows.'); 3155 }); 3156 } catch (exception) { 3157 console.error(`Failed to hide the non-system floating windows. Cause code: ${exception.code}, message: ${exception.message}`); 3158 } 3159 }); 3160 } 3161} 3162``` 3163 3164### hideNonSystemFloatingWindows<sup>11+</sup> 3165 3166hideNonSystemFloatingWindows(shouldHide: boolean): Promise<void> 3167 3168Sets whether to hide non-system floating windows. This API takes effect only on non-2-in-1 devices. It uses a promise to return the result. 3169 3170A non-system floating window is a floating window created by a non-system application. By default, the main window of a system application can be displayed together with a non-system floating window. This means that the main window may be blocked by an upper-layer non-system floating window. If the **shouldHide** parameter is set to **true**, all non-system floating windows are hidden, so that the main window will never be blocked by a non-system floating window. 3171 3172**System API**: This is a system API. 3173 3174**System capability**: SystemCapability.Window.SessionManager 3175 3176**Parameters** 3177 3178| Name | Type | Mandatory| Description | 3179| ----------- | ------------------------- | ---- | ---------- | 3180| shouldHide | boolean | Yes | Whether to hide non-system floating windows. **true** to hide, **false** otherwise.| 3181 3182**Return value** 3183 3184| Type | Description | 3185| ------------------- | ------------------------- | 3186| Promise<void> | Promise that returns no value.| 3187 3188**Error codes** 3189 3190For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3191 3192| ID| Error Message| 3193| ------- | ------------------------------ | 3194| 202 | Permission verification failed. A non-system application calls a system API. | 3195| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3196| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3197| 1300002 | This window state is abnormal. | 3198| 1300003 | This window manager service works abnormally. | 3199| 1300004 | Unauthorized operation. | 3200 3201**Example** 3202 3203```ts 3204// EntryAbility.ets 3205import { UIAbility, Want } from '@kit.AbilityKit'; 3206import { BusinessError } from '@kit.BasicServicesKit'; 3207 3208export default class EntryAbility extends UIAbility { 3209 onWindowStageCreate(windowStage: window.WindowStage) { 3210 // Load the page corresponding to the main window. 3211 windowStage.loadContent('pages/Index', (err) => { 3212 if (err.code) { 3213 console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}`); 3214 return; 3215 } 3216 console.info('Succeeded in loading the content.'); 3217 }); 3218 3219 // Obtain the main window. 3220 let mainWindow: window.Window | undefined = undefined; 3221 windowStage.getMainWindow((err, data) => { 3222 if (err.code) { 3223 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 3224 return; 3225 } 3226 mainWindow = data; 3227 console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); 3228 3229 let shouldHide = true; 3230 try { 3231 // Call hideNonSystemFloatingWindows to obtain a promise object. 3232 let promise = mainWindow.hideNonSystemFloatingWindows(shouldHide); 3233 promise.then(()=> { 3234 console.info('Succeeded in hiding the non-system floating windows.'); 3235 }).catch((err: BusinessError)=>{ 3236 console.error(`Failed to hide the non-system floating windows. Cause code: ${err.code}, message: ${err.message}`); 3237 }); 3238 } catch (exception) { 3239 console.error(`Failed to hide the non-system floating windows. Cause code: ${exception.code}, message: ${exception.message}`); 3240 } 3241 }); 3242 } 3243} 3244``` 3245 3246### setDefaultDensityEnabled<sup>20+</sup> 3247 3248setDefaultDensityEnabled(enabled: boolean): void 3249 3250Sets whether the window uses the default density of the system. In the stage model, you need to call this API after [loadContent()](arkts-apis-window-Window.md#loadcontent9) or [setUIContent()](arkts-apis-window-Window.md#setuicontent9). 3251 3252If this API is not called, the default density is not used. 3253 3254If this API, [setDefaultDensityEnabled(true)](arkts-apis-window-WindowStage.md#setdefaultdensityenabled12), and [setCustomDensity](arkts-apis-window-WindowStage.md#setCustomDensity15) are all called, the setting from the last called API will be applied. 3255 3256**System API**: This is a system API. 3257 3258**System capability**: SystemCapability.Window.SessionManager 3259 3260**Parameters** 3261 3262| Name | Type | Mandatory| Description | 3263| ---------------- | ------- | ---- | ---------------------------- | 3264| enabled | boolean | Yes | Whether to use the default density of the system. **true** to enable, **false** otherwise. When the default density is enabled, the window layout does not change with the system display size.| 3265 3266**Error codes** 3267 3268For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3269 3270| ID| Error Message| 3271| ------- | ------------------------------ | 3272| 202 | Permission verification failed. A non-system application calls a system API. | 3273| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3274| 1300002 | This window state is abnormal. | 3275 3276**Example** 3277 3278```ts 3279try { 3280 windowClass.setDefaultDensityEnabled(true); 3281 console.info(`Succeeded in setting default density enabled`); 3282} catch (exception) { 3283 console.error(`Failed to set default density enabled. Cause code: ${exception.code}, message: ${exception.message}`); 3284} 3285``` 3286 3287### isMainWindowFullScreenAcrossDisplays<sup>20+</sup> 3288 3289isMainWindowFullScreenAcrossDisplays(): Promise<boolean> 3290 3291Checks whether the main window is in full-screen mode across multiple displays. This API uses a promise to return the result. It takes effect only for the main window and child windows. 3292 3293**System API**: This is a system API. 3294 3295**System capability**: SystemCapability.Window.SessionManager 3296 3297**Return value** 3298 3299| Type | Description | 3300| ------------------- | ------------------------- | 3301| Promise<boolean> | Promise used to return the result indicating whether the main window is in full-screen mode across multiple displays. **true** if yes, **false** otherwise.| 3302 3303**Error codes** 3304 3305For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3306 3307| ID| Error Message| 3308| ------- | ------------------------------ | 3309| 202 | Permission verification failed. A non-system application calls a system API. | 3310| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3311| 1300002 | This window state is abnormal. | 3312| 1300003 | This window manager service works abnormally. | 3313| 1300004 | Unauthorized operation. | 3314 3315**Example** 3316 3317```ts 3318import { BusinessError } from '@kit.BasicServicesKit'; 3319 3320try { 3321 let promise = windowClass.isMainWindowFullScreenAcrossDisplays(); 3322 promise.then((data: boolean)=> { 3323 console.info(`Succeeded in using isMainWindowFullScreenAcrossDisplays function. Data: ${data}`); 3324 }).catch((err: BusinessError)=>{ 3325 console.error(`Failed to use isMainWindowFullScreenAcrossDisplays function. code:${err.code}, message:${err.message}.`); 3326 }); 3327} catch (exception) { 3328 console.error(`Failed to use isMainWindowFullScreenAcrossDisplays function. Cause code: ${exception.code}, message: ${exception.message}.`); 3329} 3330``` 3331 3332### on('mainWindowFullScreenAcrossDisplaysChanged')<sup>20+</sup> 3333 3334on(type: 'mainWindowFullScreenAcrossDisplaysChanged', callback: Callback<boolean>): void 3335 3336Subscribes to events indicating whether the main window is in full-screen mode across multiple displays. 3337 3338**System API**: This is a system API. 3339 3340**System capability**: SystemCapability.Window.SessionManager 3341 3342**Parameters** 3343 3344| Name | Type | Mandatory| Description | 3345| -------- | --------------------------| ---- | ------------------------------------------------------------ | 3346| type | string | Yes | Event type. The value is fixed at **'mainWindowFullScreenAcrossDisplaysChanged'**, indicating changes in whether the main window is in full-screen mode across multiple displays.| 3347| callback | Callback<boolean> | Yes | Callback used to return the result indicating whether the main window is in full-screen mode across multiple displays. **true** if yes, **false** otherwise.| 3348 3349**Error codes** 3350 3351For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3352 3353| ID| Error Message| 3354| ------- | ------------------------------ | 3355| 202 | Permission verification failed. A non-system application calls a system API. | 3356| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3357| 1300002 | This window state is abnormal. | 3358| 1300003 | This window manager service works abnormally. | 3359| 1300004 | Unauthorized operation. | 3360 3361**Example** 3362 3363```ts 3364const callback = (mainWindowFullScreenAcrossDisplaysChanged: boolean) => { 3365 console.info(`main window across displays changed. Data: ${mainWindowFullScreenAcrossDisplaysChanged}`); 3366} 3367try { 3368 windowClass.on('mainWindowFullScreenAcrossDisplaysChanged', callback); 3369} catch (exception) { 3370 console.error(`Failed to register callback. Cause code: ${exception.code}, message: ${exception.message}`); 3371} 3372``` 3373### off('mainWindowFullScreenAcrossDisplaysChanged')<sup>20+</sup> 3374 3375off(type: 'mainWindowFullScreenAcrossDisplaysChanged', callback?: Callback<boolean>): void 3376 3377Unsubscribes from events indicating whether the main window is in full-screen mode across multiple displays. 3378 3379**System API**: This is a system API. 3380 3381**System capability**: SystemCapability.Window.SessionManager 3382 3383**Parameters** 3384 3385| Name | Type | Mandatory| Description | 3386| -------- |----------------------------| ---- |--------------------------------------| 3387| type | string | Yes | Event type. The value is fixed at **'mainWindowFullScreenAcrossDisplaysChanged'**, indicating changes in whether the main window is in full-screen mode across multiple displays.| 3388| callback | Callback<boolean> | No | Callback used to return the result indicating whether the main window is in full-screen mode across multiple displays. If a value is passed in, the corresponding subscription is canceled. If no value is passed in, all subscriptions to the specified event are canceled. | 3389 3390**Error codes** 3391 3392For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3393 3394| ID| Error Message| 3395| ------- | ------------------------------ | 3396| 202 | Permission verification failed. A non-system application calls a system API. | 3397| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3398| 1300002 | This window state is abnormal. | 3399| 1300003 | This window manager service works abnormally. | 3400| 1300004 | Unauthorized operation. | 3401 3402**Example** 3403 3404```ts 3405const callback = (mainWindowFullScreenAcrossDisplaysChanged: boolean) => { 3406 // ... 3407} 3408try { 3409 // Enable listening through the on API. 3410 windowClass.on('mainWindowFullScreenAcrossDisplaysChanged', callback); 3411 // Disable the listening of a specified callback. 3412 windowClass.off('mainWindowFullScreenAcrossDisplaysChanged', callback); 3413 // Unregister all the callbacks that have been registered through on(). 3414 windowClass.off('mainWindowFullScreenAcrossDisplaysChanged'); 3415} catch (exception) { 3416 console.error(`Failed to unregister callback. Cause code: ${exception.code}, message: ${exception.message}`); 3417} 3418``` 3419 3420## setWindowContainerModalColor<sup>20+</sup> 3421 3422setWindowContainerModalColor(activeColor: string, inactiveColor: string): void 3423 3424Sets the background color of the main window container for both when it has focus and when it does not. In the stage model, you need to call this API after [loadContent()](arkts-apis-window-Window.md#loadcontent9) or [setUIContent()](arkts-apis-window-Window.md#setuicontent9). 3425 3426The background color you set here covers the entire window, including both the title bar and the content area. If you also use [setWindowBackgroundColor()](arkts-apis-window-Window.md#setwindowbackgroundcolor9), the content area shows the window background color, whereas the title bar shows the container background color. 3427 3428**System API**: This is a system API. 3429 3430**System capability**: SystemCapability.Window.SessionManager 3431 3432**Device behavior differences**: This API can be properly called on 2-in-1 devices. If it is called on other device types, error code 801 is returned. 3433 3434**Parameters** 3435 3436| Name| Type| Mandatory| Description| 3437| ----- | ------ | -- | ----------------------------------------------------------------------- | 3438| activeColor | string | Yes| Background color of the window container when it is focused. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **'#00FF00'** or **'#FF00FF00'**.| 3439| inactiveColor | string | Yes| Background color of the window container when it is not focused. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **'#00FF00'** or **'#FF00FF00'**.| 3440 3441**Error codes** 3442 3443For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3444 3445| ID| Error Message| 3446| ------- | ------------------------------ | 3447| 202 | Permission verification failed. A non-system application calls a system API. | 3448| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3449| 1300002 | This window state is abnormal. | 3450| 1300004 | Unauthorized operation. | 3451 3452**Example** 3453 3454```ts 3455// EntryAbility.ets 3456import { UIAbility } from '@kit.AbilityKit'; 3457import { BusinessError } from '@kit.BasicServicesKit'; 3458 3459export default class EntryAbility extends UIAbility { 3460 onWindowStageCreate(windowStage: window.WindowStage) { 3461 windowStage.loadContent("pages/page2", (err: BusinessError) => { 3462 let errCode: number = err.code; 3463 if (errCode) { 3464 console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}`); 3465 return; 3466 } 3467 console.info('Succeeded in loading the content.'); 3468 // Obtain the main window. 3469 let windowClass: window.Window | undefined = undefined; 3470 windowStage.getMainWindow((err: BusinessError, data) => { 3471 let errCode: number = err.code; 3472 if (errCode) { 3473 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 3474 return; 3475 } 3476 windowClass = data; 3477 let activeColor: string = '#00000000'; 3478 let inactiveColor: string = '#FF000000'; 3479 try { 3480 windowClass.setWindowContainerModalColor(activeColor, inactiveColor); 3481 console.info('Succeeded in setting window container color.'); 3482 } catch (exception) { 3483 console.error(`Failed to set the window container color. Cause code: ${exception.code}, message: ${exception.message}`); 3484 }; 3485 }); 3486 }); 3487 } 3488} 3489``` 3490 3491### setTopmost<sup>12+</sup> 3492 3493setTopmost(isTopmost: boolean): Promise<void> 3494 3495Called by the main window to place the window above all the other windows. This API uses a promise to return the result. 3496 3497This parameter is valid only when the main window is a floating window in 2-in-1 devices. 3498 3499**System API**: This is a system API. 3500 3501**System capability**: SystemCapability.Window.SessionManager 3502 3503**Parameters** 3504 3505| Name | Type | Mandatory| Description | 3506| -------- | ------------------------- | ---- | ---------- | 3507| isTopmost | boolean | Yes | Whether to pin the main window on top. **true** to pin, **false** otherwise.| 3508 3509**Return value** 3510 3511| Type | Description | 3512| ------------------- | ------------------------- | 3513| Promise<void> | Promise that returns no value.| 3514 3515**Error codes** 3516 3517For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3518 3519| ID| Error Message| 3520| ------- | ------------------------------ | 3521| 202 | Permission verification failed. A non-system application calls a system API. | 3522| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3523| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3524| 1300002 | This window state is abnormal. | 3525| 1300003 | This window manager service works abnormally. | 3526| 1300004 | Unauthorized operation. | 3527 3528**Example** 3529 3530```ts 3531// EntryAbility.ets 3532import { UIAbility } from '@kit.AbilityKit'; 3533import { BusinessError } from '@kit.BasicServicesKit'; 3534 3535export default class EntryAbility extends UIAbility { 3536 // ... 3537 onWindowStageCreate(windowStage: window.WindowStage): void { 3538 // ... 3539 windowStage.getMainWindow().then((mainWindow) => { 3540 let isTopmost: boolean = true; 3541 mainWindow.setTopmost(isTopmost).then(() => { 3542 console.info('Succeeded in setting the main window to be topmost.'); 3543 }).catch((err: BusinessError) => { 3544 console.error(`Failed to set the main window to be topmost. Cause code: ${err.code}, message: ${err.message}`); 3545 }); 3546 }); 3547 } 3548} 3549``` 3550 3551### setSingleFrameComposerEnabled<sup>11+</sup> 3552 3553setSingleFrameComposerEnabled(enable: boolean): Promise<void> 3554 3555Enables or disables the single-frame composer. This API uses a promise to return the result. 3556 3557The single-frame composer is mainly used in scenarios that require extremely low interaction latency. It reduces the screen display latency of the rendering node. 3558 3559**System API**: This is a system API. 3560 3561**System capability**: SystemCapability.Window.SessionManager 3562 3563**Parameters** 3564 3565| Name | Type | Mandatory| Description | 3566| -------- | ------------------------- | ---- | ---------- | 3567| enable | boolean | Yes | Whether to enable the single-frame composer. **true** to enable, **false** otherwise.| 3568 3569**Return value** 3570 3571| Type | Description | 3572| ------------------- | ------------------------- | 3573| Promise<void> | Promise that returns no value.| 3574 3575**Error codes** 3576 3577For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3578 3579| ID| Error Message| 3580| ------- | ------------------------------ | 3581| 202 | Permission verification failed. A non-system application calls a system API. | 3582| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3583| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3584| 1300002 | This window state is abnormal. | 3585 3586**Example** 3587 3588```ts 3589import { BusinessError } from '@kit.BasicServicesKit'; 3590 3591let enable = true; 3592try { 3593 let promise = windowClass.setSingleFrameComposerEnabled(enable); 3594 promise.then(()=> { 3595 console.info('Succeeded in enabling the single-frame-composer function.'); 3596 }).catch((err: BusinessError)=>{ 3597 console.error(`Failed to enable the single-frame-composer function. code:${err.code}, message:${err.message}.`); 3598 }); 3599} catch (exception) { 3600 console.error(`Failed to enable the single-frame-composer function. Cause code: ${exception.code}, message: ${exception.message}`); 3601} 3602``` 3603 3604### setTitleButtonVisible<sup>12+</sup> 3605 3606setTitleButtonVisible(isMaximizeVisible: boolean, isMinimizeVisible: boolean, isSplitVisible: boolean): void 3607 3608Shows or hides the maximize, minimize, and split-screen buttons on the title bar of the main window. 3609 3610This API is valid only for 2-in-1 devices and takes effect only for the title bar buttons (maximize, minimize, and split-screen) that are available in the current scenario. 3611 3612**System API**: This is a system API. 3613 3614**System capability**: SystemCapability.Window.SessionManager 3615 3616**Parameters** 3617 3618| Name | Type | Mandatory| Description | 3619| --------- | ------- | ---- | --------------------------------------------- | 3620| isMaximizeVisible | boolean | Yes | Whether to show the maximize button. **true** to show, **false** otherwise.| 3621| isMinimizeVisible | boolean | Yes | Whether to show the minimize button. **true** to show, **false** otherwise.| 3622| isSplitVisible | boolean | Yes | Whether to show the split-screen button. **true** to show, **false** otherwise.| 3623 3624**Error codes** 3625 3626For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3627 3628| ID| Error Message | 3629| -------- | ------------------------------ | 3630| 202 | Permission verification failed. A non-system application calls a system API. | 3631| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3632| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3633| 1300002 | This window state is abnormal. | 3634| 1300004 | Unauthorized operation. | 3635 3636**Example** 3637 3638```ts 3639// EntryAbility.ets 3640import { UIAbility } from '@kit.AbilityKit'; 3641import { BusinessError } from '@kit.BasicServicesKit'; 3642 3643export default class EntryAbility extends UIAbility { 3644 onWindowStageCreate(windowStage: window.WindowStage): void { 3645 // Load the page corresponding to the main window. 3646 windowStage.loadContent('pages/Index', (err) => { 3647 if (err?.code) { 3648 console.error(`Failed to load content. Cause code: ${err.code}, message: ${err.message}`); 3649 return; 3650 } 3651 let mainWindow: window.Window | undefined = undefined; 3652 // Obtain the main window. 3653 windowStage.getMainWindow().then( 3654 data => { 3655 if (!data) { 3656 console.error('Failed to get main window.'); 3657 return; 3658 } 3659 mainWindow = data; 3660 console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); 3661 // Call setTitleButtonVisible to hide the maximize, minimize, and split-screen buttons on the title bar of the main window. 3662 mainWindow.setTitleButtonVisible(false, false, false); 3663 } 3664 ).catch((err: BusinessError) => { 3665 if(err.code){ 3666 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 3667 } 3668 }); 3669 }); 3670 } 3671} 3672``` 3673 3674### setWindowType<sup>(deprecated)</sup> 3675 3676setWindowType(type: WindowType, callback: AsyncCallback<void>): void 3677 3678Sets the type of this window. This API uses an asynchronous callback to return the result. 3679 3680**System API**: This is a system API. 3681 3682> **NOTE** 3683> 3684> This API is supported since API version 7 and deprecated since API version 9. 3685 3686**System capability**: SystemCapability.WindowManager.WindowManager.Core 3687 3688**Parameters** 3689 3690| Name | Type | Mandatory| Description | 3691| -------- | ------------------------- | ---- | ---------- | 3692| type | [WindowType](#windowtype7) | Yes | Window type.| 3693| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 3694 3695**Example** 3696 3697```ts 3698import { BusinessError } from '@kit.BasicServicesKit'; 3699 3700let type = window.WindowType.TYPE_SYSTEM_ALERT; 3701windowClass.setWindowType(type, (err: BusinessError) => { 3702 const errCode: number = err.code; 3703 if (errCode) { 3704 console.error(`Failed to set the window type. Cause code: ${err.code}, message: ${err.message}`); 3705 return; 3706 } 3707 console.info('Succeeded in setting the window type.'); 3708}); 3709``` 3710 3711### setWindowType<sup>(deprecated)</sup> 3712 3713setWindowType(type: WindowType): Promise<void> 3714 3715Sets the type of this window. This API uses a promise to return the result. 3716 3717**System API**: This is a system API. 3718 3719> **NOTE** 3720> 3721> This API is supported since API version 7 and deprecated since API version 9. 3722 3723**System capability**: SystemCapability.WindowManager.WindowManager.Core 3724 3725**Parameters** 3726 3727| Name| Type | Mandatory| Description | 3728| ------ | ------------------------- | ---- | ---------- | 3729| type | [WindowType](#windowtype7) | Yes | Window type.| 3730 3731**Return value** 3732 3733| Type | Description | 3734| ------------------- | ------------------------- | 3735| Promise<void> | Promise that returns no value.| 3736 3737**Example** 3738 3739```ts 3740import { BusinessError } from '@kit.BasicServicesKit'; 3741 3742let type = window.WindowType.TYPE_SYSTEM_ALERT; 3743let promise = windowClass.setWindowType(type); 3744promise.then(() => { 3745 console.info('Succeeded in setting the window type.'); 3746}).catch((err: BusinessError) => { 3747 console.error(`Failed to set the window type. Cause code: ${err.code}, message: ${err.message}`); 3748}); 3749``` 3750 3751### requestFocus<sup>13+</sup> 3752 3753requestFocus(isFocused: boolean): Promise<void> 3754 3755Allows this window to proactively request to gain or lose focus. This API uses a promise to return the result. A value is returned as long as the API is successfully called. The return value does not indicate that the window has gained or lost focus. You can use [on('windowEvent')](arkts-apis-window-Window.md#onwindowevent10) to listen for the focus status of the window. 3756 3757When a focus request is sent, whether the window can successfully gain focus depends on its capability of being focused and its current visibility. To gain focus, the window must be capable of receiving focus and in a visible state (actively displayed and not hidden or destroyed). 3758 3759Conversely, once a blur request is sent, the window will lose focus without any conditions. 3760 3761**System API**: This is a system API. 3762 3763**System capability**: SystemCapability.Window.SessionManager 3764 3765**Parameters** 3766 3767| Name | Type | Mandatory| Description | 3768| -------- | ------------------------- | ---- | ---------- | 3769| isFocused | boolean | Yes | Whether to gain or lose focus. **true** to gain focus, **false** otherwise.| 3770 3771**Return value** 3772 3773| Type | Description | 3774| ------------------- | ------------------------- | 3775| Promise<void> | Promise that returns no value.| 3776 3777**Error codes** 3778 3779For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3780 3781| ID| Error Message| 3782| ------- | ------------------------------ | 3783| 202 | Permission verification failed, non-system application uses system API. | 3784| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3785| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3786| 1300002 | This window state is abnormal. | 3787| 1300003 | This window manager service works abnormally. | 3788 3789**Example** 3790 3791```ts 3792import { BusinessError } from '@kit.BasicServicesKit'; 3793 3794let isFocused: boolean = true; 3795let promise = windowClass.requestFocus(isFocused); 3796promise.then(() => { 3797 console.info('Succeeded in requesting focus.'); 3798}).catch((err: BusinessError) => { 3799 console.error(`Failed to request focus. Cause code: ${err.code}, message: ${err.message}`); 3800}); 3801``` 3802 3803## SubWindowOptions<sup>11+</sup> 3804 3805Describes the parameters used for creating a child window. 3806 3807| Name | Type | Read-Only| Optional| Description | 3808| ---------- | ---- | ---- | ---- | ----------- | 3809| isTopmost<sup>12+</sup> | boolean | No| Yes| Whether the child window is topmost. **true** if topmost, **false** otherwise. The default value is **false**.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.Window.SessionManager| 3810 3811## WindowStage<sup>9+</sup> 3812 3813Implements a window manager, which manages each basic window unit, that is, [Window](arkts-apis-window-Window.md) instance. 3814 3815Before calling any of the following APIs, you must use [onWindowStageCreate()](../apis-ability-kit/js-apis-app-ability-uiAbility.md#onwindowstagecreate) to create a WindowStage instance. 3816 3817### disableWindowDecor<sup>9+</sup> 3818 3819disableWindowDecor(): void 3820 3821Disables window decorators. 3822 3823When window decorators are disabled and the main window transitions into full-screen mode, hovering the cursor over the hot zone of the top window's title bar will cause a floating title bar to appear. To prevent the floating title bar from appearing, call [setTitleAndDockHoverShown()](arkts-apis-window-Window.md#settitleanddockhovershown14). 3824 3825**Model restriction**: This API can be used only in the stage model. 3826 3827**System API**: This is a system API. 3828 3829**System capability**: SystemCapability.WindowManager.WindowManager.Core 3830 3831**Error codes** 3832 3833For details about the error codes, see [Window Error Codes](errorcode-window.md). 3834 3835| ID| Error Message| 3836| ------- | ------------------------------ | 3837| 202 | Permission verification failed. A non-system application calls a system API. | 3838| 1300002 | This window state is abnormal. | 3839| 1300005 | This window stage is abnormal. | 3840 3841**Example** 3842 3843```ts 3844// EntryAbility.ets 3845import { UIAbility, Want } from '@kit.AbilityKit'; 3846 3847export default class EntryAbility extends UIAbility { 3848 // ... 3849 3850 onWindowStageCreate(windowStage: window.WindowStage) { 3851 console.log('disableWindowDecor'); 3852 windowStage.disableWindowDecor(); 3853 } 3854}; 3855``` 3856 3857### setShowOnLockScreen<sup>9+</sup> 3858 3859setShowOnLockScreen(showOnLockScreen: boolean): void 3860 3861Sets whether to display the window of the application on the lock screen. 3862 3863**System API**: This is a system API. 3864 3865**Model restriction**: This API can be used only in the stage model. 3866 3867**System capability**: SystemCapability.WindowManager.WindowManager.Core 3868 3869**Parameters** 3870 3871| Name | Type | Mandatory| Description | 3872| ---------------- | ------- | ---- | ---------------------------- | 3873| showOnLockScreen | boolean | Yes | Whether to display the window on the lock screen. **true** to display, **false** otherwise.| 3874 3875**Error codes** 3876 3877For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3878 3879| ID| Error Message| 3880| ------- | ------------------------------ | 3881| 202 | Permission verification failed. A non-system application calls a system API. | 3882| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3883| 1300002 | This window state is abnormal. | 3884| 1300005 | This window stage is abnormal. | 3885 3886**Example** 3887 3888```ts 3889// EntryAbility.ets 3890import { UIAbility } from '@kit.AbilityKit'; 3891 3892export default class EntryAbility extends UIAbility { 3893 // ... 3894 3895 onWindowStageCreate(windowStage: window.WindowStage) { 3896 console.log('onWindowStageCreate'); 3897 try { 3898 windowStage.setShowOnLockScreen(true); 3899 } catch (exception) { 3900 console.error(`Failed to show on lockscreen. Cause code: ${exception.code}, message: ${exception.message}`); 3901 } 3902 } 3903}; 3904``` 3905 3906### setImageForRecent<sup>19+</sup> 3907 3908setImageForRecent(imgResourceId: number, value: ImageFit): Promise<void> 3909 3910Sets the image displayed in the multitasking window. This API uses a promise to return the result. 3911 3912**System API**: This is a system API. 3913 3914**Model restriction**: This API can be used only in the stage model. 3915 3916**System capability**: SystemCapability.Window.SessionManager 3917 3918**Parameters** 3919 3920| Name | Type | Mandatory| Description | 3921| ----------- | ------- | ---- | ------------------------------------------------------------ | 3922| imgResourceId | number | Yes | Resource ID of the custom image. The image must be stored in the **resources/base/media** directory and its resource ID can be obtained using the **$r** resource access mode. For example, to obtain the resource ID of the startIcon image, use the following: $r("app.media.startIcon").id.| 3923| value | [ImageFit](arkui-ts/ts-appendix-enums.md#imagefit) | Yes| Fill mode of the custom image.| 3924 3925**Return value** 3926 3927| Type | Description | 3928| ------------------- | ------------------------- | 3929| Promise<void> | Promise that returns no value.| 3930 3931**Error codes** 3932 3933For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3934 3935| ID| Error Message| 3936| ------- | ------------------------------ | 3937| 202 | Permission verification failed. A non-system application calls a system API. | 3938| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3939| 1300002 | This window state is abnormal. | 3940| 1300003 | This window manager service works abnormally. | 3941| 1300016 | Parameter error. Possible cause: 1. Invalid parameter range. 2. Invalid parameter length. 3. Incorrect parameter format. | 3942 3943**Example** 3944 3945```ts 3946import { UIAbility } from '@kit.AbilityKit'; 3947import { window } from '@kit.ArkUI'; 3948import { BusinessError } from '@kit.BasicServicesKit'; 3949 3950export default class EntryAbility extends UIAbility { 3951 // ... 3952 3953 onWindowStageCreate(windowStage: window.WindowStage) { 3954 let imgResourceId = $r("app.media.startIcon").id 3955 try { 3956 let promise = windowStage.setImageForRecent(imgResourceId, ImageFit.Fill); 3957 promise.then(() => { 3958 console.info(`Succeeded in setting image for recent`); 3959 }).catch((err: BusinessError) => { 3960 console.error(`Failed to set image for recent. Cause code: ${err.code}, message: ${err.message}`); 3961 }); 3962 } catch (exception) { 3963 console.error(`Failed to set image for recent.`); 3964 } 3965 } 3966}; 3967``` 3968 3969## TransitionContext<sup>9+</sup> 3970 3971Provides the context for the transition animation. 3972 3973**System API**: This is a system API. 3974 3975### Attributes 3976 3977**System API**: This is a system API. 3978 3979**System capability**: SystemCapability.WindowManager.WindowManager.Core 3980 3981| Name | Type | Read-Only| Optional| Description | 3982| --------------------- | ----------------- | ---- | ---- | ---------------- | 3983| toWindow<sup>9+</sup> | [Window](arkts-apis-window-Window.md) | No | No | Target window to display the animation.| 3984 3985### completeTransition<sup>9+</sup> 3986 3987completeTransition(isCompleted: boolean): void 3988 3989Completes the transition. This API can be called only after [animateTo()](arkui-ts/ts-explicit-animation.md) is executed. 3990 3991**System API**: This is a system API. 3992 3993**System capability**: SystemCapability.WindowManager.WindowManager.Core 3994 3995**Parameters** 3996 3997| Name | Type | Mandatory| Description | 3998| ----------- | ------- | ---- | ------------------------------------------------------------ | 3999| isCompleted | boolean | Yes | Whether the transition is complete. **true** if complete, **false** otherwise.| 4000 4001**Error codes** 4002 4003For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 4004 4005| ID| Error Message| 4006| ------- | -------------------------------- | 4007| 202 | Permission verification failed. A non-system application calls a system API. | 4008| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 4009 4010**Example** 4011 4012```ts 4013(context: window.TransitionContext) => { 4014 let toWindow: window.Window = context.toWindow; 4015 this.getUIContext()?.animateTo({ 4016 duration: 1000, // Animation duration. 4017 tempo: 0.5, // Playback speed. 4018 curve: Curve.EaseInOut, // Animation curve. 4019 delay: 0, // Animation delay. 4020 iterations: 1, // Number of playback times. 4021 playMode: PlayMode.Normal // Animation playback mode. 4022 }, () => { 4023 let obj: window.TranslateOptions = { 4024 x: 100.0, 4025 y: 0.0, 4026 z: 0.0 4027 }; 4028 toWindow.translate(obj); 4029 console.info('toWindow translate end'); 4030 } 4031 ); 4032 try { 4033 context.completeTransition(true) 4034 } catch (exception) { 4035 console.error(`toWindow translate fail. Cause code: ${exception.code}, message: ${exception.message}`); 4036 } 4037 console.info('complete transition end'); 4038}; 4039``` 4040 4041## TransitionController<sup>9+</sup> 4042 4043Implements the transition animation controller. Before calling any API, you must create a system window. For details, see the sample code. 4044 4045**System API**: This is a system API. 4046 4047**Example** 4048 4049```ts 4050import { BusinessError } from '@kit.BasicServicesKit'; 4051 4052let windowClass: window.Window | undefined = undefined; 4053let config: window.Configuration = { 4054 name: "systemTypeWindow", 4055 windowType: window.WindowType.TYPE_PANEL, // Select a system window type as required. 4056 ctx: this.context 4057}; 4058let promise = window.createWindow(config); 4059promise.then((data) => { 4060 windowClass = data; 4061 console.info('Succeeded in creating the window. Data:' + JSON.stringify(data)); 4062}).catch((err: BusinessError) => { 4063 console.error(`Failed to create the Window. Cause code: ${err.code}, message: ${err.message}`); 4064}); 4065``` 4066 4067### animationForShown<sup>9+</sup> 4068 4069animationForShown(context: TransitionContext): void 4070 4071Customizes the animation for the scenario when the window is shown. 4072 4073**System API**: This is a system API. 4074 4075**System capability**: SystemCapability.WindowManager.WindowManager.Core 4076 4077**Parameters** 4078 4079| Name | Type | Mandatory| Description | 4080| ------- | ---------------------------------------- | ---- | -------------------- | 4081| context | [TransitionContext](#transitioncontext9) | Yes | Context of the transition animation.| 4082 4083**Error codes** 4084 4085For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 4086 4087| ID| Error Message| 4088| ------- | -------------------------------- | 4089| 202 | Permission verification failed. A non-system application calls a system API. | 4090| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 4091 4092**Example** 4093 4094```ts 4095// xxx.ts 4096export class AnimationConfig { 4097 private animationForShownCallFunc_: Function = undefined; 4098 ShowWindowWithCustomAnimation(windowClass: window.Window, callback) { 4099 if (!windowClass) { 4100 console.error('windowClass is undefined'); 4101 return false; 4102 } 4103 this.animationForShownCallFunc_ = callback; 4104 let controller: window.TransitionController = windowClass.getTransitionController(); 4105 controller.animationForShown = (context : window.TransitionContext)=> { 4106 this.animationForShownCallFunc_(context); 4107 }; 4108 windowClass.showWithAnimation(()=>{ 4109 console.info('Show with animation success'); 4110 }); 4111 } 4112} 4113``` 4114 4115```ts 4116// xxx.ets 4117let animationConfig = new AnimationConfig(); 4118let systemTypeWindow = window.findWindow("systemTypeWindow"); // Obtain a system window. 4119try { 4120 animationConfig?.ShowWindowWithCustomAnimation(systemTypeWindow, (context : window.TransitionContext)=>{ 4121 console.info('complete transition end'); 4122 let toWindow = context.toWindow; 4123 this.getUIContext()?.animateTo({ 4124 duration: 1000, // Animation duration. 4125 tempo: 0.5, // Playback speed. 4126 curve: Curve.EaseInOut, // Animation curve. 4127 delay: 0, // Animation delay. 4128 iterations: 1, // Number of playback times. 4129 playMode: PlayMode.Normal // Animation playback mode. 4130 onFinish: () => { 4131 console.info('onFinish in animation'); 4132 context.completeTransition(true) 4133 } 4134 }, () => { 4135 let obj : window.TranslateOptions = { 4136 x : 100.0, 4137 y : 0.0, 4138 z : 0.0 4139 }; 4140 toWindow.translate(obj); // Set the transition animation. 4141 console.info('toWindow translate end in animation'); 4142 }); 4143 console.info('complete transition end'); 4144 }); 4145} catch (error) { 4146 console.error(`ShowWindowWithCustomAnimation error code: ${error.code}, message: ${error.message}`); 4147} 4148``` 4149 4150### animationForHidden<sup>9+</sup> 4151 4152animationForHidden(context: TransitionContext): void 4153 4154Customizes the animation for the scenario when the window is hidden. 4155 4156**System API**: This is a system API. 4157 4158**System capability**: SystemCapability.WindowManager.WindowManager.Core 4159 4160**Parameters** 4161 4162| Name | Type | Mandatory| Description | 4163| ------- | ---------------------------------------- | ---- | -------------------- | 4164| context | [TransitionContext](#transitioncontext9) | Yes | Context of the transition animation.| 4165 4166**Error codes** 4167 4168For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 4169 4170| ID| Error Message| 4171| ------- | -------------------------------- | 4172| 202 | Permission verification failed. A non-system application calls a system API. | 4173| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 4174 4175**Example** 4176 4177```ts 4178// xxx.ts 4179export class AnimationConfig { 4180 private animationForHiddenCallFunc_: Function = undefined; 4181 HideWindowWithCustomAnimation(windowClass: window.Window, callback) { 4182 if (!windowClass) { 4183 console.error('windowClass is undefined'); 4184 return false; 4185 } 4186 this.animationForHiddenCallFunc_ = callback; 4187 let controller: window.TransitionController = windowClass.getTransitionController(); 4188 controller.animationForHidden = (context : window.TransitionContext)=> { 4189 this.animationForHiddenCallFunc_(context); 4190 }; 4191 windowClass.hideWithAnimation(()=>{ 4192 console.info('hide with animation success'); 4193 }); 4194 } 4195} 4196``` 4197 4198```ts 4199// xxx.ets 4200let animationConfig = new AnimationConfig(); 4201let systemTypeWindow = window.findWindow("systemTypeWindow"); // Obtain a system window. 4202try { 4203 animationConfig?.HideWindowWithCustomAnimation(systemTypeWindow, (context : window.TransitionContext)=>{ 4204 console.info('complete transition end'); 4205 let toWindow = context.toWindow; 4206 this.getUIContext()?.animateTo({ 4207 duration: 1000, // Animation duration. 4208 tempo: 0.5, // Playback speed. 4209 curve: Curve.EaseInOut, // Animation curve. 4210 delay: 0, // Animation delay. 4211 iterations: 1, // Number of playback times. 4212 playMode: PlayMode.Normal // Animation playback mode. 4213 onFinish: () => { 4214 console.info('onFinish in animation'); 4215 context.completeTransition(true) 4216 } 4217 }, () => { 4218 let obj : window.TranslateOptions = { 4219 x : 100.0, 4220 y : 0.0, 4221 z : 0.0 4222 }; 4223 toWindow.translate(obj); // Set the transition animation. 4224 console.info('toWindow translate end in animation'); 4225 }); 4226 console.info('complete transition end'); 4227 }); 4228} catch (error) { 4229 console.error(`HideWindowWithCustomAnimation error code: ${error.code}, message: ${error.message}` ); 4230} 4231``` 4232 4233## ExtensionWindowAttribute<sup>14+</sup> 4234 4235Enumerates the attributes of a window for a UI ServiceExtensionAbility. 4236 4237**Model restriction**: This API can be used only in the stage model. 4238 4239**System API**: This is a system API. 4240 4241**System capability**: SystemCapability.Window.SessionManager 4242 4243| Name | Value| Description | 4244| ---------- | ----- | ----------- | 4245| SYSTEM_WINDOW | 0 | System window| 4246| SUB_WINDOW | 1 | child window.| 4247 4248## SystemWindowOptions<sup>14+</sup> 4249 4250Describes the parameters for creating a system window. 4251 4252**Model restriction**: This API can be used only in the stage model. 4253 4254**System API**: This is a system API. 4255 4256**System capability**: SystemCapability.Window.SessionManager 4257 4258| Name| Type | Read-Only |Optional| Description | 4259| ------ | ------------------------- | ---- | ---- |---------- | 4260| windowType | [WindowType](#windowtype7) | No | No | Window type. There is no default value. If null is passed in, the window fails to be created. **TYPE_DIALOG** is not supported.| 4261 4262## ExtensionWindowConfig<sup>14+</sup> 4263 4264Describes the parameters for creating a window for a UI ServiceExtensionAbility. 4265 4266**Model restriction**: This API can be used only in the stage model. 4267 4268**System API**: This is a system API. 4269 4270**System capability**: SystemCapability.Window.SessionManager 4271 4272| Name| Type | Read-Only |Optional| Description | 4273| ------ | ------------------------- | ---- | ---- |---------- | 4274| windowName | string | No| No | Window name.| 4275| windowAttribute | [ExtensionWindowAttribute](#extensionwindowattribute14) | No| No | Window attribute. It specifies whether the created window is a child window or a system window. When **windowAttribute** is set to **SUB_WINDOW**, **subWindowOptions** is mandatory. When **windowAttribute** is set to **SYSTEM_WINDOW**, **systemWindowOptions** is mandatory. Otherwise, the window fails to be created.| 4276| windowRect | [Rect](arkts-apis-window-i.md#rect7) | No| No | Rectangular area of the window.| 4277| subWindowOptions | [SubWindowOptions](arkts-apis-window-i.md#subwindowoptions11) | No| Yes| Parameters used for creating a child window. There is no default value. This parameter is mandatory when **windowAttribute** is set to **SUB_WINDOW**. Otherwise, the window fails to be created.| 4278| systemWindowOptions | [SystemWindowOptions](#systemwindowoptions14) | No| Yes| Parameters for creating a system window. There is no default value. This parameter is mandatory when **windowAttribute** is set to **SYSTEM_WINDOW**. Otherwise, the window fails to be created.| 4279