@ohos.FusionConnectivity.PartnerAgentExtensionAbility (ExtensionAbility Component Supporting Device Status Notifications)
As the base class of the peripheral interconnection extension capability, PartnerAgentExtensionAbility provides the device discovery and device offline notification features. This class needs to be inherited by the application. The type attribute of extensionAbilities in the module-level configuration file module.json5 must be set to partnerAgent.
NOTE
- The initial APIs of this module are supported since API version 23. Newly added APIs will be marked with a superscript to indicate their earliest API version.
- The APIs of this module can be used only in the stage model.
Modules to Import
import { PartnerAgentExtensionAbility, partnerAgent } from '@kit.ConnectivityKit';
PartnerDeviceAddress
type PartnerDeviceAddress = partnerAgent.PartnerDeviceAddress
Describes the device address information.
System capability: SystemCapability.Communication.FusionConnectivity.Core
Model restriction: This API can be used only in the stage model.
| Type | Description |
|---|---|
| partnerAgent.PartnerDeviceAddress | Address of the device to be interconnected. |
PartnerAgentExtensionAbilityDestroyReason
type PartnerAgentExtensionAbilityDestroyReason = partnerAgent.PartnerAgentExtensionAbilityDestroyReason
Describes the reason why PartnerAgentExtensionAbility is destroyed.
System capability: SystemCapability.Communication.FusionConnectivity.Core
Model restriction: This API can be used only in the stage model.
| Type | Description |
|---|---|
| partnerAgent.PartnerAgentExtensionAbilityDestroyReason | Reason why PartnerAgentExtensionAbility is destroyed. |
PartnerAgentExtensionAbility
As the base class of the peripheral interconnection extension capability, PartnerAgentExtensionAbility provides the device discovery and device offline notification features. This class needs to be inherited by the application. It is inherited from ExtensionAbility.
Attribute
System capability: SystemCapability.Communication.FusionConnectivity.Core
Model restriction: This API can be used only in the stage model.
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| context | PartnerAgentExtensionContext | No | No | Context of PartnerAgentExtensionAbility. |
onDestroyWithReason
onDestroyWithReason(reason: PartnerAgentExtensionAbilityDestroyReason): void
Called when the peripheral interconnection extension capability is destroyed.
System capability: SystemCapability.Communication.FusionConnectivity.Core
Model restriction: This API can be used only in the stage model.
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| reason | PartnerAgentExtensionAbilityDestroyReason | Yes | Destruction reason. |
Example
export default class PartnerAgentExtAbility extends PartnerAgentExtensionAbility {
onDestroyWithReason(reason: partnerAgent.PartnerAgentExtensionAbilityDestroyReason): void {
console.info(`onDestroyWithReason is: ${reason}`);
}
}
onDeviceDiscovered
onDeviceDiscovered(deviceAddress: PartnerDeviceAddress): void
Called when a registered device is discovered.
System capability: SystemCapability.Communication.FusionConnectivity.Core
Model restriction: This API can be used only in the stage model.
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| deviceAddress | PartnerDeviceAddress | Yes | Address information of the device registered by the application. The application must be configured with the bluetoothAddress option of the PartnerDeviceAddress type. |
Example
export default class PartnerAgentExtAbility extends PartnerAgentExtensionAbility {
onDeviceDiscovered(deviceAddress: partnerAgent.PartnerDeviceAddress): void {
console.info(`onDeviceDiscovered success: ${deviceAddress.bluetoothAddress}`);
}
}
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 js-apis-bluetooth-a2dp
openharmony 鸿蒙 js-apis-bluetooth-map
openharmony 鸿蒙 capi-oh-bluetooth-h
openharmony 鸿蒙 js-apis-wifiManagerExt
openharmony 鸿蒙 js-apis-bluetooth-ble