1e41f4b71Sopenharmony_ci# @ohos.uiExtensionHost (系统接口)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci仅用于在有进程隔离诉求的UIExtensionComponent组件中为提供方应用提供宿主应用的窗口信息和组件本身的信息。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **说明**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> 后续此接口不再新增功能,相关功能在接口[uiExtension](js-apis-arkui-uiExtension.md)中提供。
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> 从API Version 11开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
10e41f4b71Sopenharmony_ci>
11e41f4b71Sopenharmony_ci> 本模块接口为系统接口。
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci## 导入模块
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci```
16e41f4b71Sopenharmony_ciimport { uiExtensionHost } from '@kit.ArkUI'
17e41f4b71Sopenharmony_ci```
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci## UIExtensionHostWindowProxy
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci### getWindowAvoidArea
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_cigetWindowAvoidArea(type: window.AvoidAreaType): window.AvoidArea
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci获取宿主应用窗口内容规避的区域;如系统栏区域、刘海屏区域、手势区域、软键盘区域等与宿主窗口内容重叠时,需要宿主窗口内容避让的区域。
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.ArkUI.ArkUI.Full
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci**系统接口**:此接口为系统接口,三方应用不支持调用。
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 |
32e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
33e41f4b71Sopenharmony_ci| type | [window.AvoidAreaType](js-apis-window.md#avoidareatype7) | 是 | 表示规避区类型。 |
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci**返回值:**
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci| 类型 | 说明 |
38e41f4b71Sopenharmony_ci| -------- | -------- |
39e41f4b71Sopenharmony_ci| [window.AvoidArea](js-apis-window.md#avoidarea7) | 宿主窗口内容规避区域。 |
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci**返回值:** 
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci| 错误码ID | 错误信息         |
44e41f4b71Sopenharmony_ci| -------- | ---------------- |
45e41f4b71Sopenharmony_ci| 401      | Parameter error. |
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci**示例**
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci```ts
50e41f4b71Sopenharmony_ci// ExtensionProvider.ts
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ciimport { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit';
53e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIExtensionAbility {
56e41f4b71Sopenharmony_ci  onSessionCreate(want: Want, session: UIExtensionContentSession) {
57e41f4b71Sopenharmony_ci    const extensionHostWindow = session.getUIExtensionHostWindowProxy();
58e41f4b71Sopenharmony_ci    // 获取宿主应用窗口的避让信息
59e41f4b71Sopenharmony_ci    const avoidArea = extensionHostWindow.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
60e41f4b71Sopenharmony_ci    console.log(`avoidArea: ${JSON.stringify(avoidArea)}`);
61e41f4b71Sopenharmony_ci  }
62e41f4b71Sopenharmony_ci}
63e41f4b71Sopenharmony_ci```
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci### on('avoidAreaChange')
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_cion(type: 'avoidAreaChange', callback: Callback<{ type: window.AvoidAreaType, area: window.AvoidArea }>): void
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci注册系统规避区变化的监听。
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.ArkUI.ArkUI.Full
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci**系统接口**:此接口为系统接口,三方应用不支持调用。
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci| 参数名   | 类型   | 必填 | 说明                   |
76e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ---------------------- |
77e41f4b71Sopenharmony_ci| type     | string | 是   | 监听的事件类型,固定为'avoidAreaChange',即系统规避区变化事件。 |
78e41f4b71Sopenharmony_ci| callback | [Callback](../apis-basic-services-kit/js-apis-base.md#callback)<{ type: [window.AvoidAreaType](js-apis-window.md#avoidareatype7), area: [window.AvoidArea](js-apis-window.md#avoidarea7) }> | 是 | 回调函数:入参用于接收当前规避区的信息,其中,"type"表示窗口规避区类型,"area"表示窗口内容规避区域。 |
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci**错误码:** 
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
83e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
84e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: <br/> 1. Mandatory parameters are left unspecified.<br/> 2. Incorrect parameters types.<br/> 3. Parameter verification failed. |
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci**示例**
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci```ts
89e41f4b71Sopenharmony_ci// ExtensionProvider.ts
90e41f4b71Sopenharmony_ciimport { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit';
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIExtensionAbility {
93e41f4b71Sopenharmony_ci  onSessionCreate(want: Want, session: UIExtensionContentSession) {
94e41f4b71Sopenharmony_ci    const extensionHostWindow = session.getUIExtensionHostWindowProxy();
95e41f4b71Sopenharmony_ci    // 注册避让区变化的监听
96e41f4b71Sopenharmony_ci    extensionHostWindow.on('avoidAreaChange', (info) => {
97e41f4b71Sopenharmony_ci      console.info(`The avoid area of the host window is: ${JSON.stringify(info.area)}.`);
98e41f4b71Sopenharmony_ci    });
99e41f4b71Sopenharmony_ci  }
100e41f4b71Sopenharmony_ci}
101e41f4b71Sopenharmony_ci```
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci### off('avoidAreaChange')
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_cioff(type: 'avoidAreaChange', callback?: Callback<{ type: window.AvoidAreaType, area: window.AvoidArea }>): void
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci注销系统规避区变化的监听。
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.ArkUI.ArkUI.Full
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci**系统接口**:此接口为系统接口,三方应用不支持调用。
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci| 参数名   | 类型   | 必填 | 说明                   |
114e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ---------------------- |
115e41f4b71Sopenharmony_ci| type     | string | 是   | 注销的事件类型,固定为'avoidAreaChange',即系统规避区变化事件。 |
116e41f4b71Sopenharmony_ci| callback | [Callback](../apis-basic-services-kit/js-apis-base.md#callback)<{ type: [window.AvoidAreaType](js-apis-window.md#avoidareatype7), area: [window.AvoidArea](js-apis-window.md#avoidarea7) }> | 否 | 回调函数:如果传入该参数,则关闭该监听。如果未传入参数,则关闭所有系统规避区变化的监听。 |
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci**错误码:** 
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
121e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
122e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: <br/> 1. Mandatory parameters are left unspecified.<br/> 2. Incorrect parameters types.<br/> 3. Parameter verification failed. |
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci**示例**
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci```ts
127e41f4b71Sopenharmony_ci// ExtensionProvider.ts
128e41f4b71Sopenharmony_ciimport { UIExtensionAbility, UIExtensionContentSession} from '@kit.AbilityKit';
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIExtensionAbility {
131e41f4b71Sopenharmony_ci  onSessionDestroy(session: UIExtensionContentSession) {
132e41f4b71Sopenharmony_ci    const extensionHostWindow = session.getUIExtensionHostWindowProxy();
133e41f4b71Sopenharmony_ci    // 注销所有避让区变化的监听
134e41f4b71Sopenharmony_ci    extensionHostWindow.off('avoidAreaChange');
135e41f4b71Sopenharmony_ci  }
136e41f4b71Sopenharmony_ci}
137e41f4b71Sopenharmony_ci```
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci### on('windowSizeChange')
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_cion(type: 'windowSizeChange', callback: Callback<window.Size>): void
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci注册宿主应用窗口尺寸变化的监听。
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.ArkUI.ArkUI.Full
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci**系统接口**:此接口为系统接口,三方应用不支持调用。
148e41f4b71Sopenharmony_ci
149e41f4b71Sopenharmony_ci| 参数名   | 类型                  | 必填 | 说明                   |
150e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ---------------------- |
151e41f4b71Sopenharmony_ci| type     | string                | 是   | 监听的事件类型,固定为'windowSizeChange',即窗口尺寸变化事件。 |
152e41f4b71Sopenharmony_ci| callback | [Callback](../apis-basic-services-kit/js-apis-base.md#callback)<[window.Size](js-apis-window.md#size7)> | 是   | 回调函数:入参用于接收当前窗口的尺寸。 |
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci**错误码:** 
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
157e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
158e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: <br/> 1. Mandatory parameters are left unspecified.<br/> 2. Incorrect parameters types.<br/> 3. Parameter verification failed. |
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci**示例**
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci```ts
163e41f4b71Sopenharmony_ci// ExtensionProvider.ts
164e41f4b71Sopenharmony_ciimport { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit';
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIExtensionAbility {
167e41f4b71Sopenharmony_ci  onSessionCreate(want: Want, session: UIExtensionContentSession) {
168e41f4b71Sopenharmony_ci    const extensionHostWindow = session.getUIExtensionHostWindowProxy();
169e41f4b71Sopenharmony_ci    // 注册宿主应用窗口大小变化的监听
170e41f4b71Sopenharmony_ci    extensionHostWindow.on('windowSizeChange', (size) => {
171e41f4b71Sopenharmony_ci      console.info(`The avoid area of the host window is: ${JSON.stringify(size)}.`);
172e41f4b71Sopenharmony_ci    });
173e41f4b71Sopenharmony_ci  }
174e41f4b71Sopenharmony_ci}
175e41f4b71Sopenharmony_ci```
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci### off('windowSizeChange')
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_cioff(type: 'windowSizeChange', callback?: Callback<window.Size>): void
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci注销宿主应用窗口尺寸变化的监听。
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.ArkUI.ArkUI.Full
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci**系统接口**:此接口为系统接口,三方应用不支持调用。
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci| 参数名   | 类型                  | 必填 | 说明                   |
188e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ---------------------- |
189e41f4b71Sopenharmony_ci| type     | string                | 是   | 注销的事件类型,固定值:'windowSizeChange',即窗口尺寸变化事件。 |
190e41f4b71Sopenharmony_ci| callback | [Callback](../apis-basic-services-kit/js-apis-base.md#callback)<[window.Size](js-apis-window.md#size7)> | 否   | 回调函数:如果传入该参数,则关闭该监听。如果未传入参数,则关闭所有系统规避区变化的监听。 |
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci**错误码:** 
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
195e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
196e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: <br/> 1. Mandatory parameters are left unspecified.<br/> 2. Incorrect parameters types.<br/> 3. Parameter verification failed. |
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ci**示例**
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci```ts
201e41f4b71Sopenharmony_ci// ExtensionProvider.ts
202e41f4b71Sopenharmony_ciimport { UIExtensionAbility, UIExtensionContentSession } from '@kit.AbilityKit';
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIExtensionAbility {
205e41f4b71Sopenharmony_ci  onSessionDestroy(session: UIExtensionContentSession) {
206e41f4b71Sopenharmony_ci    const extensionHostWindow = session.getUIExtensionHostWindowProxy();
207e41f4b71Sopenharmony_ci    // 注销宿主应用窗口大小变化的监听
208e41f4b71Sopenharmony_ci    extensionHostWindow.off('windowSizeChange');
209e41f4b71Sopenharmony_ci  }
210e41f4b71Sopenharmony_ci}
211e41f4b71Sopenharmony_ci```
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ci### properties
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_ciproperties: UIExtensionHostWindowProxyProperties
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci宿主应用窗口和UIExtensionComponent组件的信息。
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.ArkUI.ArkUI.Full
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_ci**系统接口**:此接口为系统接口,三方应用不支持调用。
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci| 参数名     | 类型                                 | 说明                             |
224e41f4b71Sopenharmony_ci| ---------- | ------------------------------------ | -------------------------------- |
225e41f4b71Sopenharmony_ci| properties | [UIExtensionHostWindowProxyProperties](#uiextensionhostwindowproxyproperties) | UIExtensionComponent组件以及宿主窗口的信息。 |
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci**示例**
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci```ts
230e41f4b71Sopenharmony_ci// ExtensionProvider.ts
231e41f4b71Sopenharmony_ciimport { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit';
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIExtensionAbility {
234e41f4b71Sopenharmony_ci  onSessionCreate(want: Want, session: UIExtensionContentSession) {
235e41f4b71Sopenharmony_ci    const extensionHostWindow = session.getUIExtensionHostWindowProxy();
236e41f4b71Sopenharmony_ci    // 获取UIExtensionComponent位置和大小信息
237e41f4b71Sopenharmony_ci    const rect = extensionHostWindow.properties.uiExtensionHostWindowProxyRect;
238e41f4b71Sopenharmony_ci    console.log(`Rect Info: ${JSON.stringify(rect)}`);
239e41f4b71Sopenharmony_ci  }
240e41f4b71Sopenharmony_ci}
241e41f4b71Sopenharmony_ci```
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci### hideNonSecureWindows
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_cihideNonSecureWindows(shouldHide: boolean): Promise&lt;void&gt;
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci设置是否隐藏不安全窗口。
248e41f4b71Sopenharmony_ci> **说明:**
249e41f4b71Sopenharmony_ci>
250e41f4b71Sopenharmony_ci> 不安全窗口是指可能遮挡UIExtensionComponent的窗口类型,如全局悬浮窗、宿主子窗口和宿主创建的Dialog窗口(不包括系统应用创建的上述类型窗口)。当UIExtensionComponent组件被用来显示敏感操作提示内容时,可以选择隐藏不安全窗口,保护敏感操作提示内容不会被遮挡。当UIExtensionComponent不显示或销毁时需要让不安全窗口重新显示。使用CreateModalUIExtension接口创建的UIExtensionComponent会默认隐藏不安全窗口,若要取消隐藏,需要申请ohos.permission.ALLOW_SHOW_NON_SECURE_WINDOWS权限,并调用本接口将shouldHide设为false。
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.ArkUI.ArkUI.Full
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci**系统接口**:此接口为系统接口,三方应用不支持调用。
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci**参数:**
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ci| 参数名      | 类型                      | 必填 | 说明       |
259e41f4b71Sopenharmony_ci| ----------- | ------------------------- | ---- | ---------- |
260e41f4b71Sopenharmony_ci| shouldHide  | boolean                   | 是   | 指示是否隐藏不安全窗口,true表示隐藏,false表示不隐藏。 |
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci**返回值:**
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci| 类型                | 说明                      |
265e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
266e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
267e41f4b71Sopenharmony_ci
268e41f4b71Sopenharmony_ci**错误码:** 
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
271e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
272e41f4b71Sopenharmony_ci| 202      | Permission verification failed. A non-system application calls a system API. |
273e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: <br> 1. Mandatory parameters are left unspecified. <br> 2. Incorrect parameters types. <br> 3. Parameter verification failed. |
274e41f4b71Sopenharmony_ci| 1300002  | Abnormal state. Possible causes: <br> 1. Permission denied. Interface caller does not have permission "ohos.permission.ALLOW_SHOW_NON_SECURE_WINDOWS". <br> 2. The UIExtension window proxy is abnormal. |
275e41f4b71Sopenharmony_ci| 1300003  | This window manager service works abnormally. |
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ci**示例**
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ci```ts
280e41f4b71Sopenharmony_ci// ExtensionProvider.ts
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ciimport { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit';
283e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIExtensionAbility {
286e41f4b71Sopenharmony_ci  onSessionCreate(want: Want, session: UIExtensionContentSession) {
287e41f4b71Sopenharmony_ci    const extensionHostWindow = session.getUIExtensionHostWindowProxy();
288e41f4b71Sopenharmony_ci    // 隐藏非安全窗口
289e41f4b71Sopenharmony_ci    extensionHostWindow.hideNonSecureWindows(true).then(()=> {
290e41f4b71Sopenharmony_ci      console.log(`Succeeded in hiding the non-secure windows.`);
291e41f4b71Sopenharmony_ci    }).catch((err: BusinessError)=> {
292e41f4b71Sopenharmony_ci      console.log(`Failed to hide the non-secure windows. Cause:${JSON.stringify(err)}`);
293e41f4b71Sopenharmony_ci    })
294e41f4b71Sopenharmony_ci  }
295e41f4b71Sopenharmony_ci  onSessionDestroy(session: UIExtensionContentSession) {
296e41f4b71Sopenharmony_ci    const extensionHostWindow = session.getUIExtensionHostWindowProxy();
297e41f4b71Sopenharmony_ci    // 取消隐藏非安全窗口
298e41f4b71Sopenharmony_ci    extensionHostWindow.hideNonSecureWindows(false).then(()=> {
299e41f4b71Sopenharmony_ci      console.log(`Succeeded in showing the non-secure windows.`);
300e41f4b71Sopenharmony_ci    }).catch((err: BusinessError)=> {
301e41f4b71Sopenharmony_ci      console.log(`Failed to show the non-secure windows. Cause:${JSON.stringify(err)}`);
302e41f4b71Sopenharmony_ci    })
303e41f4b71Sopenharmony_ci  }
304e41f4b71Sopenharmony_ci}
305e41f4b71Sopenharmony_ci```
306e41f4b71Sopenharmony_ci
307e41f4b71Sopenharmony_ci### createSubWindowWithOptions<sup>12+</sup>
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_cicreateSubWindowWithOptions(name: string, subWindowOptions: window.SubWindowOptions): Promise&lt;window.Window&gt;
310e41f4b71Sopenharmony_ci
311e41f4b71Sopenharmony_ci创建该UIExtensionHostWindowProxy实例下的子窗口,使用Promise异步回调。
312e41f4b71Sopenharmony_ci
313e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
314e41f4b71Sopenharmony_ci
315e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口,三方应用不支持调用。
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci**模型约束:** StageModelOnly
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_ci**参数:**
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明           |
322e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------- |
323e41f4b71Sopenharmony_ci| name   | string | 是   | 子窗口的名字。 |
324e41f4b71Sopenharmony_ci| subWindowOptions | [window.SubWindowOptions](js-apis-window.md#subwindowoptions11) | 是 | 子窗口参数。 |
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ci**返回值:**
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ci| 类型                             | 说明                                             |
329e41f4b71Sopenharmony_ci| -------------------------------- | ------------------------------------------------ |
330e41f4b71Sopenharmony_ci| Promise&lt;[window.Window](js-apis-window.md#window)&gt; | Promise对象。返回当前UIExtensionHostWindowProxy下创建的子窗口对象。 |
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ci**错误码:**
333e41f4b71Sopenharmony_ci
334e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
335e41f4b71Sopenharmony_ci
336e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
337e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
338e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: <br/> 1. Mandatory parameters are left unspecified.<br/> 2. Incorrect parameters types.<br/> 3. Parameter verification failed. |
339e41f4b71Sopenharmony_ci| 801 | Capability not supported on this device. |
340e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
341e41f4b71Sopenharmony_ci| 1300005 | This window proxy is abnormal. |
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci**示例:**
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci```ts
346e41f4b71Sopenharmony_ci// ExtensionProvider.ts
347e41f4b71Sopenharmony_ciimport { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit';
348e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
349e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIExtensionAbility {
352e41f4b71Sopenharmony_ci  onSessionCreate(want: Want, session: UIExtensionContentSession) {
353e41f4b71Sopenharmony_ci    const extensionHostWindow = session.getUIExtensionHostWindowProxy();
354e41f4b71Sopenharmony_ci    const subWindowOpts: window.SubWindowOptions = {
355e41f4b71Sopenharmony_ci      title: 'This is a subwindow',
356e41f4b71Sopenharmony_ci      decorEnabled: true
357e41f4b71Sopenharmony_ci    };
358e41f4b71Sopenharmony_ci    // 创建子窗口
359e41f4b71Sopenharmony_ci    extensionHostWindow.createSubWindowWithOptions('subWindowForHost', subWindowOpts)
360e41f4b71Sopenharmony_ci      .then((subWindow: window.Window) => {
361e41f4b71Sopenharmony_ci        subWindow.loadContent('pages/Index', (err, data) =>{
362e41f4b71Sopenharmony_ci          if (err && err.code != 0) {
363e41f4b71Sopenharmony_ci            return;
364e41f4b71Sopenharmony_ci          }
365e41f4b71Sopenharmony_ci          subWindow?.resize(300, 300, (err, data)=>{
366e41f4b71Sopenharmony_ci            if (err && err.code != 0) {
367e41f4b71Sopenharmony_ci              return;
368e41f4b71Sopenharmony_ci            }
369e41f4b71Sopenharmony_ci            subWindow?.moveWindowTo(100, 100, (err, data)=>{
370e41f4b71Sopenharmony_ci              if (err && err.code != 0) {
371e41f4b71Sopenharmony_ci                return;
372e41f4b71Sopenharmony_ci              }
373e41f4b71Sopenharmony_ci              subWindow?.showWindow((err, data) => {
374e41f4b71Sopenharmony_ci                if (err && err.code == 0) {
375e41f4b71Sopenharmony_ci                  console.info(`The subwindow has been shown!`);
376e41f4b71Sopenharmony_ci                } else {
377e41f4b71Sopenharmony_ci                  console.error(`Failed to show the subwindow!`);
378e41f4b71Sopenharmony_ci                }
379e41f4b71Sopenharmony_ci              });
380e41f4b71Sopenharmony_ci            });
381e41f4b71Sopenharmony_ci          });
382e41f4b71Sopenharmony_ci        });
383e41f4b71Sopenharmony_ci      }).catch((error: BusinessError) => {
384e41f4b71Sopenharmony_ci        console.error(`Create subwindow failed: ${JSON.stringify(error)}`);
385e41f4b71Sopenharmony_ci      })
386e41f4b71Sopenharmony_ci  }
387e41f4b71Sopenharmony_ci}
388e41f4b71Sopenharmony_ci```
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci### setWaterMarkFlag<sup>12+</sup>
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_cisetWaterMarkFlag(enable: boolean): Promise&lt;void&gt;
393e41f4b71Sopenharmony_ci
394e41f4b71Sopenharmony_ci为当前窗口添加或删除安全水印标志,使用Promise异步回调。
395e41f4b71Sopenharmony_ci> **说明:**
396e41f4b71Sopenharmony_ci>
397e41f4b71Sopenharmony_ci> 添加安全水印标志后,窗口在前台时会将当前全屏幕覆盖水印。全屏、悬浮窗、分屏等场景下只要有添加了安全水印标志的窗口在前台,就会显示全屏水印。
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.ArkUI.ArkUI.Full
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci**系统接口**:此接口为系统接口,三方应用不支持调用。
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci**参数:**
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_ci| 参数名 | 类型     | 必填 | 说明                                            |
406e41f4b71Sopenharmony_ci| ------ | ------- | --- | ------------------------------------------------ |
407e41f4b71Sopenharmony_ci| enable | boolean | 是   | 是否对窗口添加标志位。true表示添加,false表示删除。 |
408e41f4b71Sopenharmony_ci
409e41f4b71Sopenharmony_ci**返回值:**
410e41f4b71Sopenharmony_ci
411e41f4b71Sopenharmony_ci| 类型                | 说明                      |
412e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
413e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
414e41f4b71Sopenharmony_ci
415e41f4b71Sopenharmony_ci**错误码:**
416e41f4b71Sopenharmony_ci
417e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
418e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------- |
419e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.                 |
420e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally.  |
421e41f4b71Sopenharmony_ci| 1300008 | The operation is on invalid display. |
422e41f4b71Sopenharmony_ci
423e41f4b71Sopenharmony_ci**示例**
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci```ts
426e41f4b71Sopenharmony_ci// ExtensionProvider.ts
427e41f4b71Sopenharmony_ciimport { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit';
428e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIExtensionAbility {
431e41f4b71Sopenharmony_ci  onSessionCreate(want: Want, session: UIExtensionContentSession) {
432e41f4b71Sopenharmony_ci    const extensionHostWindow = session.getUIExtensionHostWindowProxy();
433e41f4b71Sopenharmony_ci    // 添加安全水印标志
434e41f4b71Sopenharmony_ci    extensionHostWindow.setWaterMarkFlag(true).then(() => {
435e41f4b71Sopenharmony_ci      console.log(`Succeeded in setting water mark flag of window.`);
436e41f4b71Sopenharmony_ci    }).catch((err: BusinessError) => {
437e41f4b71Sopenharmony_ci      console.log(`Failed to setting water mark flag of window. Cause:${JSON.stringify(err)}`);
438e41f4b71Sopenharmony_ci    })
439e41f4b71Sopenharmony_ci  }
440e41f4b71Sopenharmony_ci  onSessionDestroy(session: UIExtensionContentSession) {
441e41f4b71Sopenharmony_ci    const extensionHostWindow = session.getUIExtensionHostWindowProxy();
442e41f4b71Sopenharmony_ci    // 删除安全水印标志
443e41f4b71Sopenharmony_ci    extensionHostWindow.setWaterMarkFlag(false).then(() => {
444e41f4b71Sopenharmony_ci      console.log(`Succeeded in deleting water mark flag of window.`);
445e41f4b71Sopenharmony_ci    }).catch((err: BusinessError) => {
446e41f4b71Sopenharmony_ci      console.log(`Failed to deleting water mark flag of window. Cause:${JSON.stringify(err)}`);
447e41f4b71Sopenharmony_ci    })
448e41f4b71Sopenharmony_ci  }
449e41f4b71Sopenharmony_ci}
450e41f4b71Sopenharmony_ci```
451e41f4b71Sopenharmony_ci
452e41f4b71Sopenharmony_ci## UIExtensionHostWindowProxyProperties
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci用于表示宿主应用窗口和UIExtensionComponent组件的信息。
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.ArkUI.ArkUI.Full
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci**系统接口**:此接口为系统接口
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ci| 名称                         | 类型        | 必填      | 说明                             |
461e41f4b71Sopenharmony_ci| ------------------------------ | ----------- | -------------------------------- | -------------------------------- |
462e41f4b71Sopenharmony_ci| uiExtensionHostWindowProxyRect | [window.Rect](js-apis-window.md#rect7) | 是 | UIExtensionComponent的位置和宽高。 |
463e41f4b71Sopenharmony_ci
464e41f4b71Sopenharmony_ci## 完整示例
465e41f4b71Sopenharmony_ci
466e41f4b71Sopenharmony_ci本示例展示文档中所有API在UIExtensionAbility中的基础使用方式,示例应用需采用系统签名,且`bundleName`为"com.example.uiextensiondemo", 被拉起的`UIExtensionAbility`为"ExampleUIExtensionAbility".
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci- 示例应用中的EntryAbility(UIAbility)加载首页文件:`pages/Index.ets`,其中内容如下:
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_ci  ```ts
471e41f4b71Sopenharmony_ci  // pages/Index.ets -- UIAbility启动时加载此页面
472e41f4b71Sopenharmony_ci  import { Want } from '@kit.AbilityKit';
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci  @Entry
475e41f4b71Sopenharmony_ci  @Component
476e41f4b71Sopenharmony_ci  struct Index {
477e41f4b71Sopenharmony_ci    @State message: string = 'Message: '
478e41f4b71Sopenharmony_ci    private want: Want = {
479e41f4b71Sopenharmony_ci      bundleName: "com.example.uiextensiondemo",
480e41f4b71Sopenharmony_ci      abilityName: "ExampleUIExtensionAbility",
481e41f4b71Sopenharmony_ci      parameters: {
482e41f4b71Sopenharmony_ci        "ability.want.params.uiExtensionType": "sys/commonUI"
483e41f4b71Sopenharmony_ci      }
484e41f4b71Sopenharmony_ci    }
485e41f4b71Sopenharmony_ci
486e41f4b71Sopenharmony_ci    build() {
487e41f4b71Sopenharmony_ci      Row() {
488e41f4b71Sopenharmony_ci        Column() {
489e41f4b71Sopenharmony_ci          Text(this.message).fontSize(30)
490e41f4b71Sopenharmony_ci          UIExtensionComponent(this.want)
491e41f4b71Sopenharmony_ci            .width('100%')
492e41f4b71Sopenharmony_ci            .height('90%')
493e41f4b71Sopenharmony_ci        }
494e41f4b71Sopenharmony_ci        .width('100%')
495e41f4b71Sopenharmony_ci      }
496e41f4b71Sopenharmony_ci      .height('100%')
497e41f4b71Sopenharmony_ci    }
498e41f4b71Sopenharmony_ci  }
499e41f4b71Sopenharmony_ci  ```
500e41f4b71Sopenharmony_ci
501e41f4b71Sopenharmony_ci- UIExtensionComponent拉起的UIExtensionAbility在`ets/extensionAbility/ExampleUIExtensionAbility`文件中实现,内容如下:
502e41f4b71Sopenharmony_ci
503e41f4b71Sopenharmony_ci  ```ts
504e41f4b71Sopenharmony_ci  import { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit';
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_ci  const TAG: string = '[ExampleUIExtensionAbility]'
507e41f4b71Sopenharmony_ci  export default class ExampleUIExtensionAbility extends UIExtensionAbility {
508e41f4b71Sopenharmony_ci    onCreate() {
509e41f4b71Sopenharmony_ci      console.log(TAG, `onCreate`);
510e41f4b71Sopenharmony_ci    }
511e41f4b71Sopenharmony_ci
512e41f4b71Sopenharmony_ci    onForeground() {
513e41f4b71Sopenharmony_ci      console.log(TAG, `onForeground`);
514e41f4b71Sopenharmony_ci    }
515e41f4b71Sopenharmony_ci
516e41f4b71Sopenharmony_ci    onBackground() {
517e41f4b71Sopenharmony_ci      console.log(TAG, `onBackground`);
518e41f4b71Sopenharmony_ci    }
519e41f4b71Sopenharmony_ci
520e41f4b71Sopenharmony_ci    onDestroy() {
521e41f4b71Sopenharmony_ci      console.log(TAG, `onDestroy`);
522e41f4b71Sopenharmony_ci    }
523e41f4b71Sopenharmony_ci
524e41f4b71Sopenharmony_ci    onSessionCreate(want: Want, session: UIExtensionContentSession) {
525e41f4b71Sopenharmony_ci      console.log(TAG, `onSessionCreate, want: ${JSON.stringify(want)}`);
526e41f4b71Sopenharmony_ci      let param: Record<string, UIExtensionContentSession> = {
527e41f4b71Sopenharmony_ci        'session': session
528e41f4b71Sopenharmony_ci      };
529e41f4b71Sopenharmony_ci      let storage: LocalStorage = new LocalStorage(param);
530e41f4b71Sopenharmony_ci      session.loadContent('pages/extension', storage);
531e41f4b71Sopenharmony_ci    }
532e41f4b71Sopenharmony_ci  }
533e41f4b71Sopenharmony_ci  ```
534e41f4b71Sopenharmony_ci
535e41f4b71Sopenharmony_ci- UIExtensionAbility的入口页面文件`pages/extension.ets`内容如下:
536e41f4b71Sopenharmony_ci
537e41f4b71Sopenharmony_ci  ```ts
538e41f4b71Sopenharmony_ci  import { UIExtensionContentSession } from '@kit.AbilityKit';
539e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
540e41f4b71Sopenharmony_ci  import { uiExtensionHost, window } from '@kit.ArkUI';
541e41f4b71Sopenharmony_ci
542e41f4b71Sopenharmony_ci  let storage = LocalStorage.getShared()
543e41f4b71Sopenharmony_ci
544e41f4b71Sopenharmony_ci  @Entry(storage)
545e41f4b71Sopenharmony_ci  @Component
546e41f4b71Sopenharmony_ci  struct Extension {
547e41f4b71Sopenharmony_ci    @State message: string = 'UIExtensionAbility Index';
548e41f4b71Sopenharmony_ci    private session: UIExtensionContentSession | undefined = storage.get<UIExtensionContentSession>('session');
549e41f4b71Sopenharmony_ci    private extensionWindow: uiExtensionHost.UIExtensionHostWindowProxy | undefined = this.session?.getUIExtensionHostWindowProxy();
550e41f4b71Sopenharmony_ci    private subWindow: window.Window | undefined = undefined;
551e41f4b71Sopenharmony_ci
552e41f4b71Sopenharmony_ci    aboutToAppear(): void {
553e41f4b71Sopenharmony_ci      this.extensionWindow?.on('windowSizeChange', (size) => {
554e41f4b71Sopenharmony_ci          console.info(`size = ${JSON.stringify(size)}`);
555e41f4b71Sopenharmony_ci      });
556e41f4b71Sopenharmony_ci      this.extensionWindow?.on('avoidAreaChange', (info) => {
557e41f4b71Sopenharmony_ci          console.info(`type = ${JSON.stringify(info.type)}, area = ${JSON.stringify(info.area)}`);
558e41f4b71Sopenharmony_ci      });
559e41f4b71Sopenharmony_ci      let promise = this.extensionWindow?.hideNonSecureWindows(true);
560e41f4b71Sopenharmony_ci      promise?.then(()=> {
561e41f4b71Sopenharmony_ci        console.log(`Succeeded in hiding the non-secure windows.`);
562e41f4b71Sopenharmony_ci      }).catch((err: BusinessError)=> {
563e41f4b71Sopenharmony_ci        console.log(`Failed to hide the non-secure windows. Cause:${JSON.stringify(err)}`);
564e41f4b71Sopenharmony_ci      })
565e41f4b71Sopenharmony_ci    }
566e41f4b71Sopenharmony_ci
567e41f4b71Sopenharmony_ci    aboutToDisappear(): void {
568e41f4b71Sopenharmony_ci      this.extensionWindow?.off('windowSizeChange');
569e41f4b71Sopenharmony_ci      this.extensionWindow?.off('avoidAreaChange');
570e41f4b71Sopenharmony_ci      let promise = this.extensionWindow?.hideNonSecureWindows(false);
571e41f4b71Sopenharmony_ci      promise?.then(()=> {
572e41f4b71Sopenharmony_ci        console.log(`Succeeded in showing the non-secure windows.`);
573e41f4b71Sopenharmony_ci      }).catch((err: BusinessError)=> {
574e41f4b71Sopenharmony_ci        console.log(`Failed to show the non-secure windows. Cause:${JSON.stringify(err)}`);
575e41f4b71Sopenharmony_ci      })
576e41f4b71Sopenharmony_ci    }
577e41f4b71Sopenharmony_ci
578e41f4b71Sopenharmony_ci    build() {
579e41f4b71Sopenharmony_ci      Column() {
580e41f4b71Sopenharmony_ci        Text(this.message)
581e41f4b71Sopenharmony_ci          .fontSize(20)
582e41f4b71Sopenharmony_ci          .fontWeight(FontWeight.Bold)
583e41f4b71Sopenharmony_ci        Button("获取组件大小").width('90%').margin({top: 5, bottom: 5}).fontSize(16).onClick(() => {
584e41f4b71Sopenharmony_ci          let rect = this.extensionWindow?.properties.uiExtensionHostWindowProxyRect;
585e41f4b71Sopenharmony_ci          console.info(`UIExtensionComponent的宽高和位置信息: ${JSON.stringify(rect)}`);
586e41f4b71Sopenharmony_ci        })
587e41f4b71Sopenharmony_ci        Button("获取系统规避区信息").width('90%').margin({top: 5, bottom: 5}).fontSize(16).onClick(() => {
588e41f4b71Sopenharmony_ci          let avoidArea: window.AvoidArea | undefined = this.extensionWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
589e41f4b71Sopenharmony_ci          console.info(`系统规避区: ${JSON.stringify(avoidArea)}`);
590e41f4b71Sopenharmony_ci        })
591e41f4b71Sopenharmony_ci        Button("创建子窗口").width('90%').margin({top: 5, bottom: 5}).fontSize(16).onClick(() => {
592e41f4b71Sopenharmony_ci          let subWindowOpts: window.SubWindowOptions = {
593e41f4b71Sopenharmony_ci            'title': 'This is a subwindow',
594e41f4b71Sopenharmony_ci            decorEnabled: true
595e41f4b71Sopenharmony_ci          };
596e41f4b71Sopenharmony_ci          this.extensionWindow?.createSubWindowWithOptions('subWindowForHost', subWindowOpts)
597e41f4b71Sopenharmony_ci            .then((subWindow: window.Window) => {
598e41f4b71Sopenharmony_ci              this.subWindow = subWindow;
599e41f4b71Sopenharmony_ci              this.subWindow.loadContent('pages/Index', storage, (err, data) =>{
600e41f4b71Sopenharmony_ci                if (err && err.code != 0) {
601e41f4b71Sopenharmony_ci                  return;
602e41f4b71Sopenharmony_ci                }
603e41f4b71Sopenharmony_ci                this.subWindow?.resize(300, 300, (err, data)=>{
604e41f4b71Sopenharmony_ci                  if (err && err.code != 0) {
605e41f4b71Sopenharmony_ci                    return;
606e41f4b71Sopenharmony_ci                  }
607e41f4b71Sopenharmony_ci                  this.subWindow?.moveWindowTo(100, 100, (err, data)=>{
608e41f4b71Sopenharmony_ci                    if (err && err.code != 0) {
609e41f4b71Sopenharmony_ci                      return;
610e41f4b71Sopenharmony_ci                    }
611e41f4b71Sopenharmony_ci                    this.subWindow?.showWindow((err, data) => {
612e41f4b71Sopenharmony_ci                      if (err && err.code == 0) {
613e41f4b71Sopenharmony_ci                        console.info(`The subwindow has been shown!`);
614e41f4b71Sopenharmony_ci                      } else {
615e41f4b71Sopenharmony_ci                        console.error(`Failed to show the subwindow!`);
616e41f4b71Sopenharmony_ci                      }
617e41f4b71Sopenharmony_ci                    });
618e41f4b71Sopenharmony_ci                  });
619e41f4b71Sopenharmony_ci                });
620e41f4b71Sopenharmony_ci              });
621e41f4b71Sopenharmony_ci            }).catch((error: BusinessError) => {
622e41f4b71Sopenharmony_ci              console.error(`Create subwindow failed: ${JSON.stringify(error)}`);
623e41f4b71Sopenharmony_ci            })
624e41f4b71Sopenharmony_ci        })
625e41f4b71Sopenharmony_ci      }.width('100%').height('100%')
626e41f4b71Sopenharmony_ci    }
627e41f4b71Sopenharmony_ci  }
628e41f4b71Sopenharmony_ci  ```
629e41f4b71Sopenharmony_ci
630e41f4b71Sopenharmony_ci- 最后,示例应用的`module.json5`中的"extensionAbilities"中需要增加一项,具体内容如下:
631e41f4b71Sopenharmony_ci  ```json
632e41f4b71Sopenharmony_ci  {
633e41f4b71Sopenharmony_ci    "name": "ExampleUIExtensionAbility",
634e41f4b71Sopenharmony_ci    "srcEntry": "./ets/extensionAbility/ExampleUIExtensionAbility.ets",
635e41f4b71Sopenharmony_ci    "type": "sys/commonUI",
636e41f4b71Sopenharmony_ci  }
637e41f4b71Sopenharmony_ci  ```
638