目录

ShareKitManager

Class Info

public class ShareKitManager

Share Engine management class used to call the Share Engine capabilities.

Public Constructor Summary

Constructor name

ShareKitManager(@NonNull Context context)

Constructs a ShareKitManager instance.

Public Method Summary

Qualifier and Type

Method Name and Description

void

init(IShareKitInitCallback callback)

Initializes Share Engine capabilities.

void

uninit()

Releases Share Engine capabilities.

int

getShareStatus()

Obtains the Share Engine capability status.

int

enable()

Enables Bluetooth and Wi-Fi.

int

startDiscovery()

Starts to discover devices.

int

stopDiscovery()

Stops discovering devices.

List<NearByDeviceEx>

getDeviceList()

Obtains the devices processing sharing.

int

registerCallback(IWidgetCallback callback)

Registers a callback API.

int

unregisterCallback(IWidgetCallback callback)

Unregisters a callback API.

int

doSend(NearByDeviceEx device, ShareBean bean)

Sends shared content.

int

cancelSend(NearByDeviceEx device)

Cancels sending.

int

startDiscoverable()

Sets the device to be discoverable.

int

stopDiscoverable()

Sets the device to be non-discoverable.

void

setWifiP2pManagerEx(IWifiP2pManagerEx wifiP2pManagerEx)

Sets the southbound API (required for non-Huawei phones to receive shared content through Wi-Fi Direct).

void

clearWifiP2pManagerEx()

Clears the southbound API.

Public Constructors

[h2]ShareKitManager

constructor

ShareKitManager(@NonNull Context context)

Constructs a ShareKitManager instance.

Parameters

Name

Description

context

App context.

Public Methods

[h2]init

Method

void init(IShareKitInitCallback callback)

Initializes Share Engine capabilities.

Parameters

Name

Description

callback

Callback instance for ShareKitManager initialization.

[h2]uninit

Method

void uninit()

Releases Share Engine capabilities.

[h2]getShareStatus

Method

int getShareStatus()

Obtains the Share Engine capability status.

Return

Type

Description

int

0: Normal

Result code: For details, please refer to the description in KitResult.

[h2]enable

Method

int enable()

Enables Bluetooth and Wi-Fi.

Return

Type

Description

int

Result code: For details, please refer to the description in KitResult.

[h2]startDiscovery

Method

int startDiscovery()

Starts to discover devices.

Return

Type

Description

int

Result code: For details, please refer to the description in KitResult.

[h2]stopDiscovery

Method

int stopDiscovery()

Stops discovering devices.

Return

Type

Description

int

Result code: For details, please refer to the description in KitResult.

[h2]getDeviceList

Method

List<NearByDeviceEx> getDeviceList()

Obtains the devices processing sharing.

Return

Type

Description

List<NearByDeviceEx>

List of the devices processing sharing.

[h2]registerCallback

Method

int registerCallback(IWidgetCallback callback)

Registers a callback API.

Parameters

Name

Description

callback

Callback instance for Share Engine.

Return

Type

Description

int

Result code. For details, please refer to the section "KitResult".

[h2]unregisterCallback

Method

int unregisterCallback(IWidgetCallback callback)

Unregisters a callback API.

Parameters

Name

Description

callback

Callback instance for Share Engine.

Return

Type

Description

int

Result code. For details, please refer to the section "KitResult".

[h2]doSend

Method

int doSend(NearByDeviceEx device, ShareBean bean)

Sends shared content.

Parameters

Name

Description

device

ID of the peer device.

bean

Shared information.

Return

Type

Description

int

Result code. For details, please refer to the section "KitResult".

[h2]cancelSend

Method

int cancelSend(NearByDeviceEx device)

Cancels sending.

Parameters

Name

Description

device

ID of the peer device.

Return

Type

Description

int

Result code. For details, please refer to the section "KitResult".

[h2]startDiscoverable

Method

int startDiscoverable()

Sets the device to be discoverable.

Return

Type

Description

int

Result code. For details, please refer to the section "KitResult".

[h2]stopDiscoverable

Method

int stopDiscoverable ()

Sets the device to be non-discoverable.

Return

Type

Description

int

Result code. For details, please refer to the section "KitResult".

[h2]setWifiP2pManagerEx

Method

void setWifiP2pManagerEx(IWifiP2pManagerEx wifiP2pManagerEx)

Sets the southbound API (required for non-Huawei phones to receive shared content through Wi-Fi Direct).

Parameters

Name

Description

wifiP2pManagerEx

Southbound API instance.

[h2]clearWifiP2pManagerEx

Method

void clearWifiP2pManagerEx()

Clears the southbound API.