diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiExtensionContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiExtensionContext.md index f05ce2ccb14a8962de47e77b92af45b19c0bcacc..ffa33ea792c8204734f0c324fe053c9d4eca65fd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiExtensionContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiExtensionContext.md @@ -288,3 +288,97 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes | 16200001 | The caller has been released. | 错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + + +## UIExtensionContext.connectServiceExtensionAbility + +connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; + +将当前Ability连接到一个使用AbilityInfo.AbilityType.SERVICE模板的Ability。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-want.md) | 是 | 连接ServiceExtensionAbility的want信息。 | +| options | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | 是 | 与ServiceExtensionAbility建立连接后回调函数的实例。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 返回Ability连接的结果code。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + + + +## UIExtensionContext.disconnectServiceExtensionAbility + +disconnectServiceExtensionAbility(connection: number): Promise\; + +断开与ServiceExtensionAbility的连接,断开连接之后需要将连接成功时返回的remote对象置空(promise形式)。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| connection | number | 是 | 连接的ServiceExtensionAbility的数字代码,即connectServiceExtensionAbility返回的connectionId。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise\ | 返回执行结果。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + +## UIExtensionContext.disconnectServiceExtensionAbility + +disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback\): void; + +断开与ServiceExtensionAbility的连接,断开连接之后需要将连接成功时返回的remote对象置空(callback形式)。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| connection | number | 是 | 连接的ServiceExtensionAbility的数字代码,即connectServiceExtensionAbility返回的connectionId。 | +| callback | AsyncCallback\ | 是 | callback形式返回断开连接的结果。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)