• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.app.ability.UIExtensionContentSession (UI Operation Class for ExtensionAbilities with UI)
2
3**UIExtensionContentSession** is an instance created when the [UIExtensionAbility](js-apis-app-ability-uiExtensionAbility.md) loads UI content. When the UIExtensionComponent starts a UIExtensionAbility, the UIExtensionAbility creates a UIExtensionContentSession instance and returns it through the [onSessionCreate](js-apis-app-ability-uiExtensionAbility.md#uiextensionabilityonsessioncreate) callback. One UIExtensionComponent corresponds to one **UIExtensionContentSession** instance, which provides methods such as UI loading and result notification. The **UIExtensionContentSession** instances of multiple UIExtensionAbilities are operated separately.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9> The APIs of this module can be used only in the stage model.
10
11## Modules to Import
12
13```ts
14import { UIExtensionContentSession } from '@kit.AbilityKit';
15```
16
17## UIExtensionContentSession.loadContent
18
19loadContent(path: string, storage?: LocalStorage): void
20
21Loads content from a page associated with a local storage to the window corresponding to the current UIExtensionComponent.
22
23**System capability**: SystemCapability.Ability.AbilityRuntime.Core
24
25**Parameters**
26
27| Name | Type                                           | Mandatory| Description                                                        |
28| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
29| path    | string                                          | Yes  | Path of the page from which the content will be loaded.                                        |
30| storage | [LocalStorage](../../quick-start/arkts-localstorage.md) | No  | A storage unit, which provides storage for variable state properties and non-variable state properties of an application. This parameter is left blank by default.|
31
32**Error codes**
33
34For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
35
36| ID| Error Message|
37| ------- | -------------------------------- |
38| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
39| 16000050 | Internal error. |
40
41**Example**
42
43```ts
44import { UIExtensionContentSession, UIExtensionAbility, Want } from '@kit.AbilityKit';
45
46export default class UIExtAbility extends UIExtensionAbility {
47  // ...
48
49  onSessionCreate(want: Want, session: UIExtensionContentSession): void {
50    let storage: LocalStorage = new LocalStorage();
51    storage.setOrCreate('session', session);
52    session.loadContent('pages/Extension', storage);
53  }
54
55  // ...
56}
57```
58
59## UIExtensionContentSession.loadContentByName<sup>18+</sup>
60
61loadContentByName(name: string, storage?: LocalStorage): void
62
63Loads a [named route](../../ui/arkts-routing.md#named-route) page for a [UIExtensionAbility](./js-apis-app-ability-uiExtensionAbility.md), with state properties passed to the page through [LocalStorage](../../quick-start/arkts-localstorage.md). This API is used to load a named route page in the [onSessionCreate](./js-apis-app-ability-uiExtensionAbility.md#uiextensionabilityonsessioncreate) lifecycle of the UIExtensionAbility.
64
65**System capability**: SystemCapability.Ability.AbilityRuntime.Core
66
67**Parameters**
68
69| Name| Type| Mandatory| Description|
70| ------ | ------ | ------ | ------ |
71| name | string | Yes| Name of the named route page.|
72| storage | [LocalStorage](../../quick-start/arkts-localstorage.md) | No| A page-level UI state storage unit, which is used to pass state properties to the page. The default value is null.|
73
74**Error codes**
75
76For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
77
78| ID| Error Message|
79| ------ | ------ |
80| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
81| 16000050 | Internal error. |
82
83**Example**
84
85Implementation of the UIExtensionAbility:
86```ts
87import { UIExtensionContentSession, UIExtensionAbility, Want } from '@kit.AbilityKit';
88import { BusinessError } from '@kit.BasicServicesKit';
89import './pages/UIExtensionPage'; // Import the named route page. The ./pages/UIExtensionPage.ets file is used as an example in the sample code. Change the path and file name to the actual ones during your development.
90
91export default class UIExtAbility extends UIExtensionAbility {
92  // Other lifecycles and implementations
93
94  onSessionCreate(want: Want, session: UIExtensionContentSession): void {
95    let storage: LocalStorage = new LocalStorage();
96    storage.setOrCreate('session', session);
97
98    let name: string = 'UIExtPage'; // Name of the named route page.
99    try {
100      session.loadContentByName(name, storage);
101    } catch (error) {
102      let code = (error as BusinessError).code;
103      let message = (error as BusinessError).message;
104      console.error(`Failed to load content by name ${name}, code: ${code}, msg: ${message}`);
105    }
106  }
107
108  // Other lifecycles and implementations
109}
110```
111
112Implementation of the named route page loaded by the UIExtensionAbility:
113```ts
114// Implementation of the ./pages/UIExtensionPage.ets file.
115import { UIExtensionContentSession } from '@kit.AbilityKit';
116
117@Entry ({routeName: 'UIExtPage'}) // Use routeName to define the name of the named route page.
118@Component
119struct UIExtensionPage {
120  @State message: string = 'Hello world';
121  storage: LocalStorage | undefined = LocalStorage.getShared();
122  private session: UIExtensionContentSession | undefined = this.storage?.get<UIExtensionContentSession>('session');
123
124  build() {
125    Row() {
126      Column() {
127        Text(this.message)
128          .fontSize(20)
129          .fontWeight(FontWeight.Bold)
130      }
131      .width('100%')
132    }
133    .height('100%')
134  }
135}
136```
137
138## UIExtensionContentSession.terminateSelf
139
140terminateSelf(callback: AsyncCallback&lt;void&gt;): void
141
142Stops the window object corresponding to this **UIExtensionContentSession** instance. This API uses an asynchronous callback to return the result.
143
144**System capability**: SystemCapability.Ability.AbilityRuntime.Core
145
146**Parameters**
147
148| Name| Type| Mandatory| Description|
149| -------- | -------- | -------- | -------- |
150| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the window object is stopped, **err** is **undefined**; otherwise, **err** is an error object.|
151
152**Error codes**
153
154For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
155
156| ID| Error Message|
157| ------- | -------------------------------- |
158| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
159
160**Example**
161
162```ts
163import { UIExtensionContentSession } from '@kit.AbilityKit';
164import { BusinessError } from '@kit.BasicServicesKit';
165
166let storage = LocalStorage.getShared();
167
168@Entry(storage)
169@Component
170struct Index {
171  private session: UIExtensionContentSession | undefined =
172    storage.get<UIExtensionContentSession>('session');
173
174  build() {
175    RelativeContainer() {
176      Button('TerminateSelf')
177        .onClick(() => {
178          this.session?.terminateSelf((err: BusinessError) => {
179            if (err) {
180              console.error(`Failed to terminate self, code: ${err.code}, msg: ${err.message}`);
181              return;
182            }
183            console.info(`Successed in terminating self.`);
184          });
185
186          storage.clear();
187        })
188    }
189    .height('100%')
190    .width('100%')
191  }
192}
193```
194
195## UIExtensionContentSession.terminateSelf
196
197terminateSelf(): Promise&lt;void&gt;
198
199Stops the window object corresponding to this **UIExtensionContentSession** instance. This API uses a promise to return the result.
200
201**System capability**: SystemCapability.Ability.AbilityRuntime.Core
202
203**Return value**
204
205| Type| Description|
206| -------- | -------- |
207| Promise&lt;void&gt; | Promise that returns no value.|
208
209**Example**
210
211```ts
212import { UIExtensionContentSession } from '@kit.AbilityKit';
213import { BusinessError } from '@kit.BasicServicesKit';
214
215let storage = LocalStorage.getShared();
216
217@Entry(storage)
218@Component
219struct Index {
220  private session: UIExtensionContentSession | undefined =
221    storage.get<UIExtensionContentSession>('session');
222
223  build() {
224    RelativeContainer() {
225      Button('TerminateSelf')
226        .onClick(() => {
227          this.session?.terminateSelf()
228            .then(() => {
229              console.info(`Successed in terminating self.`);
230            })
231            .catch((err: BusinessError) => {
232              console.error(`Failed to terminate self, code: ${err.code}, msg: ${err.message}`);
233            });
234
235          storage.clear();
236        })
237    }
238    .height('100%')
239    .width('100%')
240  }
241}
242```
243
244## UIExtensionContentSession.terminateSelfWithResult
245
246terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback&lt;void&gt;): void
247
248Stops the window object corresponding to this **UIExtensionContentSession** instance and returns the result to the UIExtensionComponent. This API uses an asynchronous callback to return the result.
249
250**System capability**: SystemCapability.Ability.AbilityRuntime.Core
251
252**Parameters**
253
254| Name| Type| Mandatory| Description|
255| -------- | -------- | -------- | -------- |
256| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes| Result returned to the UIExtensionComponent.|
257| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the window object is stopped, **err** is **undefined**; otherwise, **err** is an error object.|
258
259**Error codes**
260
261For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
262
263| ID| Error Message|
264| ------- | -------------------------------- |
265| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
266
267**Example**
268
269```ts
270import { UIExtensionContentSession, common } from '@kit.AbilityKit';
271import { BusinessError } from '@kit.BasicServicesKit';
272
273let storage = LocalStorage.getShared();
274
275@Entry(storage)
276@Component
277struct Index {
278  private session: UIExtensionContentSession | undefined =
279    storage.get<UIExtensionContentSession>('session');
280
281  build() {
282    RelativeContainer() {
283      Button('TerminateSelfWithResult')
284        .onClick(() => {
285          let abilityResult: common.AbilityResult = {
286            resultCode: 0,
287            want: {
288              bundleName: 'com.ohos.uiextensioncontentsession',
289              parameters: {
290                'result': 123456
291              }
292            }
293          };
294
295          this.session?.terminateSelfWithResult(abilityResult, (err: BusinessError) => {
296            if (err) {
297              console.error(`Failed to terminate self with result, code: ${err.code}, msg: ${err.message}`);
298              return;
299            }
300            console.info(`Successed in terminating self with result.`);
301          });
302
303          storage.clear();
304        })
305    }
306    .height('100%')
307    .width('100%')
308  }
309}
310```
311
312## UIExtensionContentSession.terminateSelfWithResult
313
314terminateSelfWithResult(parameter: AbilityResult): Promise&lt;void&gt;
315
316Stops the window object corresponding to this **UIExtensionContentSession** instance and returns the result to the UIExtensionComponent. This API uses a promise to return the result.
317
318**System capability**: SystemCapability.Ability.AbilityRuntime.Core
319
320**Parameters**
321
322| Name| Type| Mandatory| Description|
323| -------- | -------- | -------- | -------- |
324| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes| Result returned to the UIExtensionComponent.|
325
326**Return value**
327
328| Type| Description|
329| -------- | -------- |
330| Promise&lt;void&gt; | Promise that returns no value.|
331
332**Error codes**
333
334For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
335
336| ID| Error Message|
337| ------- | -------------------------------- |
338| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
339
340**Example**
341
342```ts
343import { UIExtensionContentSession, common } from '@kit.AbilityKit';
344import { BusinessError } from '@kit.BasicServicesKit';
345
346let storage = LocalStorage.getShared();
347
348@Entry(storage)
349@Component
350struct Index {
351  private session: UIExtensionContentSession | undefined =
352    storage.get<UIExtensionContentSession>('session');
353
354  build() {
355    RelativeContainer() {
356      Button('TerminateSelfWithResult')
357        .onClick(() => {
358          let abilityResult: common.AbilityResult = {
359            resultCode: 0,
360            want: {
361              bundleName: 'com.ohos.uiextensioncontentsession',
362              parameters: {
363                'result': 123456
364              }
365            }
366          };
367
368          this.session?.terminateSelfWithResult(abilityResult)
369            .then(() => {
370              console.info(`Successed in terminating self with result.`);
371            })
372            .catch((err: BusinessError) => {
373              console.error(`Failed to terminate self with result, code: ${err.code}, msg: ${err.message}`);
374            });
375
376          storage.clear();
377        })
378    }
379    .height('100%')
380    .width('100%')
381  }
382}
383```
384
385## UIExtensionContentSession.setWindowPrivacyMode
386
387setWindowPrivacyMode(isPrivacyMode: boolean): Promise&lt;void&gt;
388
389Sets whether the window is in privacy mode. A window in privacy mode cannot be captured or recorded. This API uses a promise to return the result.
390
391**System capability**: SystemCapability.Ability.AbilityRuntime.Core
392
393**Required permissions**: ohos.permission.PRIVACY_WINDOW
394
395**Parameters**
396
397| Name| Type| Mandatory| Description|
398| ------------- | ------- | -- | ----------------------------------------------------- |
399| isPrivacyMode | boolean | Yes| Whether the window is in privacy mode. The value **true** means that the window is in privacy mode, and **false** means the opposite.|
400
401**Return value**
402
403| Type| Description|
404| ------------------- | ------------------------ |
405| Promise&lt;void&gt; | Promise that returns no value.|
406
407**Error codes**
408
409For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
410
411| ID| Error Message|
412| ------- | -------------------------------- |
413| 201      | The application does not have permission to call the interface. |
414| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
415
416**Example**
417
418```ts
419import { UIExtensionContentSession, UIExtensionAbility, Want } from '@kit.AbilityKit';
420import { BusinessError } from '@kit.BasicServicesKit';
421
422export default class UIExtAbility extends UIExtensionAbility {
423  // ...
424
425  onSessionCreate(want: Want, session: UIExtensionContentSession): void {
426    let isPrivacyMode: boolean = true;
427    try {
428      session.setWindowPrivacyMode(isPrivacyMode)
429        .then(() => {
430          console.info(`Successed in setting window to privacy mode.`);
431        })
432        .catch((err: BusinessError) => {
433          console.error(`Failed to set window to privacy mode, code: ${err.code}, msg: ${err.message}`);
434        });
435    } catch (e) {
436      let code = (e as BusinessError).code;
437      let msg = (e as BusinessError).message;
438      console.error(`Failed to set window to privacy mode, code: ${code}, msg: ${msg}`);
439    }
440  }
441
442  // ...
443}
444```
445
446## UIExtensionContentSession.setWindowPrivacyMode
447
448setWindowPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback&lt;void&gt;): void
449
450Sets whether the window is in privacy mode. A window in privacy mode cannot be captured or recorded. This API uses an asynchronous callback to return the result.
451
452**System capability**: SystemCapability.Ability.AbilityRuntime.Core
453
454**Required permissions**: ohos.permission.PRIVACY_WINDOW
455
456**Parameters**
457
458| Name| Type| Mandatory| Description|
459| ------------- | ------------------------- | -- | ------------------------------------------------------ |
460| isPrivacyMode | boolean                   | Yes| Whether the window is in privacy mode. The value **true** means that the window is in privacy mode, and **false** means the opposite. |
461| callback      | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the setting is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
462
463**Error codes**
464
465For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
466
467| ID| Error Message|
468| ------- | -------------------------------- |
469| 201      | The application does not have permission to call the interface. |
470| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
471
472**Example**
473
474```ts
475import { UIExtensionContentSession, UIExtensionAbility, Want } from '@kit.AbilityKit';
476import { BusinessError } from '@kit.BasicServicesKit';
477
478export default class UIExtAbility extends UIExtensionAbility {
479  // ...
480
481  onSessionCreate(want: Want, session: UIExtensionContentSession): void {
482    let isPrivacyMode: boolean = true;
483    try {
484      session.setWindowPrivacyMode(isPrivacyMode, (err: BusinessError) => {
485        if (err) {
486          console.error(`Failed to set window to privacy mode, code: ${err.code}, msg: ${err.message}`);
487          return;
488        }
489        console.info(`Successed in setting window to privacy mode.`);
490      });
491    } catch (e) {
492      let code = (e as BusinessError).code;
493      let msg = (e as BusinessError).message;
494      console.error(`Failed to set window to privacy mode, code: ${code}, msg: ${msg}`);
495    }
496  }
497
498  // ...
499}
500```
501
502## UIExtensionContentSession.startAbilityByType<sup>11+</sup>
503
504startAbilityByType(type: string, wantParam: Record<string, Object>,
505    abilityStartCallback: AbilityStartCallback, callback: AsyncCallback\<void>): void
506
507Implicitly starts a given type of UIExtensionAbility. This API uses an asynchronous callback to return the result. It can be called only by applications running in the foreground.
508
509**System capability**: SystemCapability.Ability.AbilityRuntime.Core
510
511**Parameters**
512
513| Name| Type| Mandatory| Description|
514| -------- | -------- | -------- | -------- |
515| type | string | Yes| Type of the UIExtensionAbility to start.<!--Del--> For details, see [Starting an Application of the Specified Type](../../application-models/start-intent-panel.md#matching-rules).<!--DelEnd-->|
516| wantParam | Record<string, Object> | Yes| Extended parameter.|
517| abilityStartCallback | [AbilityStartCallback](js-apis-inner-application-abilityStartCallback.md) | Yes| Callback used to return the detailed error information if the startup fails.|
518| callback | AsyncCallback\<void> | Yes|Callback used to return the result. If the ability is started, **err** is **undefined**; otherwise, **err** is an error object.|
519
520**Error codes**
521
522For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
523
524| ID| Error Message|
525| ------- | -------------------------------- |
526| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
527| 16000050 | Internal error. |
528
529**Example**
530
531```ts
532import { UIExtensionContentSession, UIExtensionAbility, Want, common } from '@kit.AbilityKit';
533import { BusinessError } from '@kit.BasicServicesKit';
534
535export default class UIExtAbility extends UIExtensionAbility {
536  // ...
537
538  onSessionCreate(want: Want, session: UIExtensionContentSession): void {
539    let wantParams: Record<string, Object> = {
540      'sceneType': 1
541    };
542    let abilityStartCallback: common.AbilityStartCallback = {
543      onError: (code: number, name: string, message: string) => {
544        console.error(`onError, code: ${code}, name: ${name}, msg: ${message}`);
545      },
546      onResult: (result: common.AbilityResult) => {
547        console.info(`onResult, result: ${JSON.stringify(result)}`);
548      }
549    };
550
551    session.startAbilityByType('test', wantParams, abilityStartCallback, (err: BusinessError) => {
552      if (err) {
553        console.error(`Failed to startAbilityByType, code: ${err.code}, msg: ${err.message}`);
554        return;
555      }
556      console.info(`Successed in startAbilityByType`);
557    });
558  }
559
560  // ...
561}
562```
563
564## UIExtensionContentSession.startAbilityByType<sup>11+</sup>
565
566startAbilityByType(type: string, wantParam: Record<string, Object>,
567    abilityStartCallback: AbilityStartCallback): Promise\<void>
568
569Implicitly starts a given type of UIExtensionAbility. This API uses a promise to return the result. It can be called only by applications running in the foreground.
570
571**System capability**: SystemCapability.Ability.AbilityRuntime.Core
572
573**Parameters**
574
575| Name| Type| Mandatory| Description|
576| -------- | -------- | -------- | -------- |
577| type | string | Yes| Type of the UIExtensionAbility to start.<!--Del--> For details, see [Starting an Application of the Specified Type](../../application-models/start-intent-panel.md#matching-rules).<!--DelEnd-->|
578| wantParam | Record<string, Object> | Yes| Extended parameter.|
579| abilityStartCallback | [AbilityStartCallback](js-apis-inner-application-abilityStartCallback.md) | Yes| Callback used to return the detailed error information if the startup fails.|
580
581**Return value**
582
583| Type| Description|
584| -------- | -------- |
585| Promise\<void> | Promise that returns no value.|
586
587**Error codes**
588
589For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
590
591| ID| Error Message|
592| ------- | -------------------------------- |
593| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
594| 16000050 | Internal error. |
595
596**Example**
597
598```ts
599import { UIExtensionContentSession, UIExtensionAbility, Want, common } from '@kit.AbilityKit';
600import { BusinessError } from '@kit.BasicServicesKit';
601
602export default class UIExtAbility extends UIExtensionAbility {
603  // ...
604
605  onSessionCreate(want: Want, session: UIExtensionContentSession): void {
606    let wantParams: Record<string, Object> = {
607      'sceneType': 1
608    };
609    let abilityStartCallback: common.AbilityStartCallback = {
610      onError: (code: number, name: string, message: string) => {
611        console.error(`onError, code: ${code}, name: ${name}, msg: ${message}`);
612      },
613      onResult: (result: common.AbilityResult) => {
614        console.info(`onResult, result: ${JSON.stringify(result)}`);
615      }
616    };
617
618    session.startAbilityByType('test', wantParams, abilityStartCallback)
619      .then(() => {
620        console.info(`Successed in startAbilityByType`);
621      })
622      .catch((err: BusinessError) => {
623        console.error(`Failed to startAbilityByType, code: ${err.code}, msg: ${err.message}`);
624      });
625  }
626
627  // ...
628}
629```
630
631## UIExtensionContentSession.getUIExtensionWindowProxy<sup>12+</sup>
632
633getUIExtensionWindowProxy(): uiExtension.WindowProxy
634
635Obtains the window proxy of this UIExtensionAbility.
636
637**System capability**: SystemCapability.Ability.AbilityRuntime.Core
638
639**Return value**
640
641| Type| Description|
642| -------- | -------- |
643| uiExtension.WindowProxy | Window proxy.|
644
645**Error codes**
646
647For details about the error codes, see [Ability Error Codes](errorcode-ability.md).
648
649| ID| Error Message|
650| ------- | -------------------------------- |
651| 16000050 | Internal error. |
652
653**Example**
654
655```ts
656// Index.ets
657import { UIExtensionContentSession } from '@kit.AbilityKit';
658import uiExtension from '@ohos.arkui.uiExtension';
659
660let storage = LocalStorage.getShared();
661
662@Entry(storage)
663@Component
664struct Extension {
665  @State message: string = 'EmbeddedUIExtensionAbility Index';
666  private session: UIExtensionContentSession | undefined = storage.get<UIExtensionContentSession>('session');
667  private extensionWindow: uiExtension.WindowProxy | undefined = this.session?.getUIExtensionWindowProxy();
668
669  aboutToAppear(): void {
670    this.extensionWindow?.on('windowSizeChange', (size) => {
671      console.info(`size = ${JSON.stringify(size)}`);
672    });
673    this.extensionWindow?.on('avoidAreaChange', (info) => {
674      console.info(`type = ${JSON.stringify(info.type)}, area = ${JSON.stringify(info.area)}`);
675    });
676  }
677
678  aboutToDisappear(): void {
679    this.extensionWindow?.off('windowSizeChange');
680    this.extensionWindow?.off('avoidAreaChange');
681  }
682
683  build() {
684    Column() {
685      Text(this.message)
686        .fontSize(20)
687        .fontWeight(FontWeight.Bold)
688    }
689    .width('100%')
690  }
691}
692```
693