1e41f4b71Sopenharmony_ci# @ohos.app.ability.UIExtensionContentSession (UI Operation Class for ExtensionAbilities with UI) (System API) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci**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. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> 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. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> The APIs of this module can be used only in the stage model. 10e41f4b71Sopenharmony_ci> 11e41f4b71Sopenharmony_ci> This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.app.ability.UIExtensionContentSession (UI Operation Class for ExtensionAbilities with UI)](js-apis-app-ability-uiExtensionContentSession.md). 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## Modules to Import 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci```ts 16e41f4b71Sopenharmony_ciimport { UIExtensionContentSession } from '@kit.AbilityKit'; 17e41f4b71Sopenharmony_ci``` 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci## UIExtensionContentSession.sendData 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_cisendData(data: Record\<string, Object>): void 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciSends data to the UIExtensionComponent. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**System API**: This is a system API. 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci**Parameters** 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 32e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 33e41f4b71Sopenharmony_ci| data | Record\<string, Object> | Yes| Data to send.| 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci**Error codes** 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci| ID| Error Message| 40e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 41e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 42e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 43e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci## UIExtensionContentSession.setReceiveDataCallback 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_cisetReceiveDataCallback(callback: (data: Record\<string, Object>) => void): void 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ciSets a callback to receive data from the UIExtensionComponent. This API uses an asynchronous callback to return the result. 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci**System API**: This is a system API. 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci**Parameters** 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 58e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 59e41f4b71Sopenharmony_ci| callback | (data: Record\<string, Object>) => void | Yes| Callback used to return the received data.| 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci**Error codes** 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci| ID| Error Message| 66e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 67e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 68e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 69e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci## UIExtensionContentSession.setReceiveDataForResultCallback<sup>11+</sup> 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_cisetReceiveDataForResultCallback(callback: (data: Record<string, Object>) => Record<string, Object>): void 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ciSets a callback with a return value to receive data from the UIExtensionComponent. This API uses an asynchronous callback to return the result. 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci**System API**: This is a system API. 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci**Parameters** 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description | 85e41f4b71Sopenharmony_ci| -------- | -------- | -------- |----------------| 86e41f4b71Sopenharmony_ci| callback | (data: { [key: string]: Object }) => { [key: string]: Object } | Yes| Callback used to return the received data with a return value.| 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci**Error codes** 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci| ID| Error Message| 93e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 94e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 95e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 96e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci## UIExtensionContentSession.startAbility 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_cistartAbility(want: Want, callback: AsyncCallback<void>): void 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ciStarts an ability. This API uses an asynchronous callback to return the result. 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci> **NOTE** 105e41f4b71Sopenharmony_ci> 106e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md). 107e41f4b71Sopenharmony_ci> The application where the UIExtensionComponent is located must be running in the foreground and gain focus. 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 110e41f4b71Sopenharmony_ci 111e41f4b71Sopenharmony_ci**System API**: This is a system API. 112e41f4b71Sopenharmony_ci 113e41f4b71Sopenharmony_ci**Parameters** 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 116e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 117e41f4b71Sopenharmony_ci| want | [Want](js-apis-app-ability-want.md) | Yes| Want information about the target ability.| 118e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the ability is started, **err** is **undefined**; otherwise, **err** is an error object.| 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ci**Error codes** 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci| ID| Error Message| 125e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 126e41f4b71Sopenharmony_ci| 201 | The application does not have permission to call the interface. | 127e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 128e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 129e41f4b71Sopenharmony_ci| 16000001 | The specified ability does not exist. | 130e41f4b71Sopenharmony_ci| 16000002 | Incorrect ability type. | 131e41f4b71Sopenharmony_ci| 16000004 | Failed to start the invisible ability. | 132e41f4b71Sopenharmony_ci| 16000005 | The specified process does not have the permission. | 133e41f4b71Sopenharmony_ci| 16000006 | Cross-user operations are not allowed. | 134e41f4b71Sopenharmony_ci| 16000008 | The crowdtesting application expires. | 135e41f4b71Sopenharmony_ci| 16000009 | An ability cannot be started or stopped in Wukong mode. | 136e41f4b71Sopenharmony_ci| 16000010 | The call with the continuation flag is forbidden. | 137e41f4b71Sopenharmony_ci| 16000011 | The context does not exist. | 138e41f4b71Sopenharmony_ci| 16000012 | The application is controlled. | 139e41f4b71Sopenharmony_ci| 16000013 | The application is controlled by EDM. | 140e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 141e41f4b71Sopenharmony_ci| 16000053 | The ability is not on the top of the UI. | 142e41f4b71Sopenharmony_ci| 16000055 | Installation-free timed out. | 143e41f4b71Sopenharmony_ci| 16200001 | The caller has been released. | 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci## UIExtensionContentSession.startAbility 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_cistartAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ciStarts an ability with **options** specified. This API uses an asynchronous callback to return the result. 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ci> **NOTE** 152e41f4b71Sopenharmony_ci> 153e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md). 154e41f4b71Sopenharmony_ci> The application where the UIExtensionComponent is located must be running in the foreground and gain focus. 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci**System API**: This is a system API. 159e41f4b71Sopenharmony_ci 160e41f4b71Sopenharmony_ci**Parameters** 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 163e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 164e41f4b71Sopenharmony_ci| want | [Want](js-apis-app-ability-want.md) | Yes| Want information about the target ability.| 165e41f4b71Sopenharmony_ci| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Parameters used for starting the ability.| 166e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the ability is started, **err** is **undefined**; otherwise, **err** is an error object.| 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ci**Error codes** 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 171e41f4b71Sopenharmony_ci 172e41f4b71Sopenharmony_ci| ID| Error Message| 173e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 174e41f4b71Sopenharmony_ci| 201 | The application does not have permission to call the interface. | 175e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 176e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 177e41f4b71Sopenharmony_ci| 16000001 | The specified ability does not exist. | 178e41f4b71Sopenharmony_ci| 16000004 | Failed to start the invisible ability. | 179e41f4b71Sopenharmony_ci| 16000005 | The specified process does not have the permission. | 180e41f4b71Sopenharmony_ci| 16000006 | Cross-user operations are not allowed. | 181e41f4b71Sopenharmony_ci| 16000008 | The crowdtesting application expires. | 182e41f4b71Sopenharmony_ci| 16000009 | An ability cannot be started or stopped in Wukong mode. | 183e41f4b71Sopenharmony_ci| 16000011 | The context does not exist. | 184e41f4b71Sopenharmony_ci| 16000012 | The application is controlled. | 185e41f4b71Sopenharmony_ci| 16000013 | The application is controlled by EDM. | 186e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 187e41f4b71Sopenharmony_ci| 16000053 | The ability is not on the top of the UI. | 188e41f4b71Sopenharmony_ci| 16000055 | Installation-free timed out. | 189e41f4b71Sopenharmony_ci| 16200001 | The caller has been released. | 190e41f4b71Sopenharmony_ci 191e41f4b71Sopenharmony_ci## UIExtensionContentSession.startAbility 192e41f4b71Sopenharmony_ci 193e41f4b71Sopenharmony_cistartAbility(want: Want, options?: StartOptions): Promise<void> 194e41f4b71Sopenharmony_ci 195e41f4b71Sopenharmony_ciStarts an ability. This API uses a promise to return the result. 196e41f4b71Sopenharmony_ci 197e41f4b71Sopenharmony_ci> **NOTE** 198e41f4b71Sopenharmony_ci> 199e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md). 200e41f4b71Sopenharmony_ci> The application where the UIExtensionComponent is located must be running in the foreground and gain focus. 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ci**System API**: This is a system API. 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci**Parameters** 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 209e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 210e41f4b71Sopenharmony_ci| want | [Want](js-apis-app-ability-want.md) | Yes| Want information about the target ability.| 211e41f4b71Sopenharmony_ci| options | [StartOptions](js-apis-app-ability-startOptions.md) | No| Parameters used for starting the ability.| 212e41f4b71Sopenharmony_ci 213e41f4b71Sopenharmony_ci**Return value** 214e41f4b71Sopenharmony_ci 215e41f4b71Sopenharmony_ci| Type| Description| 216e41f4b71Sopenharmony_ci| -------- | -------- | 217e41f4b71Sopenharmony_ci| Promise<void> | Promise that returns no value.| 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_ci**Error codes** 220e41f4b71Sopenharmony_ci 221e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ci| ID| Error Message| 224e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 225e41f4b71Sopenharmony_ci| 201 | The application does not have permission to call the interface. | 226e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 227e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 228e41f4b71Sopenharmony_ci| 16000001 | The specified ability does not exist. | 229e41f4b71Sopenharmony_ci| 16000002 | Incorrect ability type. | 230e41f4b71Sopenharmony_ci| 16000004 | Failed to start the invisible ability. | 231e41f4b71Sopenharmony_ci| 16000005 | The specified process does not have the permission. | 232e41f4b71Sopenharmony_ci| 16000006 | Cross-user operations are not allowed. | 233e41f4b71Sopenharmony_ci| 16000008 | The crowdtesting application expires. | 234e41f4b71Sopenharmony_ci| 16000009 | An ability cannot be started or stopped in Wukong mode. | 235e41f4b71Sopenharmony_ci| 16000010 | The call with the continuation flag is forbidden. | 236e41f4b71Sopenharmony_ci| 16000011 | The context does not exist. | 237e41f4b71Sopenharmony_ci| 16000012 | The application is controlled. | 238e41f4b71Sopenharmony_ci| 16000013 | The application is controlled by EDM. | 239e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 240e41f4b71Sopenharmony_ci| 16000053 | The ability is not on the top of the UI. | 241e41f4b71Sopenharmony_ci| 16000055 | Installation-free timed out. | 242e41f4b71Sopenharmony_ci| 16200001 | The caller has been released. | 243e41f4b71Sopenharmony_ci 244e41f4b71Sopenharmony_ci## UIExtensionContentSession.startAbilityForResult 245e41f4b71Sopenharmony_ci 246e41f4b71Sopenharmony_cistartAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ciStarts an ability and returns the result to the caller after the ability is terminated. This API uses an asynchronous callback to return the result. 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ciAn ability can be terminated in the following ways: 251e41f4b71Sopenharmony_ci - Normally, you can call [terminateSelfWithResult](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult) to terminate the ability. The result is returned to the caller. 252e41f4b71Sopenharmony_ci - If an exception occurs, for example, the ability is killed, an error message, in which **resultCode** is **-1**, is returned to the caller. 253e41f4b71Sopenharmony_ci - If different applications call this API to start an ability that uses the singleton mode and then call [terminateSelfWithResult](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult) to terminate the ability, the normal result is returned to the last caller, and an exception message, in which **resultCode** is **-1**, is returned to others. 254e41f4b71Sopenharmony_ci 255e41f4b71Sopenharmony_ci> **NOTE** 256e41f4b71Sopenharmony_ci> 257e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md). 258e41f4b71Sopenharmony_ci> The application where the UIExtensionComponent is located must be running in the foreground and gain focus. 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 261e41f4b71Sopenharmony_ci 262e41f4b71Sopenharmony_ci**System API**: This is a system API. 263e41f4b71Sopenharmony_ci 264e41f4b71Sopenharmony_ci**Parameters** 265e41f4b71Sopenharmony_ci 266e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 267e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 268e41f4b71Sopenharmony_ci| want |[Want](js-apis-app-ability-want.md) | Yes| Want information about the target ability.| 269e41f4b71Sopenharmony_ci| callback | AsyncCallback<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Yes| Callback used to return the result. If the ability is started and terminated, **err** is **undefined** and **data** is the obtained result code and data; otherwise, **err** is an error object.| 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ci**Error codes** 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_ci| ID| Error Message| 276e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 277e41f4b71Sopenharmony_ci| 201 | The application does not have permission to call the interface. | 278e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 279e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 280e41f4b71Sopenharmony_ci| 16000001 | The specified ability does not exist. | 281e41f4b71Sopenharmony_ci| 16000002 | Incorrect ability type. | 282e41f4b71Sopenharmony_ci| 16000004 | Failed to start the invisible ability. | 283e41f4b71Sopenharmony_ci| 16000005 | The specified process does not have the permission. | 284e41f4b71Sopenharmony_ci| 16000006 | Cross-user operations are not allowed. | 285e41f4b71Sopenharmony_ci| 16000008 | The crowdtesting application expires. | 286e41f4b71Sopenharmony_ci| 16000009 | An ability cannot be started or stopped in Wukong mode. | 287e41f4b71Sopenharmony_ci| 16000010 | The call with the continuation flag is forbidden. | 288e41f4b71Sopenharmony_ci| 16000011 | The context does not exist. | 289e41f4b71Sopenharmony_ci| 16000012 | The application is controlled. | 290e41f4b71Sopenharmony_ci| 16000013 | The application is controlled by EDM. | 291e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 292e41f4b71Sopenharmony_ci| 16000053 | The ability is not on the top of the UI. | 293e41f4b71Sopenharmony_ci| 16000055 | Installation-free timed out. | 294e41f4b71Sopenharmony_ci| 16200001 | The caller has been released. | 295e41f4b71Sopenharmony_ci 296e41f4b71Sopenharmony_ci## UIExtensionContentSession.startAbilityForResult 297e41f4b71Sopenharmony_ci 298e41f4b71Sopenharmony_cistartAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void 299e41f4b71Sopenharmony_ci 300e41f4b71Sopenharmony_ciStarts an ability with **options** specified and returns the result to the caller after the ability is terminated. This API uses an asynchronous callback to return the result. 301e41f4b71Sopenharmony_ci 302e41f4b71Sopenharmony_ciAn ability can be terminated in the following ways: 303e41f4b71Sopenharmony_ci - Normally, you can call [terminateSelfWithResult](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult) to terminate the ability. The result is returned to the caller. 304e41f4b71Sopenharmony_ci - If an exception occurs, for example, the ability is killed, an error message, in which **resultCode** is **-1**, is returned to the caller. 305e41f4b71Sopenharmony_ci - If different applications call this API to start an ability that uses the singleton mode and then call [terminateSelfWithResult](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult) to terminate the ability, the normal result is returned to the last caller, and an exception message, in which **resultCode** is **-1**, is returned to others. 306e41f4b71Sopenharmony_ci 307e41f4b71Sopenharmony_ci> **NOTE** 308e41f4b71Sopenharmony_ci> 309e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md). 310e41f4b71Sopenharmony_ci> The application where the UIExtensionComponent is located must be running in the foreground and gain focus. 311e41f4b71Sopenharmony_ci 312e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 313e41f4b71Sopenharmony_ci 314e41f4b71Sopenharmony_ci**System API**: This is a system API. 315e41f4b71Sopenharmony_ci 316e41f4b71Sopenharmony_ci**Parameters** 317e41f4b71Sopenharmony_ci 318e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 319e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 320e41f4b71Sopenharmony_ci| want |[Want](js-apis-app-ability-want.md) | Yes| Want information about the target ability.| 321e41f4b71Sopenharmony_ci| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Parameters used for starting the ability.| 322e41f4b71Sopenharmony_ci| callback | AsyncCallback<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Yes| Callback used to return the result. If the ability is started and terminated, **err** is **undefined** and **data** is the obtained result code and data; otherwise, **err** is an error object.| 323e41f4b71Sopenharmony_ci 324e41f4b71Sopenharmony_ci**Error codes** 325e41f4b71Sopenharmony_ci 326e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 327e41f4b71Sopenharmony_ci 328e41f4b71Sopenharmony_ci| ID| Error Message| 329e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 330e41f4b71Sopenharmony_ci| 201 | The application does not have permission to call the interface. | 331e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 332e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 333e41f4b71Sopenharmony_ci| 16000001 | The specified ability does not exist. | 334e41f4b71Sopenharmony_ci| 16000004 | Failed to start the invisible ability. | 335e41f4b71Sopenharmony_ci| 16000005 | The specified process does not have the permission. | 336e41f4b71Sopenharmony_ci| 16000006 | Cross-user operations are not allowed. | 337e41f4b71Sopenharmony_ci| 16000008 | The crowdtesting application expires. | 338e41f4b71Sopenharmony_ci| 16000009 | An ability cannot be started or stopped in Wukong mode. | 339e41f4b71Sopenharmony_ci| 16000011 | The context does not exist. | 340e41f4b71Sopenharmony_ci| 16000012 | The application is controlled. | 341e41f4b71Sopenharmony_ci| 16000013 | The application is controlled by EDM. | 342e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 343e41f4b71Sopenharmony_ci| 16000053 | The ability is not on the top of the UI. | 344e41f4b71Sopenharmony_ci| 16000055 | Installation-free timed out. | 345e41f4b71Sopenharmony_ci| 16200001 | The caller has been released. | 346e41f4b71Sopenharmony_ci 347e41f4b71Sopenharmony_ci## UIExtensionContentSession.startAbilityForResult 348e41f4b71Sopenharmony_ci 349e41f4b71Sopenharmony_cistartAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityResult> 350e41f4b71Sopenharmony_ci 351e41f4b71Sopenharmony_ciStarts an ability and returns the result to the caller after the ability is terminated. This API uses a promise to return the result. 352e41f4b71Sopenharmony_ci 353e41f4b71Sopenharmony_ciAn ability can be terminated in the following ways: 354e41f4b71Sopenharmony_ci - Normally, you can call [terminateSelfWithResult](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult) to terminate the ability. The result is returned to the caller. 355e41f4b71Sopenharmony_ci - If an exception occurs, for example, the ability is killed, an error message, in which **resultCode** is **-1**, is returned to the caller. 356e41f4b71Sopenharmony_ci - If different applications call this API to start an ability that uses the singleton mode and then call [terminateSelfWithResult](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult) to terminate the ability, the normal result is returned to the last caller, and an exception message, in which **resultCode** is **-1**, is returned to others. 357e41f4b71Sopenharmony_ci 358e41f4b71Sopenharmony_ci> **NOTE** 359e41f4b71Sopenharmony_ci> 360e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md). 361e41f4b71Sopenharmony_ci> The application where the UIExtensionComponent is located must be running in the foreground and gain focus. 362e41f4b71Sopenharmony_ci 363e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 364e41f4b71Sopenharmony_ci 365e41f4b71Sopenharmony_ci**System API**: This is a system API. 366e41f4b71Sopenharmony_ci 367e41f4b71Sopenharmony_ci**Parameters** 368e41f4b71Sopenharmony_ci 369e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 370e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 371e41f4b71Sopenharmony_ci| want | [Want](js-apis-app-ability-want.md) | Yes| Want information about the target ability.| 372e41f4b71Sopenharmony_ci| options | [StartOptions](js-apis-app-ability-startOptions.md) | No| Parameters used for starting the ability.| 373e41f4b71Sopenharmony_ci 374e41f4b71Sopenharmony_ci 375e41f4b71Sopenharmony_ci**Return value** 376e41f4b71Sopenharmony_ci 377e41f4b71Sopenharmony_ci| Type| Description| 378e41f4b71Sopenharmony_ci| -------- | -------- | 379e41f4b71Sopenharmony_ci| Promise<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Promise used to return the result code and data.| 380e41f4b71Sopenharmony_ci 381e41f4b71Sopenharmony_ci**Error codes** 382e41f4b71Sopenharmony_ci 383e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 384e41f4b71Sopenharmony_ci 385e41f4b71Sopenharmony_ci| ID| Error Message| 386e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 387e41f4b71Sopenharmony_ci| 201 | The application does not have permission to call the interface. | 388e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 389e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 390e41f4b71Sopenharmony_ci| 16000001 | The specified ability does not exist. | 391e41f4b71Sopenharmony_ci| 16000002 | Incorrect ability type. | 392e41f4b71Sopenharmony_ci| 16000004 | Failed to start the invisible ability. | 393e41f4b71Sopenharmony_ci| 16000005 | The specified process does not have the permission. | 394e41f4b71Sopenharmony_ci| 16000006 | Cross-user operations are not allowed. | 395e41f4b71Sopenharmony_ci| 16000008 | The crowdtesting application expires. | 396e41f4b71Sopenharmony_ci| 16000009 | An ability cannot be started or stopped in Wukong mode. | 397e41f4b71Sopenharmony_ci| 16000010 | The call with the continuation flag is forbidden. | 398e41f4b71Sopenharmony_ci| 16000011 | The context does not exist. | 399e41f4b71Sopenharmony_ci| 16000012 | The application is controlled. | 400e41f4b71Sopenharmony_ci| 16000013 | The application is controlled by EDM. | 401e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 402e41f4b71Sopenharmony_ci| 16000053 | The ability is not on the top of the UI. | 403e41f4b71Sopenharmony_ci| 16000055 | Installation-free timed out. | 404e41f4b71Sopenharmony_ci| 16200001 | The caller has been released. | 405e41f4b71Sopenharmony_ci 406e41f4b71Sopenharmony_ci## UIExtensionContentSession.setWindowBackgroundColor 407e41f4b71Sopenharmony_ci 408e41f4b71Sopenharmony_cisetWindowBackgroundColor(color: string): void 409e41f4b71Sopenharmony_ci 410e41f4b71Sopenharmony_ciSets the background color for the loading page of the UIExtensionAbility. This API can be used only after [loadContent()](js-apis-app-ability-uiExtensionContentSession.md#uiextensioncontentsessionloadcontent) is called and takes effect. 411e41f4b71Sopenharmony_ci 412e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 413e41f4b71Sopenharmony_ci 414e41f4b71Sopenharmony_ci**System API**: This is a system API. 415e41f4b71Sopenharmony_ci 416e41f4b71Sopenharmony_ci**Parameters** 417e41f4b71Sopenharmony_ci 418e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 419e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 420e41f4b71Sopenharmony_ci| color | string | Yes| Background color to set. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**.| 421e41f4b71Sopenharmony_ci 422e41f4b71Sopenharmony_ci**Error codes** 423e41f4b71Sopenharmony_ci 424e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 425e41f4b71Sopenharmony_ci 426e41f4b71Sopenharmony_ci| ID| Error Message| 427e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 428e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 429e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 430e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 431e41f4b71Sopenharmony_ci 432e41f4b71Sopenharmony_ci## UIExtensionContentSession.startAbilityAsCaller<sup>11+</sup> 433e41f4b71Sopenharmony_ci 434e41f4b71Sopenharmony_cistartAbilityAsCaller(want: Want, callback: AsyncCallback\<void>): void 435e41f4b71Sopenharmony_ci 436e41f4b71Sopenharmony_ciStarts an ability as the caller. The initial ability places its caller information (such as the bundle name and ability name) in the **want** parameter and transfers the information to an **ExtensionAbility** at the middle layer. When the ExtensionAbility starts another ability by calling this API, the started ability can obtain the caller information of the initial ability from the **onCreate** lifecycle. This API uses an asynchronous callback to return the result. 437e41f4b71Sopenharmony_ci 438e41f4b71Sopenharmony_ci**System API**: This is a system API. 439e41f4b71Sopenharmony_ci 440e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 441e41f4b71Sopenharmony_ci 442e41f4b71Sopenharmony_ci**Parameters** 443e41f4b71Sopenharmony_ci 444e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 445e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 446e41f4b71Sopenharmony_ci| want | [Want](js-apis-app-ability-want.md) | Yes| Want information about the target ability.| 447e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.| 448e41f4b71Sopenharmony_ci 449e41f4b71Sopenharmony_ci**Error codes** 450e41f4b71Sopenharmony_ci 451e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 452e41f4b71Sopenharmony_ci 453e41f4b71Sopenharmony_ci| ID| Error Message| 454e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 455e41f4b71Sopenharmony_ci| 201 | The application does not have permission to call the interface. | 456e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 457e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 458e41f4b71Sopenharmony_ci| 16000001 | The specified ability does not exist. | 459e41f4b71Sopenharmony_ci| 16000002 | Incorrect ability type. | 460e41f4b71Sopenharmony_ci| 16000004 | Failed to start the invisible ability. | 461e41f4b71Sopenharmony_ci| 16000005 | The specified process does not have the permission. | 462e41f4b71Sopenharmony_ci| 16000006 | Cross-user operations are not allowed. | 463e41f4b71Sopenharmony_ci| 16000008 | The crowdtesting application expires. | 464e41f4b71Sopenharmony_ci| 16000009 | An ability cannot be started or stopped in Wukong mode. | 465e41f4b71Sopenharmony_ci| 16000010 | The call with the continuation flag is forbidden. | 466e41f4b71Sopenharmony_ci| 16000011 | The context does not exist. | 467e41f4b71Sopenharmony_ci| 16000012 | The application is controlled. | 468e41f4b71Sopenharmony_ci| 16000013 | The application is controlled by EDM. | 469e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 470e41f4b71Sopenharmony_ci| 16000053 | The ability is not on the top of the UI. | 471e41f4b71Sopenharmony_ci| 16000055 | Installation-free timed out. | 472e41f4b71Sopenharmony_ci| 16200001 | The caller has been released. | 473e41f4b71Sopenharmony_ci 474e41f4b71Sopenharmony_ci## UIExtensionContentSession.startAbilityAsCaller<sup>11+</sup> 475e41f4b71Sopenharmony_ci 476e41f4b71Sopenharmony_cistartAbilityAsCaller(want: Want, options: StartOptions, callback: AsyncCallback\<void>): void 477e41f4b71Sopenharmony_ci 478e41f4b71Sopenharmony_ciStarts an ability as the caller, with **options** specified. The initial ability places its caller information (such as the bundle name and ability name) in the **want** parameter and transfers the information to an **ExtensionAbility** at the middle layer. When the ExtensionAbility starts another ability by calling this API, the started ability can obtain the caller information of the initial ability from the **onCreate** lifecycle. This API uses an asynchronous callback to return the result. 479e41f4b71Sopenharmony_ci 480e41f4b71Sopenharmony_ci**System API**: This is a system API. 481e41f4b71Sopenharmony_ci 482e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 483e41f4b71Sopenharmony_ci 484e41f4b71Sopenharmony_ci**Parameters** 485e41f4b71Sopenharmony_ci 486e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 487e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 488e41f4b71Sopenharmony_ci| want | [Want](js-apis-app-ability-want.md) | Yes| Want information about the target ability.| 489e41f4b71Sopenharmony_ci| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Parameters used for starting the ability.| 490e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.| 491e41f4b71Sopenharmony_ci 492e41f4b71Sopenharmony_ci**Error codes** 493e41f4b71Sopenharmony_ci 494e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 495e41f4b71Sopenharmony_ci 496e41f4b71Sopenharmony_ci| ID| Error Message| 497e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 498e41f4b71Sopenharmony_ci| 201 | The application does not have permission to call the interface. | 499e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 500e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 501e41f4b71Sopenharmony_ci| 16000001 | The specified ability does not exist. | 502e41f4b71Sopenharmony_ci| 16000004 | Failed to start the invisible ability. | 503e41f4b71Sopenharmony_ci| 16000005 | The specified process does not have the permission. | 504e41f4b71Sopenharmony_ci| 16000006 | Cross-user operations are not allowed. | 505e41f4b71Sopenharmony_ci| 16000008 | The crowdtesting application expires. | 506e41f4b71Sopenharmony_ci| 16000009 | An ability cannot be started or stopped in Wukong mode. | 507e41f4b71Sopenharmony_ci| 16000011 | The context does not exist. | 508e41f4b71Sopenharmony_ci| 16000012 | The application is controlled. | 509e41f4b71Sopenharmony_ci| 16000013 | The application is controlled by EDM. | 510e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 511e41f4b71Sopenharmony_ci| 16000053 | The ability is not on the top of the UI. | 512e41f4b71Sopenharmony_ci| 16000055 | Installation-free timed out. | 513e41f4b71Sopenharmony_ci| 16200001 | The caller has been released. | 514e41f4b71Sopenharmony_ci 515e41f4b71Sopenharmony_ci## UIExtensionContentSession.startAbilityAsCaller<sup>11+</sup> 516e41f4b71Sopenharmony_ci 517e41f4b71Sopenharmony_cistartAbilityAsCaller(want: Want, options?: StartOptions): Promise\<void> 518e41f4b71Sopenharmony_ci 519e41f4b71Sopenharmony_ciStarts an ability as the caller. The initial ability places its caller information (such as the bundle name and ability name) in the **want** parameter and transfers the information to an **ExtensionAbility** at the middle layer. When the ExtensionAbility starts another ability by calling this API, the started ability can obtain the caller information of the initial ability from the **onCreate** lifecycle. This API uses a promise to return the result. 520e41f4b71Sopenharmony_ci 521e41f4b71Sopenharmony_ci**System API**: This is a system API. 522e41f4b71Sopenharmony_ci 523e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 524e41f4b71Sopenharmony_ci 525e41f4b71Sopenharmony_ci**Parameters** 526e41f4b71Sopenharmony_ci 527e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 528e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 529e41f4b71Sopenharmony_ci| want | [Want](js-apis-app-ability-want.md) | Yes| Want information about the target ability.| 530e41f4b71Sopenharmony_ci| options | [StartOptions](js-apis-app-ability-startOptions.md) | No| Parameters used for starting the ability.| 531e41f4b71Sopenharmony_ci 532e41f4b71Sopenharmony_ci**Return value** 533e41f4b71Sopenharmony_ci 534e41f4b71Sopenharmony_ci| Type| Description| 535e41f4b71Sopenharmony_ci| -------- | -------- | 536e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value.| 537e41f4b71Sopenharmony_ci 538e41f4b71Sopenharmony_ci**Error codes** 539e41f4b71Sopenharmony_ci 540e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 541e41f4b71Sopenharmony_ci 542e41f4b71Sopenharmony_ci| ID| Error Message| 543e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 544e41f4b71Sopenharmony_ci| 201 | The application does not have permission to call the interface. | 545e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 546e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 547e41f4b71Sopenharmony_ci| 16000001 | The specified ability does not exist. | 548e41f4b71Sopenharmony_ci| 16000002 | Incorrect ability type. | 549e41f4b71Sopenharmony_ci| 16000004 | Failed to start the invisible ability. | 550e41f4b71Sopenharmony_ci| 16000005 | The specified process does not have the permission. | 551e41f4b71Sopenharmony_ci| 16000006 | Cross-user operations are not allowed. | 552e41f4b71Sopenharmony_ci| 16000008 | The crowdtesting application expires. | 553e41f4b71Sopenharmony_ci| 16000009 | An ability cannot be started or stopped in Wukong mode. | 554e41f4b71Sopenharmony_ci| 16000010 | The call with the continuation flag is forbidden. | 555e41f4b71Sopenharmony_ci| 16000011 | The context does not exist. | 556e41f4b71Sopenharmony_ci| 16000012 | The application is controlled. | 557e41f4b71Sopenharmony_ci| 16000013 | The application is controlled by EDM. | 558e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 559e41f4b71Sopenharmony_ci| 16000053 | The ability is not on the top of the UI. | 560e41f4b71Sopenharmony_ci| 16000055 | Installation-free timed out. | 561e41f4b71Sopenharmony_ci| 16200001 | The caller has been released. | 562e41f4b71Sopenharmony_ci 563e41f4b71Sopenharmony_ci## UIExtensionContentSession.getUIExtensionHostWindowProxy<sup>11+</sup> 564e41f4b71Sopenharmony_ci 565e41f4b71Sopenharmony_cigetUIExtensionHostWindowProxy(): uiExtensionHost.UIExtensionHostWindowProxy 566e41f4b71Sopenharmony_ci 567e41f4b71Sopenharmony_ciObtains the window object corresponding to the current UIExtension to notify the width, height, position, and avoided area. 568e41f4b71Sopenharmony_ci 569e41f4b71Sopenharmony_ci**System API**: This is a system API. 570e41f4b71Sopenharmony_ci 571e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 572e41f4b71Sopenharmony_ci 573e41f4b71Sopenharmony_ci**Return value** 574e41f4b71Sopenharmony_ci 575e41f4b71Sopenharmony_ci| Type| Description| 576e41f4b71Sopenharmony_ci| -------- | -------- | 577e41f4b71Sopenharmony_ci| [uiExtensionHost.UIExtensionHostWindowProxy](../apis-arkui/js-apis-uiExtensionHost-sys.md) | Window information of the host application.| 578e41f4b71Sopenharmony_ci 579e41f4b71Sopenharmony_ci**Error codes** 580e41f4b71Sopenharmony_ci 581e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 582e41f4b71Sopenharmony_ci 583e41f4b71Sopenharmony_ci| ID| Error Message| 584e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 585e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. | 586e41f4b71Sopenharmony_ci| 16000050 | Internal error. | 587e41f4b71Sopenharmony_ci 588e41f4b71Sopenharmony_ci**Example** 589e41f4b71Sopenharmony_ci 590e41f4b71Sopenharmony_ci```ts 591e41f4b71Sopenharmony_ciimport { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit'; 592e41f4b71Sopenharmony_ciimport { uiExtensionHost } from '@kit.ArkUI'; 593e41f4b71Sopenharmony_ci 594e41f4b71Sopenharmony_ciconst TAG: string = '[UIExtAbility]'; 595e41f4b71Sopenharmony_ci 596e41f4b71Sopenharmony_ciexport default class UIExtAbility extends UIExtensionAbility { 597e41f4b71Sopenharmony_ci 598e41f4b71Sopenharmony_ci onCreate() { 599e41f4b71Sopenharmony_ci console.log(TAG, `UIExtAbility onCreate`); 600e41f4b71Sopenharmony_ci } 601e41f4b71Sopenharmony_ci 602e41f4b71Sopenharmony_ci onForeground() { 603e41f4b71Sopenharmony_ci console.log(TAG, `UIExtAbility onForeground`); 604e41f4b71Sopenharmony_ci } 605e41f4b71Sopenharmony_ci 606e41f4b71Sopenharmony_ci onBackground() { 607e41f4b71Sopenharmony_ci console.log(TAG, `UIExtAbility onBackground`); 608e41f4b71Sopenharmony_ci } 609e41f4b71Sopenharmony_ci 610e41f4b71Sopenharmony_ci onDestroy() { 611e41f4b71Sopenharmony_ci console.log(TAG, `UIExtAbility onDestroy`); 612e41f4b71Sopenharmony_ci } 613e41f4b71Sopenharmony_ci 614e41f4b71Sopenharmony_ci onSessionCreate(want: Want, session: UIExtensionContentSession) { 615e41f4b71Sopenharmony_ci let extensionHostWindow = session.getUIExtensionHostWindowProxy(); 616e41f4b71Sopenharmony_ci let data: Record<string, UIExtensionContentSession | uiExtensionHost.UIExtensionHostWindowProxy> = { 617e41f4b71Sopenharmony_ci 'session': session, 618e41f4b71Sopenharmony_ci 'extensionHostWindow': extensionHostWindow 619e41f4b71Sopenharmony_ci }; 620e41f4b71Sopenharmony_ci let storage: LocalStorage = new LocalStorage(data); 621e41f4b71Sopenharmony_ci 622e41f4b71Sopenharmony_ci session.loadContent('pages/extension', storage); 623e41f4b71Sopenharmony_ci } 624e41f4b71Sopenharmony_ci 625e41f4b71Sopenharmony_ci onSessionDestroy(session: UIExtensionContentSession) { 626e41f4b71Sopenharmony_ci console.log(TAG, `UIExtAbility onSessionDestroy`); 627e41f4b71Sopenharmony_ci } 628e41f4b71Sopenharmony_ci} 629e41f4b71Sopenharmony_ci``` 630