1# @ohos.display (Display) 2 3The **Display** module provides APIs for managing displays, such as obtaining information about the default display, obtaining information about all displays, and listening for the addition and removal of displays. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8 9## Modules to Import 10 11```ts 12import { display } from '@kit.ArkUI'; 13``` 14 15## DisplayState 16 17Enumerates the display states. 18 19**Atomic service API**: This API can be used in atomic services since API version 12. 20 21**System capability**: SystemCapability.WindowManager.WindowManager.Core 22 23| Name| Value| Description| 24| -------- | -------- | -------- | 25| STATE_UNKNOWN | 0 | Unknown.| 26| STATE_OFF | 1 | The display is shut down.| 27| STATE_ON | 2 | The display is powered on.| 28| STATE_DOZE | 3 | The display is in sleep mode.| 29| STATE_DOZE_SUSPEND | 4 | The display is in sleep mode, and the CPU is suspended.| 30| STATE_VR | 5 | The display is in VR mode.| 31| STATE_ON_SUSPEND | 6 | The display is powered on, and the CPU is suspended.| 32 33## Orientation<sup>10+</sup> 34 35Enumerates the orientations of the display. 36 37**Atomic service API**: This API can be used in atomic services since API version 12. 38 39**System capability**: SystemCapability.WindowManager.WindowManager.Core 40 41| Name| Value| Description| 42| -------- | -------- | -------- | 43| PORTRAIT | 0 | The display is in portrait mode.| 44| LANDSCAPE | 1 | The display is in landscape mode.| 45| PORTRAIT_INVERTED | 2 | The display is in reverse portrait mode.| 46| LANDSCAPE_INVERTED | 3 | The display is in reverse landscape mode.| 47 48## FoldStatus<sup>10+</sup> 49 50Enumerates the folding statuses of a foldable device. 51 52**Atomic service API**: This API can be used in atomic services since API version 12. 53 54**System capability**: SystemCapability.Window.SessionManager 55 56| Name| Value| Description| 57| -------- | -------- | -------- | 58| FOLD_STATUS_UNKNOWN | 0 | The folding status of the device is unknown.| 59| FOLD_STATUS_EXPANDED | 1 | The device is fully open.| 60| FOLD_STATUS_FOLDED | 2 | The device is folded (completely closed).| 61| FOLD_STATUS_HALF_FOLDED | 3 | The device is half-folded, somehow between fully open and completely closed.| 62 63## FoldDisplayMode<sup>10+</sup> 64 65Enumerates the display modes of a foldable device. 66 67**Atomic service API**: This API can be used in atomic services since API version 12. 68 69**System capability**: SystemCapability.Window.SessionManager 70 71| Name| Value| Description| 72| -------- | -------- | -------- | 73| FOLD_DISPLAY_MODE_UNKNOWN | 0 | The display mode of the device is unknown.| 74| FOLD_DISPLAY_MODE_FULL | 1 | The device is displayed in full screen.| 75| FOLD_DISPLAY_MODE_MAIN | 2 | The main screen of the device is displayed.| 76| FOLD_DISPLAY_MODE_SUB | 3 | The subscreen of the device is displayed.| 77| FOLD_DISPLAY_MODE_COORDINATION | 4 | Both screens of the device are displayed in collaborative mode.| 78 79## FoldCreaseRegion<sup>10+</sup> 80 81Defines the crease region of a foldable device. 82 83**Atomic service API**: This API can be used in atomic services since API version 12. 84 85**System capability**: SystemCapability.Window.SessionManager 86 87| Name | Type| Readable| Writable| Description | 88| ------ | -------- | ---- | ---- | ------------------ | 89| displayId | number | Yes | No | ID of the display where the crease is located.| 90| creaseRects | Array\<[Rect](#rect9)> | Yes | No | Crease region.| 91 92## Rect<sup>9+</sup> 93 94Describes a rectangle on the display. 95 96**Atomic service API**: This API can be used in atomic services since API version 12. 97 98**System capability**: SystemCapability.WindowManager.WindowManager.Core 99 100| Name | Type| Readable| Writable| Description | 101| ------ | -------- | ---- | ---- | ------------------ | 102| left | number | Yes | Yes | Left boundary of the rectangle, in px. The value must be an integer.| 103| top | number | Yes | Yes | Top boundary of the rectangle, in px. The value must be an integer.| 104| width | number | Yes | Yes | Width of the rectangle, in px. The value must be an integer. | 105| height | number | Yes | Yes | Height of the rectangle, in px. The value must be an integer. | 106 107## WaterfallDisplayAreaRects<sup>9+</sup> 108 109Describes the curved area (an area that is not intended for displaying content) on the waterfall display. 110 111**Atomic service API**: This API can be used in atomic services since API version 12. 112 113**System capability**: SystemCapability.WindowManager.WindowManager.Core 114 115| Name | Type | Readable| Writable| Description | 116| ------ | ------------- | ---- | ---- | ------------------ | 117| left | [Rect](#rect9) | Yes | No | Bounding rectangle for the curved area, which is located on the left of the display surface.| 118| top | [Rect](#rect9) | Yes | No | Bounding rectangle for the curved area, which is located at the top of the display surface.| 119| right | [Rect](#rect9) | Yes | No | Bounding rectangle for the curved area, which is located on the right of the display surface.| 120| bottom | [Rect](#rect9) | Yes | No | Bounding rectangle for the curved area, which is located at the bottom of the display surface.| 121 122## CutoutInfo<sup>9+</sup> 123 124Describes the cutout, which is an area that is not intended for displaying content on the display. 125 126**Atomic service API**: This API can be used in atomic services since API version 12. 127 128**System capability**: SystemCapability.WindowManager.WindowManager.Core 129 130| Name | Type | Readable| Writable| Description | 131| --------------------------- | ------------- | ---- | ---- | ------------------ | 132| boundingRects | Array\<[Rect](#rect9)> | Yes | No | Bounding rectangle for punch holes and notches.| 133| waterfallDisplayAreaRects | [WaterfallDisplayAreaRects](#waterfalldisplayarearects9) | Yes| No| Curved area on the waterfall display.| 134 135## DisplayPhysicalResolution<sup>12+</sup> 136Describes the display mode of a foldable device and the corresponding physical screen resolution information. 137 138**Atomic service API**: This API can be used in atomic services since API version 12. 139 140**System capability**: SystemCapability.WindowManager.WindowManager.Core 141 142| Name | Type | Read-Only| Optional| Description | 143| --------------------------- | ------------- | ---- | ---- | ------------------ | 144| foldDisplayMode | [FoldDisplayMode](#folddisplaymode10) | Yes | No | Display mode of the foldable device.| 145| physicalWidth | number | Yes| No| Width of the foldable device, in px. The value must be an integer greater than 0.| 146| physicalHeight | number | Yes| No| Height of the foldable device, in px. The value must be an integer greater than 0.| 147 148## display.getDisplayByIdSync<sup>12+</sup> 149 150getDisplayByIdSync(displayId: number): Display 151 152Obtains a **Display** object based on the display ID. 153 154**System capability**: SystemCapability.WindowManager.WindowManager.Core 155 156**Atomic service API**: This API can be used in atomic services since API version 12. 157 158**Parameters** 159 160| Name| Type | Mandatory| Description | 161| ------ | ------------------------- | ---- |----------| 162| displayId | number | Yes | Display ID. The value must be an integer greater than or equal to 0. An object can be obtained only when the passed-in display ID is correct. You can use the value of the **displayId** property in [WindowProperties](js-apis-window.md#windowproperties) as the input parameter.| 163 164**Return value** 165 166| Type | Description | 167| ------------------------------| ----------------------------------------------| 168| [Display](#display) | **Display** object.| 169 170**Error codes** 171 172For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md). 173 174| ID| Error Message| 175| ------- | ----------------------- | 176| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2. Incorrect parameter types. | 177| 1400003 | This display manager service works abnormally. | 178 179**Example** 180 181```ts 182import { display } from '@kit.ArkUI'; 183 184let displayClass: display.Display | null = null; 185 186try { 187 // Use the value of the displayId property in WindowProperties as the input parameter. 188 let displayId = 0; 189 displayClass = display.getDisplayByIdSync(displayId); 190} catch (exception) { 191 console.error(`Failed to get display. Code: ${exception.code}, message: ${exception.message}`); 192} 193``` 194 195## display.getAllDisplayPhysicalResolution<sup>12+</sup> 196 197getAllDisplayPhysicalResolution(): Promise<Array<DisplayPhysicalResolution>> 198 199Obtains the display mode of the current foldable device and the corresponding physical screen resolution information. 200 201**Atomic service API**: This API can be used in atomic services since API version 12. 202 203**System capability**: SystemCapability.WindowManager.WindowManager.Core 204 205**Return value** 206 207| Type| Description| 208| ----------------------------------------------- | ------------------------------------------------------- | 209| Promise<Array<[DisplayPhysicalResolution](#displayphysicalresolution12)>> | Promise used to return all the **DisplayPhysicalResolution** objects.| 210 211**Error codes** 212 213For details about the error codes, see [Display Error Codes](errorcode-display.md). 214 215| ID| Error Message| 216| ------- | ----------------------- | 217| 1400003 | This display manager service works abnormally. | 218 219**Example** 220 221```ts 222import { BusinessError } from '@kit.BasicServicesKit'; 223import { display } from '@kit.ArkUI'; 224 225let promise = display.getAllDisplayPhysicalResolution(); 226promise.then((resolutionObjects) => { 227 console.info('Obtaining physical resolution length: ' + resolutionObjects.length); 228 for (let i = 0; i < resolutionObjects.length; i++) { 229 console.info(`resolutionObjects[${i}].foldDisplayMode: ${resolutionObjects[i].foldDisplayMode}`); 230 console.info(`resolutionObjects[${i}].physicalWidth: ${resolutionObjects[i].physicalWidth}`); 231 console.info(`resolutionObjects[${i}].physicalHeight: ${resolutionObjects[i].physicalHeight}`); 232 } 233}).catch((err: BusinessError) => { 234 console.error(`Failed to obtain physical resolution. Code: ${err.code}, message: ${err.message}`); 235}); 236``` 237 238## display.getDefaultDisplaySync<sup>9+</sup> 239 240getDefaultDisplaySync(): Display 241 242Obtains the default display object. This API returns the result synchronously. 243 244**System capability**: SystemCapability.WindowManager.WindowManager.Core 245 246**Atomic service API**: This API can be used in atomic services since API version 11. 247 248**Return value** 249 250| Type | Description | 251| ------------------------------| ----------------------------------------------| 252| [Display](#display) | Default display object.| 253 254**Error codes** 255 256For details about the error codes, see [Display Error Codes](errorcode-display.md). 257 258| ID| Error Message| 259| ------- | ----------------------- | 260| 1400001 | Invalid display or screen. | 261 262**Example** 263 264```ts 265import { display } from '@kit.ArkUI'; 266 267let displayClass: display.Display | null = null; 268 269displayClass = display.getDefaultDisplaySync(); 270``` 271 272## display.getAllDisplays<sup>9+</sup> 273 274getAllDisplays(callback: AsyncCallback<Array<Display>>): void 275 276Obtains all display objects. This API uses an asynchronous callback to return the result. 277 278**Atomic service API**: This API can be used in atomic services since API version 12. 279 280**System capability**: SystemCapability.WindowManager.WindowManager.Core 281 282**Parameters** 283 284| Name| Type| Mandatory| Description| 285| -------- | ---------------------------------------------------- | ---- | ------------------------------- | 286| callback | AsyncCallback<Array<[Display](#display)>> | Yes| Callback used to return all the display objects.| 287 288**Error codes** 289 290For details about the error codes, see [Display Error Codes](errorcode-display.md). 291 292| ID| Error Message| 293| ------- | ----------------------- | 294| 1400001 | Invalid display or screen. | 295 296**Example** 297 298```ts 299import { BusinessError } from '@kit.BasicServicesKit'; 300import { display } from '@kit.ArkUI'; 301 302let displayClass: Array<display.Display> = []; 303display.getAllDisplays((err: BusinessError, data: Array<display.Display>) => { 304 displayClass = data; 305 const errCode: number = err.code; 306 if (errCode) { 307 console.error(`Failed to obtain all the display objects. Code: ${err.code}, message: ${err.message}`); 308 return; 309 } 310 console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); 311}); 312``` 313 314## display.getAllDisplays<sup>9+</sup> 315 316getAllDisplays(): Promise<Array<Display>> 317 318Obtains all display objects. This API uses a promise to return the result. 319 320**Atomic service API**: This API can be used in atomic services since API version 12. 321 322**System capability**: SystemCapability.WindowManager.WindowManager.Core 323 324**Return value** 325 326| Type| Description| 327| ----------------------------------------------- | ------------------------------------------------------- | 328| Promise<Array<[Display](#display)>> | Promise used to return all the display objects.| 329 330**Error codes** 331 332For details about the error codes, see [Display Error Codes](errorcode-display.md). 333 334| ID| Error Message| 335| ------- | ----------------------- | 336| 1400001 | Invalid display or screen. | 337 338**Example** 339 340```ts 341import { BusinessError } from '@kit.BasicServicesKit'; 342import { display } from '@kit.ArkUI'; 343 344let displayClass: Array<display.Display> =[]; 345let promise: Promise<Array<display.Display>> = display.getAllDisplays(); 346promise.then((data: Array<display.Display>) => { 347 displayClass = data; 348 console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); 349}).catch((err: BusinessError) => { 350 console.error(`Failed to obtain all the display objects. Code: ${err.code}, message: ${err.message}`); 351}); 352``` 353 354## display.on('add'|'remove'|'change') 355 356on(type: 'add'|'remove'|'change', callback: Callback<number>): void 357 358Subscribes to display changes. 359 360**Atomic service API**: This API can be used in atomic services since API version 12. 361 362**System capability**: SystemCapability.WindowManager.WindowManager.Core 363 364**Parameters** 365 366| Name| Type| Mandatory| Description | 367| -------- | -------- | -------- |---------------------------------------------------------------------------------------------------------------------------------| 368| type | string | Yes| Event type.<br>- **add**, indicating the display addition event. Example: event that a display is connected.<br>- **remove**, indicating the display removal event. Example: event that a display is disconnected.<br>- **change**, indicating the display change event. Example: event that the display orientation is changed.| 369| callback | Callback<number> | Yes| Callback used to return the ID of the display, which is an integer. | 370 371**Error codes** 372 373For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 374 375| ID| Error Message| 376| ------- | ----------------------- | 377| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.| 378 379**Example** 380 381```ts 382import { Callback } from '@kit.BasicServicesKit'; 383 384let callback: Callback<number> = (data: number) => { 385 console.info('Listening enabled. Data: ' + JSON.stringify(data)); 386}; 387 388display.on("add", callback); 389``` 390 391## display.off('add'|'remove'|'change') 392 393off(type: 'add'|'remove'|'change', callback?: Callback<number>): void 394 395Unsubscribes from display changes. 396 397**Atomic service API**: This API can be used in atomic services since API version 12. 398 399**System capability**: SystemCapability.WindowManager.WindowManager.Core 400 401**Parameters** 402 403| Name| Type| Mandatory| Description| 404| -------- | -------- | -------- | -------- | 405| type | string | Yes| Event type.<br>- **add**, indicating the display addition event. Example: event that a display is connected.<br>- **remove**, indicating the display removal event. Example: event that a display is disconnected.<br>- **change**, indicating the display change event. Example: event that the display orientation is changed.| 406| callback | Callback<number> | No| Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified type will be unregistered.| 407 408**Error codes** 409 410For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 411 412| ID| Error Message| 413| ------- | ----------------------- | 414| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.| 415 416**Example** 417 418```ts 419 420// Unregister all the callbacks that have been registered through on(). 421display.off("remove"); 422 423let callback: Callback<number> = (data: number) => { 424 console.info('Succeeded in unregistering the callback for display remove. Data: ' + JSON.stringify(data)) 425}; 426// Unregister the specified callback. 427display.off('remove', callback); 428``` 429 430## display.isFoldable<sup>10+</sup> 431isFoldable(): boolean 432 433Checks whether the device is foldable. 434 435**Atomic service API**: This API can be used in atomic services since API version 12. 436 437**System capability**: SystemCapability.Window.SessionManager 438 439**Return value** 440 441| Type| Description| 442| ----------------------------------------------- | ------------------------------------------------------- | 443| boolean | Returns **true** if the device is foldable, and returns **false** otherwise.| 444 445**Error codes** 446 447For details about the error codes, see [Display Error Codes](errorcode-display.md). 448 449| ID| Error Message| 450| ------- | ----------------------- | 451| 1400003 | This display manager service works abnormally. | 452 453**Example** 454 455```ts 456import { display } from '@kit.ArkUI'; 457 458let ret: boolean = false; 459ret = display.isFoldable(); 460``` 461 462## display.getFoldStatus<sup>10+</sup> 463getFoldStatus(): FoldStatus 464 465Obtains the folding status of the foldable device. 466 467**Atomic service API**: This API can be used in atomic services since API version 12. 468 469**System capability**: SystemCapability.Window.SessionManager 470 471**Return value** 472 473| Type| Description| 474| ----------------------------------------------- | ------------------------------------------------------- | 475| [FoldStatus](#foldstatus10) | Folding status of the device.| 476 477**Error codes** 478 479For details about the error codes, see [Display Error Codes](errorcode-display.md). 480 481| ID| Error Message| 482| ------- | ----------------------- | 483| 1400003 | This display manager service works abnormally. | 484 485**Example** 486 487```ts 488import { display } from '@kit.ArkUI'; 489 490let data: display.FoldStatus = display.getFoldStatus(); 491console.info('Succeeded in obtaining fold status. Data: ' + JSON.stringify(data)); 492``` 493 494## display.getFoldDisplayMode<sup>10+</sup> 495getFoldDisplayMode(): FoldDisplayMode 496 497Obtains the display mode of the foldable device. 498 499**Atomic service API**: This API can be used in atomic services since API version 12. 500 501**System capability**: SystemCapability.Window.SessionManager 502 503**Return value** 504 505| Type| Description| 506| ----------------------------------------------- | ------------------------------------------------------- | 507| [FoldDisplayMode](#folddisplaymode10) | Display mode of the device.| 508 509**Error codes** 510 511For details about the error codes, see [Display Error Codes](errorcode-display.md). 512 513| ID| Error Message| 514| ------- | ----------------------- | 515| 1400003 | This display manager service works abnormally. | 516 517**Example** 518 519```ts 520import { display } from '@kit.ArkUI'; 521 522let data: display.FoldDisplayMode = display.getFoldDisplayMode(); 523console.info('Succeeded in obtaining fold display mode. Data: ' + JSON.stringify(data)); 524``` 525 526## display.getCurrentFoldCreaseRegion<sup>10+</sup> 527getCurrentFoldCreaseRegion(): FoldCreaseRegion 528 529Obtains the crease region of the foldable device in the current display mode. 530 531**Atomic service API**: This API can be used in atomic services since API version 12. 532 533**System capability**: SystemCapability.Window.SessionManager 534 535**Return value** 536 537| Type| Description| 538| ----------------------------------------------- | ------------------------------------------------------- | 539| [FoldCreaseRegion](#foldcreaseregion10) | Crease region of the device.| 540 541**Error codes** 542 543For details about the error codes, see [Display Error Codes](errorcode-display.md). 544 545| ID| Error Message| 546| ------- | ----------------------- | 547| 1400003 | This display manager service works abnormally. | 548 549**Example** 550 551```ts 552import { display } from '@kit.ArkUI'; 553 554let data: display.FoldCreaseRegion = display.getCurrentFoldCreaseRegion(); 555console.info('Succeeded in obtaining current fold crease region. Data: ' + JSON.stringify(data)); 556``` 557 558## display.on('foldStatusChange')<sup>10+</sup> 559 560on(type: 'foldStatusChange', callback: Callback<FoldStatus>): void 561 562Subscribes to folding status change events of the foldable device. 563 564**Atomic service API**: This API can be used in atomic services since API version 12. 565 566**System capability**: SystemCapability.Window.SessionManager 567 568**Parameters** 569 570| Name | Type | Mandatory| Description | 571| -------- |------------------------------------------| ---- | ------------------------------------------------------- | 572| type | string | Yes | Event type. The event **'foldStatusChange'** is triggered when the folding status of the device changes.| 573| callback | Callback<[FoldStatus](#foldstatus10)> | Yes | Callback used to return the folding status.| 574 575**Error codes** 576 577For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md). 578 579| ID| Error Message| 580| ------- | ----------------------- | 581| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.| 582| 1400003 | This display manager service works abnormally. | 583 584**Example** 585 586```ts 587import { Callback } from '@kit.BasicServicesKit'; 588 589let callback: Callback<display.FoldStatus> = (data: display.FoldStatus) => { 590 console.info('Listening enabled. Data: ' + JSON.stringify(data)); 591}; 592display.on('foldStatusChange', callback); 593``` 594 595## display.off('foldStatusChange')<sup>10+</sup> 596 597off(type: 'foldStatusChange', callback?: Callback<FoldStatus>): void 598 599Unsubscribes from folding status change events of the foldable device. 600 601**Atomic service API**: This API can be used in atomic services since API version 12. 602 603**System capability**: SystemCapability.Window.SessionManager 604 605**Parameters** 606 607| Name | Type | Mandatory| Description | 608| -------- |------------------------------------------| ---- | ------------------------------------------------------- | 609| type | string | Yes | Event type. The event **'foldStatusChange'** is triggered when the folding status of the device changes.| 610| callback | Callback<[FoldStatus](#foldstatus10)> | No | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified type will be unregistered.| 611 612**Error codes** 613 614For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md). 615 616| ID| Error Message| 617| ------- | ----------------------- | 618| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.| 619| 1400003 | This display manager service works abnormally. | 620 621**Example** 622 623```ts 624 625// Unregister all the callbacks that have been registered through on(). 626display.off('foldStatusChange'); 627 628let callback: Callback<display.FoldStatus> = (data: display.FoldStatus) => { 629 console.info('unregistering FoldStatus changes callback. Data: ' + JSON.stringify(data)); 630}; 631// Unregister the specified callback. 632display.off('foldStatusChange', callback); 633``` 634 635## display.on('foldAngleChange')<sup>12+</sup> 636 637on(type: 'foldAngleChange', callback: Callback<Array<number>>): void 638 639Subscribes to folding angle change events of the foldable device. 640 641**Atomic service API**: This API can be used in atomic services since API version 12. 642 643**System capability**: SystemCapability.Window.SessionManager 644 645**Parameters** 646 647| Name | Type | Mandatory| Description | 648| -------- |------------------------------------------| ---- | ------------------------------------------------------- | 649| type | string | Yes| Event type. The event **'foldAngleChange'** is triggered when the folding angle of the device changes.| 650| callback | Callback<Array<number>> | Yes| Callback used to return the folding angle (0–180 degrees).| 651 652**Error codes** 653 654For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md). 655 656| ID| Error Message| 657| ------- | ----------------------- | 658| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.| 659| 1400003 | This display manager service works abnormally. | 660 661**Example** 662 663```ts 664import { Callback } from '@kit.BasicServicesKit'; 665 666let callback: Callback<Array<number>> = (angles: Array<number>) => { 667 console.info('Listening fold angles length: ' + angles.length); 668}; 669display.on('foldAngleChange', callback); 670``` 671 672## display.off('foldAngleChange')<sup>12+</sup> 673 674off(type: 'foldAngleChange', callback?: Callback<Array<number>>): void 675 676Unsubscribes from folding angle change events of the foldable device. 677 678**Atomic service API**: This API can be used in atomic services since API version 12. 679 680**System capability**: SystemCapability.Window.SessionManager 681 682**Parameters** 683 684| Name | Type | Mandatory| Description | 685| -------- |-------------------------------------------| ---- | ------------------------------------------------------- | 686| type | string | Yes | Event type. The event **'foldAngleChange'** is triggered when the folding angle of the device changes.| 687| callback | Callback<Array<number>> | No | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified type will be unregistered.| 688 689**Error codes** 690 691For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md). 692 693| ID| Error Message| 694| ------- | ----------------------- | 695| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.| 696| 1400003 | This display manager service works abnormally. | 697 698**Example** 699 700```ts 701display.off('foldAngleChange'); 702``` 703 704## display.on('captureStatusChange')<sup>12+</sup> 705 706on(type: 'captureStatusChange', callback: Callback<boolean>): void 707 708Subscribes to screen capture, projection, or recording status changes. 709 710**Atomic service API**: This API can be used in atomic services since API version 12. 711 712**System capability**: SystemCapability.Window.SessionManager 713 714**Parameters** 715 716| Name | Type | Mandatory| Description | 717| -------- |-------------------------------------------| ---- | ------------------------------------------------------- | 718| type | string | Yes| Event type. The event **'captureStatusChange'** is triggered when the screen capture, projection, or recording status changes.| 719| callback | Callback<boolean> | Yes| Callback used to return the screen capture, projection, or recording status change. The value **true** means that the device starts screen capture, projection, or recording, and **false** means that the device stops screen capture, projection, or recording.| 720 721**Error codes** 722 723For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md). 724 725| ID| Error Message| 726| ------- | ----------------------- | 727| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.| 728| 1400003 | This display manager service works abnormally. | 729 730**Example** 731 732```ts 733import { Callback } from '@kit.BasicServicesKit'; 734 735let callback: Callback<boolean> = (captureStatus: boolean) => { 736 console.info('Listening capture status: ' + captureStatus); 737}; 738display.on('captureStatusChange', callback); 739``` 740 741## display.off('captureStatusChange')<sup>12+</sup> 742 743off(type: 'captureStatusChange', callback?: Callback<boolean>): void 744 745Unsubscribes from screen capture, projection, or recording status changes. 746 747**Atomic service API**: This API can be used in atomic services since API version 12. 748 749**System capability**: SystemCapability.Window.SessionManager 750 751**Parameters** 752 753| Name | Type | Mandatory| Description | 754| -------- |-------------------------------------------| ---- | ------------------------------------------------------- | 755| type | string | Yes| Event type. The event **'captureStatusChange'** is triggered when the screen capture, projection, or recording status changes.| 756| callback | Callback<boolean> | No| Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified type will be unregistered.| 757 758**Error codes** 759 760For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md). 761 762| ID| Error Message| 763| ------- | ----------------------- | 764| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.| 765| 1400003 | This display manager service works abnormally. | 766 767**Example** 768 769```ts 770display.off('captureStatusChange'); 771``` 772 773## display.isCaptured<sup>12+</sup> 774isCaptured(): boolean 775 776Checks whether the device screen is being captured, projected, or recorded. 777 778**Atomic service API**: This API can be used in atomic services since API version 12. 779 780**System capability**: SystemCapability.Window.SessionManager 781 782**Return value** 783 784| Type| Description| 785| ----------------------------------------------- | ------------------------------------------------------- | 786| boolean | **true**: The device screen is being captured, projected, or recorded.<br> **false**: The device screen is not being captured, projected, or recorded.| 787 788**Error codes** 789 790For details about the error codes, see [Display Error Codes](errorcode-display.md). 791 792| ID| Error Message| 793| ------- | ----------------------- | 794| 1400003 | This display manager service works abnormally. | 795 796**Example** 797 798```ts 799import { display } from '@kit.ArkUI'; 800 801let ret: boolean = false; 802ret = display.isCaptured(); 803``` 804 805## display.on('foldDisplayModeChange')<sup>10+</sup> 806 807on(type: 'foldDisplayModeChange', callback: Callback<FoldDisplayMode>): void 808 809Subscribes to display mode change events of the foldable device. 810 811**Atomic service API**: This API can be used in atomic services since API version 12. 812 813**System capability**: SystemCapability.Window.SessionManager 814 815**Parameters** 816 817| Name | Type | Mandatory| Description | 818| -------- |------------------------------------------| ---- | ------------------------------------------------------- | 819| type | string | Yes | Event type. The event **'foldDisplayModeChange'** is triggered when the display mode of the device changes.| 820| callback | Callback<[FoldDisplayMode](#folddisplaymode10)> | Yes | Callback used to return the display mode.| 821 822**Error codes** 823 824For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md). 825 826| ID| Error Message| 827| ------- | ----------------------- | 828| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.| 829| 1400003 | This display manager service works abnormally. | 830 831**Example** 832 833```ts 834import { Callback } from '@kit.BasicServicesKit'; 835 836let callback: Callback<display.FoldDisplayMode> = (data: display.FoldDisplayMode) => { 837 console.info('Listening enabled. Data: ' + JSON.stringify(data)); 838}; 839display.on('foldDisplayModeChange', callback); 840``` 841 842## display.off('foldDisplayModeChange')<sup>10+</sup> 843 844off(type: 'foldDisplayModeChange', callback?: Callback<FoldDisplayMode>): void 845 846Unsubscribes from display mode change events of the foldable device. 847 848**Atomic service API**: This API can be used in atomic services since API version 12. 849 850**System capability**: SystemCapability.Window.SessionManager 851 852**Parameters** 853 854| Name | Type | Mandatory| Description | 855| -------- |------------------------------------------| ---- | ------------------------------------------------------- | 856| type | string | Yes | Event type. The event **'foldDisplayModeChange'** is triggered when the display mode of the device changes.| 857| callback | Callback<[FoldDisplayMode](#folddisplaymode10)> | No | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified type will be unregistered.| 858 859**Error codes** 860 861For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md). 862 863| ID| Error Message| 864| ------- | ----------------------- | 865| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.| 866| 1400003 | This display manager service works abnormally. | 867 868**Example** 869 870```ts 871 872// Unregister all the callbacks that have been registered through on(). 873display.off('foldDisplayModeChange'); 874 875let callback: Callback<display.FoldDisplayMode> = (data: display.FoldDisplayMode) => { 876 console.info('unregistering FoldDisplayMode changes callback. Data: ' + JSON.stringify(data)); 877}; 878// Unregister the specified callback. 879display.off('foldDisplayModeChange', callback); 880``` 881 882 883## display.getDefaultDisplay<sup>(deprecated)</sup> 884 885getDefaultDisplay(callback: AsyncCallback<Display>): void 886 887Obtains the default display object. This API uses an asynchronous callback to return the result. 888 889> **NOTE** 890> 891> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDefaultDisplaySync()](#displaygetdefaultdisplaysync9) instead. 892 893**System capability**: SystemCapability.WindowManager.WindowManager.Core 894 895**Parameters** 896 897| Name| Type| Mandatory| Description| 898| -------- | -------- | -------- | -------- | 899| callback | AsyncCallback<[Display](#display)> | Yes| Callback used to return the default display object.| 900 901**Example** 902 903```ts 904import { BusinessError } from '@kit.BasicServicesKit'; 905 906let displayClass: display.Display | null = null; 907display.getDefaultDisplay((err: BusinessError, data: display.Display) => { 908 const errCode: number = err.code; 909 if (errCode) { 910 console.error(`Failed to obtain the default display object. Code: ${err.code}, message: ${err.message}`); 911 return; 912 } 913 console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); 914 displayClass = data; 915}); 916``` 917 918## display.getDefaultDisplay<sup>(deprecated)</sup> 919 920getDefaultDisplay(): Promise<Display> 921 922Obtains the default display object. This API uses a promise to return the result. 923 924> **NOTE** 925> 926> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDefaultDisplaySync()](#displaygetdefaultdisplaysync9) instead. 927 928**System capability**: SystemCapability.WindowManager.WindowManager.Core 929 930**Return value** 931 932| Type | Description | 933| ---------------------------------- | ---------------------------------------------- | 934| Promise<[Display](#display)> | Promise used to return the default display object.| 935 936**Example** 937 938```ts 939import { BusinessError } from '@kit.BasicServicesKit'; 940 941let displayClass: display.Display | null = null; 942let promise: Promise<display.Display> = display.getDefaultDisplay(); 943promise.then((data: display.Display) => { 944 displayClass = data; 945 console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); 946}).catch((err: BusinessError) => { 947 console.error(`Failed to obtain the default display object. Code: ${err.code}, message: ${err.message}`); 948}); 949``` 950 951## display.getAllDisplay<sup>(deprecated)</sup> 952 953getAllDisplay(callback: AsyncCallback<Array<Display>>): void 954 955Obtains all display objects. This API uses an asynchronous callback to return the result. 956 957> **NOTE** 958> 959> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getAllDisplays()](#displaygetalldisplays9) instead. 960 961**System capability**: SystemCapability.WindowManager.WindowManager.Core 962 963**Parameters** 964 965| Name | Type | Mandatory| Description | 966| -------- | ---------------------------------------------------- | ---- | ------------------------------- | 967| callback | AsyncCallback<Array<[Display](#display)>> | Yes | Callback used to return all the display objects.| 968 969**Example** 970 971```ts 972import { BusinessError } from '@kit.BasicServicesKit'; 973 974display.getAllDisplay((err: BusinessError, data: Array<display.Display>) => { 975 const errCode: number = err.code; 976 if (errCode) { 977 console.error(`Failed to obtain all the display objects. Code: ${err.code}, message: ${err.message}`); 978 return; 979 } 980 console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); 981}); 982``` 983 984## display.getAllDisplay<sup>(deprecated)</sup> 985 986getAllDisplay(): Promise<Array<Display>> 987 988Obtains all display objects. This API uses a promise to return the result. 989 990> **NOTE** 991> 992> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getAllDisplays()](#displaygetalldisplays9-1) instead. 993 994**System capability**: SystemCapability.WindowManager.WindowManager.Core 995 996**Return value** 997 998| Type | Description | 999| ----------------------------------------------- | ------------------------------------------------------- | 1000| Promise<Array<[Display](#display)>> | Promise used to return all the display objects.| 1001 1002**Example** 1003 1004```ts 1005import { BusinessError } from '@kit.BasicServicesKit'; 1006 1007let promise: Promise<Array<display.Display>> = display.getAllDisplay(); 1008promise.then((data: Array<display.Display>) => { 1009 console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); 1010}).catch((err: BusinessError) => { 1011 console.error(`Failed to obtain all the display objects. Code: ${err.code}, message: ${err.message}`); 1012}); 1013``` 1014 1015## Display 1016Implements a **Display** instance, with properties and APIs defined. 1017 1018Before calling any API in **Display**, you must use [getAllDisplays()](#displaygetalldisplays9) or [getDefaultDisplaySync()](#displaygetdefaultdisplaysync9) to obtain a **Display** instance. 1019 1020### Attributes 1021 1022**System capability**: SystemCapability.WindowManager.WindowManager.Core 1023 1024| Name| Type| Read-Only| Optional| Description | 1025| -------- | -------- | -------- | -------- |---------------------------------------------------------------------------------------------------------------| 1026| id | number | Yes| No| ID of the display. The value must be an integer.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1027| name | string | Yes| No| Name of the display.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1028| alive | boolean | Yes| No| Whether the display is alive.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1029| state | [DisplayState](#displaystate) | Yes| No| State of the display.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1030| refreshRate | number | Yes| No| Refresh rate of the display, in hz. The value must be an integer.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1031| rotation | number | Yes| No| Clockwise rotation angle of the screen of the display.<br>The value **0** indicates that the screen of the display rotates clockwise by 0°.<br>The value **1** indicates that the screen of the display rotates clockwise by 90°.<br>The value **2** indicates that the screen of the display rotates clockwise by 180°.<br>The value **3** indicates that the screen of the display rotates clockwise by 270°.<br>**Atomic service API**: This API can be used in atomic services since API version 11.| 1032| width | number | Yes| No| Screen width of the display, in px. The value must be an integer.<br>**Atomic service API**: This API can be used in atomic services since API version 11. | 1033| height | number | Yes| No| Screen height of the display, in px. The value must be an integer.<br>**Atomic service API**: This API can be used in atomic services since API version 11. | 1034| densityDPI | number | Yes| No| Physical pixel density of the display, that is, the number of pixels per inch. The value is a floating point number, in px. The value range is [80.0, 640.0]. Generally, the value is **160.0** or **480.0**. The actual value depends on the optional values provided by the device in use.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1035| orientation<sup>10+</sup> | [Orientation](#orientation10) | Yes| No| Orientation of the display.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1036| densityPixels | number | Yes| No| Logical pixel density of the display, which is the scaling coefficient between physical pixels and logical pixels. The calculation method is as follows:<br><br>The value is a floating point number and is restricted by the range of **densityDPI**. The value range is [0.5, 4.0]. Generally, the value is **1.0** or **3.0**. The actual value depends on the density DPI provided by the device in use.<br>**Atomic service API**: This API can be used in atomic services since API version 11. | 1037| scaledDensity | number | Yes| No| Scaling factor for fonts displayed on the display. The value must be a floating point number. Generally, the value is the same as that of **densityPixels**.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1038| xDPI | number | Yes| No| Exact physical dots per inch of the screen in the horizontal direction. The value must be a floating point number.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1039| yDPI | number | Yes| No| Exact physical dots per inch of the screen in the vertical direction. The value must be a floating point number.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1040| colorSpaces<sup>11+</sup> | Array<[colorSpaceManager.ColorSpace](../apis-arkgraphics2d/js-apis-colorSpaceManager.md)> | Yes| No| All color spaces supported by the display.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1041| hdrFormats<sup>11+</sup> | Array<[hdrCapability.HDRFormat](../apis-arkgraphics2d/js-apis-hdrCapability.md)> | Yes| No| All HDR formats supported by the display.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1042| availableWidth<sup>12+</sup> | number | Yes| No| Width of the available area on the screen of a 2-in-1 device, in px. The value is an integer greater than 0.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1043| availableHeight<sup>12+</sup> | number | Yes| No| Height of the available area on the screen of a 2-in-1 device, in px. The value is an integer greater than 0.<br>**Atomic service API**: This API can be used in atomic services since API version 12. | 1044 1045### getCutoutInfo<sup>9+</sup> 1046getCutoutInfo(callback: AsyncCallback<CutoutInfo>): void 1047 1048Obtains the cutout information of the display. This API uses an asynchronous callback to return the result. You are advised not to use the cutout area during application layout. 1049 1050**Atomic service API**: This API can be used in atomic services since API version 12. 1051 1052**System capability**: SystemCapability.WindowManager.WindowManager.Core 1053 1054**Parameters** 1055 1056| Name | Type | Mandatory| Description | 1057| ----------- | --------------------------- | ---- | ------------------------------------------------------------ | 1058| callback | AsyncCallback<[CutoutInfo](#cutoutinfo9)> | Yes | Callback used to return the **CutoutInfo** object.| 1059 1060**Error codes** 1061 1062For details about the error codes, see [Display Error Codes](errorcode-display.md). 1063 1064| ID| Error Message| 1065| ------- | ----------------------- | 1066| 1400001 | Invalid display or screen. | 1067 1068**Example** 1069 1070```ts 1071import { BusinessError } from '@kit.BasicServicesKit'; 1072 1073let displayClass: display.Display | null = null; 1074displayClass = display.getDefaultDisplaySync(); 1075 1076displayClass.getCutoutInfo((err: BusinessError, data: display.CutoutInfo) => { 1077 const errCode: number = err.code; 1078 if (errCode) { 1079 console.error(`Failed to get cutoutInfo. Code: ${err.code}, message: ${err.message}`); 1080 return; 1081 } 1082 console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data)); 1083}); 1084``` 1085### getCutoutInfo<sup>9+</sup> 1086getCutoutInfo(): Promise<CutoutInfo> 1087 1088Obtains the cutout information of the display. This API uses a promise to return the result. You are advised not to use the cutout area during application layout. 1089 1090**Atomic service API**: This API can be used in atomic services since API version 12. 1091 1092**System capability**: SystemCapability.WindowManager.WindowManager.Core 1093 1094**Return value** 1095 1096| Type | Description | 1097| ------------------- | ------------------------- | 1098| Promise<[CutoutInfo](#cutoutinfo9)> | Promise used to return the **CutoutInfo** object.| 1099 1100**Error codes** 1101 1102For details about the error codes, see [Display Error Codes](errorcode-display.md). 1103 1104| ID| Error Message| 1105| ------- | ----------------------- | 1106| 1400001 | Invalid display or screen. | 1107 1108**Example** 1109 1110```ts 1111import { BusinessError } from '@kit.BasicServicesKit'; 1112 1113let displayClass: display.Display | null = null; 1114displayClass = display.getDefaultDisplaySync(); 1115let promise: Promise<display.CutoutInfo> = displayClass.getCutoutInfo(); 1116promise.then((data: display.CutoutInfo) => { 1117 console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data)); 1118}).catch((err: BusinessError) => { 1119 console.error(`Failed to obtain all the display objects. Code: ${err.code}, message: ${err.message}`); 1120}); 1121``` 1122 1123### getAvailableArea<sup>12+</sup> 1124getAvailableArea(): Promise<Rect> 1125 1126Obtains the available area of the screen of the current 2-in-1 device. This API uses a promise to return the result. 1127 1128**Atomic service API**: This API can be used in atomic services since API version 12. 1129 1130**System capability**: SystemCapability.Window.SessionManager 1131 1132**Return value** 1133 1134| Type | Description | 1135| ------------------- | ------------------------- | 1136| Promise<[Rect](#rect9)> | Promise used to return the available area, which is a rectangle.| 1137 1138**Error codes** 1139 1140For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md). 1141 1142| ID| Error Message| 1143| ------- | ----------------------- | 1144| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 1145| 1400001 | Invalid display or screen. | 1146 1147**Example** 1148 1149```ts 1150import { BusinessError } from '@kit.BasicServicesKit'; 1151import { display } from '@kit.ArkUI'; 1152 1153let displayClass: display.Display | null = null; 1154try { 1155 displayClass = display.getDefaultDisplaySync(); 1156 let promise = displayClass.getAvailableArea(); 1157 promise.then((data) => { 1158 console.info('Succeeded get the available area in this display. data: ' + JSON.stringify(data)); 1159 }).catch((err: BusinessError) => { 1160 console.error(`Failed to get the available area in this display. Code: ${err.code}, message: ${err.message}`); 1161 }) 1162} catch (exception) { 1163 console.error(`Failed to obtain the default display object. Code: ${exception.code}, message: ${exception.message}`); 1164} 1165``` 1166 1167### on('availableAreaChange')<sup>12+</sup> 1168on(type: 'availableAreaChange', callback: Callback<Rect>): void 1169 1170Subscribes to changes of the available area on the screen of the current 2-in-1 device. This API uses an asynchronous callback to return the result. 1171 1172**Atomic service API**: This API can be used in atomic services since API version 12. 1173 1174**System capability**: SystemCapability.Window.SessionManager 1175 1176**Parameters** 1177 1178| Name | Type | Mandatory| Description | 1179| -------- |------------------------------------------| ---- | ------------------------------------------------------- | 1180| type | string | Yes | Event type. The event **'availableAreaChange'** is triggered when the available area of the screen changes.| 1181| callback | Callback<[Rect](#rect9)> | Yes | Callback used to return the new available area.| 1182 1183**Error codes** 1184 1185For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md). 1186 1187| ID| Error Message| 1188| ------- | ----------------------- | 1189| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.| 1190| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 1191| 1400003 | This display manager service works abnormally. | 1192 1193**Example** 1194 1195```ts 1196import { Callback } from '@kit.BasicServicesKit'; 1197import { display } from '@kit.ArkUI'; 1198 1199let callback: Callback<display.Rect> = (data: display.Rect) => { 1200 console.info('Listening enabled. Data: ' + JSON.stringify(data)); 1201}; 1202let displayClass: display.Display | null = null; 1203try { 1204 displayClass = display.getDefaultDisplaySync(); 1205 displayClass.on("availableAreaChange", callback); 1206} catch (exception) { 1207 console.error(`Failed to register callback. Code: ${exception.code}, message: ${exception.message}`); 1208} 1209``` 1210 1211### off('availableAreaChange')<sup>12+</sup> 1212 1213off(type: 'availableAreaChange', callback?: Callback<Rect>): void 1214 1215Unsubscribes from changes of the available area on the screen of the current 2-in-1 device. 1216 1217**Atomic service API**: This API can be used in atomic services since API version 12. 1218 1219**System capability**: SystemCapability.Window.SessionManager 1220 1221**Parameters** 1222 1223| Name | Type | Mandatory| Description | 1224| -------- |------------------------------------------| ---- | ------------------------------------------------------- | 1225| type | string | Yes | Event type. The event **'availableAreaChange'** is triggered when the available area of the screen changes.| 1226| callback | Callback<[Rect](#rect9)> | No | Callback used for unsubscription. If no value is passed in, all subscriptions to the specified event are canceled.| 1227 1228**Error codes** 1229 1230For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md). 1231 1232| ID| Error Message| 1233| ------- | ----------------------- | 1234| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.| 1235| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 1236| 1400003 | This display manager service works abnormally. | 1237 1238**Example** 1239 1240```ts 1241import { Callback } from '@kit.BasicServicesKit'; 1242import { display } from '@kit.ArkUI'; 1243 1244let callback: Callback<display.Rect> = (data: display.Rect) => { 1245 console.info('Listening enabled. Data: ' + JSON.stringify(data)); 1246}; 1247let displayClass: display.Display | null = null; 1248try { 1249 displayClass = display.getDefaultDisplaySync(); 1250 displayClass.off("availableAreaChange", callback); 1251} catch (exception) { 1252 console.error(`Failed to unregister callback. Code: ${exception.code}, message: ${exception.message}`); 1253} 1254``` 1255