• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.application.WindowExtensionAbility (WindowExtensionAbility)
2
3**WindowExtensionAbility** inherits from **ExtensionAbility**. The content in a **WindowExtensionAbility** object can be displayed as an ability component in other application windows.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9> The APIs provided by this module are system APIs.
10>
11> The APIs of this module can be used only in the stage model.
12
13## Modules to Import
14
15```ts
16import WindowExtensionAbility from '@ohos.application.WindowExtensionAbility';
17```
18
19## Attributes
20
21**System capability**: SystemCapability.WindowManager.WindowManager.Core
22
23| Name     | Type| Readable| Writable| Description                     |
24| --------- | -------- | ---- | ---- | ------------------------- |
25| context      | [WindowExtensionContext](js-apis-inner-application-windowExtensionContext.md)   | Yes  | No  | Context of an Extension ability.     |
26
27## WindowExtensionAbility.onConnect
28
29onConnect(want: Want): void
30
31Called when this Window Extension ability is connected to an ability for the first time.
32
33**System capability**: SystemCapability.WindowManager.WindowManager.Core
34
35**Parameters**
36
37| Name| Type| Mandatory| Description|
38| -------- | -------- | -------- | -------- |
39| want | [Want](js-apis-application-want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.|
40
41**Example**
42
43```ts
44export default class MyWindowExtensionAbility extends WindowExtensionAbility {
45
46  onConnect(want) {
47    console.info('WindowExtAbility onConnect ' + want.abilityName);
48  }
49
50}
51```
52
53## WindowExtensionAbility.onDisconnect
54
55onDisconnect(want: Want): void
56
57Called when this Window Extension ability is disconnected from all connected abilities.
58
59**System capability**: SystemCapability.WindowManager.WindowManager.Core
60
61**Parameters**
62
63| Name| Type| Mandatory| Description|
64| -------- | -------- | -------- | -------- |
65| want | [Want](js-apis-application-want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.|
66
67
68**Example**
69
70```ts
71export default class MyWindowExtensionAbility extends WindowExtensionAbility {
72
73  onDisconnect(want) {
74    console.info('WindowExtAbility onDisconnect ' + want.abilityName);
75  }
76
77}
78```
79
80## WindowExtensionAbility.onWindowReady
81
82onWindowReady(window: window.Window): void
83
84Called when a window is ready.
85
86**System capability**: SystemCapability.WindowManager.WindowManager.Core
87
88**Parameters**
89
90| Name| Type| Mandatory| Description|
91| -------- | -------- | -------- | -------- |
92| window | [window.Window](js-apis-window.md#window) | Yes| Current **Window** instance.|
93
94
95**Example**
96
97```ts
98export default class MyWindowExtensionAbility extends WindowExtensionAbility {
99
100  onWindowReady(window) {
101    window.loadContent('WindowExtAbility/pages/index1').then(() => {
102      window.getProperties().then((pro) => {
103        console.log('WindowExtension ' + JSON.stringify(pro));
104      });
105      window.show();
106    });
107  }
108
109}
110```
111