public class WifiP2pManager
extends Object
| java.lang.Object | |
| android.net.wifi.p2p.WifiP2pManager | |
该课程提供用于管理Wi-Fi点对点连接的API。 这可以让应用程序发现可用的对等点,建立与对等点的连接并查询对等点列表。 当通过wifi形成p2p连接时,设备继续通过移动设备或任何其他可用网络维持设备上的互联网连接的上行链路连接。
该API是异步的,并且对来自应用程序的请求的响应在应用程序提供的侦听器回调上。 在执行任何p2p操作之前,应用程序需要使用initialize(Context, Looper, WifiP2pManager.ChannelListener)进行初始化。
大多数应用程序调用需要WifiP2pManager.ActionListener实例来接收回调onSuccess()或onFailure(int) 。 行动回调表明行动的开始是成功还是失败。 如果失败,失败的原因可以是一个ERROR , P2P_UNSUPPORTED或BUSY 。
应用程序可以使用discoverPeers(WifiP2pManager.Channel, WifiP2pManager.ActionListener)启动发现对discoverPeers(WifiP2pManager.Channel, WifiP2pManager.ActionListener) 。 从应用程序发起的发现请求保持活动状态,直到设备开始连接到对等体,形成p2p组或者有明确的stopPeerDiscovery(WifiP2pManager.Channel, WifiP2pManager.ActionListener) 。 应用程序可以收听WIFI_P2P_DISCOVERY_CHANGED_ACTION以了解对等发现是否正在运行或停止。 此外, WIFI_P2P_PEERS_CHANGED_ACTION指示对等列表是否已更改。
当应用程序需要获取当前对等列表时,它可以通过requestPeers(WifiP2pManager.Channel, WifiP2pManager.PeerListListener)请求对等列表。 当对等列表可用时, onPeersAvailable(WifiP2pDeviceList)与设备列表onPeersAvailable(WifiP2pDeviceList)被调用。
应用程序可以通过connect(WifiP2pManager.Channel, WifiP2pConfig, WifiP2pManager.ActionListener)向对等方发起连接请求。 有关设置配置的详细信息,请参见WifiP2pConfig 。 为了与不支持p2p的传统Wi-Fi设备进行通信,应用程序可以使用createGroup(WifiP2pManager.Channel, WifiP2pManager.ActionListener)创建一个组,从而创建一个访问点,其详细信息可以通过requestGroupInfo(WifiP2pManager.Channel, WifiP2pManager.GroupInfoListener)获取。
在成功通过createGroup(WifiP2pManager.Channel, WifiP2pManager.ActionListener)或connect(WifiP2pManager.Channel, WifiP2pConfig, WifiP2pManager.ActionListener)成功后,请使用requestConnectionInfo(WifiP2pManager.Channel, WifiP2pManager.ConnectionInfoListener)获取连接详细信息。 连接信息WifiP2pInfo包含组拥有者groupOwnerAddress的地址和用于指示当前设备是否是p2p组拥有者的标志isGroupOwner 。 因此,p2p客户端可以通过套接字连接与p2p组所有者进行通信。
通过使用discoverPeers(WifiP2pManager.Channel, WifiP2pManager.ActionListener)对等体发现,应用程序发现邻居对等体,但没有好方法找出哪个对等体与之建立连接。 例如,如果游戏应用程序有兴趣找到所有也在运行相同游戏的邻居对等点,那么直到连接建立之后才能找到它。 预关联服务发现旨在解决基于正在运行的服务过滤对等点的问题。
通过预关联服务发现,应用程序可以在设备之间建立连接之前为对等设备上的应用程序通告服务。 目前,基于DNS的服务发现(Bonjour)和Upnp是支持的更高层协议。 获取dns-sd.org上的Bonjour资源以及upnp.org上的Upnp资源作为示例,视频应用程序可以在与设备建立Wi-Fi p2p连接之前发现支持Upnp的媒体渲染器。
应用程序可以通过调用addLocalService(WifiP2pManager.Channel, WifiP2pServiceInfo, WifiP2pManager.ActionListener)来宣传Upnp或Bonjour服务。 添加本地服务后,框架在建立p2p连接之前自动响应发现该服务的对等应用程序。 呼叫removeLocalService(WifiP2pManager.Channel, WifiP2pServiceInfo, WifiP2pManager.ActionListener)删除本地服务, clearLocalServices(WifiP2pManager.Channel, WifiP2pManager.ActionListener)可用于清除所有本地服务。
寻找支持某些服务的对等设备的应用程序可以通过拨打discoverServices(WifiP2pManager.Channel, WifiP2pManager.ActionListener)来discoverServices(WifiP2pManager.Channel, WifiP2pManager.ActionListener) 。 在此之前开始发现,应用程序可以添加一个调用服务发现请求addServiceRequest(WifiP2pManager.Channel, WifiP2pServiceRequest, WifiP2pManager.ActionListener) ,删除与一个呼叫的服务发现请求removeServiceRequest(WifiP2pManager.Channel, WifiP2pServiceRequest, WifiP2pManager.ActionListener)或清除与到呼叫所有请求clearServiceRequests(WifiP2pManager.Channel, WifiP2pManager.ActionListener) 。 当没有服务请求时,以前运行的服务发现将停止。 应用程序通过通过setDnsSdResponseListeners(WifiP2pManager.Channel, WifiP2pManager.DnsSdServiceResponseListener, WifiP2pManager.DnsSdTxtRecordListener)设置Bonjour或setUpnpServiceResponseListener(WifiP2pManager.Channel, WifiP2pManager.UpnpServiceResponseListener)为Upnp设置的监听器回调通知服务发现请求的结果。
注意:使用initialize(Context, Looper, WifiP2pManager.ChannelListener)注册应用程序处理程序需要权限ACCESS_WIFI_STATE和CHANGE_WIFI_STATE才能执行任何进一步的对等操作。 通过调用Context.getSystemService(Context.WIFI_P2P_SERVICE)获取此类的实例。
Nested classes |
|
|---|---|
interface |
WifiP2pManager.ActionListener 应用程序操作的回调调用接口 |
class |
WifiP2pManager.Channel 将应用程序连接到Wifi p2p框架的渠道。 |
interface |
WifiP2pManager.ChannelListener 当框架通道丢失时,用于回调调用的接口 |
interface |
WifiP2pManager.ConnectionInfoListener 当连接信息可用时,用于回调调用的接口 |
interface |
WifiP2pManager.DnsSdServiceResponseListener 接收到Bonjour服务发现响应时的回调调用接口 |
interface |
WifiP2pManager.DnsSdTxtRecordListener Bonjour TXT记录可用于服务时的回调调用接口 |
interface |
WifiP2pManager.GroupInfoListener 组信息可用时的回调调用接口 |
interface |
WifiP2pManager.PeerListListener 对等列表可用时的回调调用接口 |
interface |
WifiP2pManager.ServiceResponseListener 接收到Upnp或Bonjour以外的服务发现响应时的回调调用接口 |
interface |
WifiP2pManager.UpnpServiceResponseListener 接收upnp服务发现响应时的回调调用接口 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
String EXTRA_DISCOVERY_STATE
int的查找键,指示p2p发现是否已启动或停止。 用getIntExtra(String, int)检索。
常量值:“discoveryState”
String EXTRA_NETWORK_INFO
与p2p网络关联的NetworkInfo对象的查找键。 用getParcelableExtra(String)检索。
常量值:“networkInfo”
String EXTRA_P2P_DEVICE_LIST
发送 WIFI_P2P_PEERS_CHANGED_ACTION广播时代表新对等列表的 WifiP2pDeviceList对象的查找键。
用 getParcelableExtra(String)检索。
常量值:“wifiP2pDeviceList”
String EXTRA_WIFI_P2P_DEVICE
为查找关键 WifiP2pDevice对象获取与 getParcelableExtra(String) 。
常数值:“wifiP2pDevice”
String EXTRA_WIFI_P2P_GROUP
与p2p网络关联的WifiP2pGroup对象的查找键。 用getParcelableExtra(String)检索。
常量值:“p2pGroupInfo”
String EXTRA_WIFI_P2P_INFO
为查找关键 WifiP2pInfo对象获取与 getParcelableExtra(String) 。
常数值:“wifiP2pInfo”
String EXTRA_WIFI_STATE
用于指示Wi-Fi p2p是启用还是禁用的int查找键。 用getIntExtra(String, int)检索。
常量值:“wifi_p2p_state”
int NO_SERVICE_REQUESTS
通过onFailure(int) 。 表示discoverServices(WifiP2pManager.Channel, WifiP2pManager.ActionListener)失败,因为没有添加服务请求。 使用addServiceRequest(WifiP2pManager.Channel, WifiP2pServiceRequest, WifiP2pManager.ActionListener)添加服务请求。
常量值:3(0x00000003)
int P2P_UNSUPPORTED
通过onFailure(int) 。 表示操作失败,因为设备上不支持p2p。
常数值:1(0x00000001)
String WIFI_P2P_CONNECTION_CHANGED_ACTION
广播意图操作指示Wi-Fi p2p连接状态已更改。 一个额外的EXTRA_WIFI_P2P_INFO以WifiP2pInfo对象的形式提供p2p连接信息。 另一个额外的EXTRA_NETWORK_INFO以NetworkInfo的形式提供网络信息。 第三个额外提供了该组的详细信息。
常量值:“android.net.wifi.p2p.CONNECTION_STATE_CHANGE”
String WIFI_P2P_DISCOVERY_CHANGED_ACTION
广播意图操作指示对等方发现已启动或停止。 一个额外的EXTRA_DISCOVERY_STATE指示发现是否已经开始或停止。
请注意,发现将在连接设置期间停止。 如果应用程序尝试在此期间重新发起发现,则可能会失败。
常量值:“android.net.wifi.p2p.DISCOVERY_STATE_CHANGE”
int WIFI_P2P_DISCOVERY_STARTED
p2p发现已经开始
常量值:2(0x00000002)
int WIFI_P2P_DISCOVERY_STOPPED
p2p发现已停止
常数值:1(0x00000001)
String WIFI_P2P_PEERS_CHANGED_ACTION
广播意图操作,指示可用对等列表已更改。 这可以通过找到,丢失或更新的同伴来发送。
一个额外的EXTRA_P2P_DEVICE_LIST提供了当前同行的完整列表。 requestPeers(WifiP2pManager.Channel, WifiP2pManager.PeerListListener)也可以随时获得完整的同伴列表。
也可以看看:
常量值:“android.net.wifi.p2p.PEERS_CHANGED”
String WIFI_P2P_STATE_CHANGED_ACTION
广播意图操作以指示Wi-Fi p2p是启用还是禁用。 额外的EXTRA_WIFI_STATE以int EXTRA_WIFI_STATE提供状态信息。
也可以看看:
常量值:“android.net.wifi.p2p.STATE_CHANGED”
int WIFI_P2P_STATE_DISABLED
Wi-Fi p2p已禁用。
常数值:1(0x00000001)
int WIFI_P2P_STATE_ENABLED
Wi-Fi p2p已启用。
常量值:2(0x00000002)
String WIFI_P2P_THIS_DEVICE_CHANGED_ACTION
广播意图操作指示此设备的详细信息已更改。
常量值:“android.net.wifi.p2p.THIS_DEVICE_CHANGED”
void addLocalService (WifiP2pManager.Channel c, WifiP2pServiceInfo servInfo, WifiP2pManager.ActionListener listener)
注册本地服务以进行服务发现。 如果本地服务已注册,框架会自动响应来自对等方的服务发现请求。
函数调用在发送请求以将本地服务添加到框架后立即返回。 通过侦听器回调onSuccess()或onFailure(int)向应用程序通知添加服务成功或失败。
服务信息通过WifiP2pServiceInfo设置。
或其子类分别为Upnp或Bonjour服务调用newInstance(String, String, List
或newInstance(String, String, Map
服务信息可以通过拨打 removeLocalService(WifiP2pManager.Channel, WifiP2pServiceInfo, WifiP2pManager.ActionListener)或 clearLocalServices(WifiP2pManager.Channel, WifiP2pManager.ActionListener)来清除。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
servInfo |
WifiP2pServiceInfo: is a local service information. |
listener |
WifiP2pManager.ActionListener: for callbacks on success or failure. Can be null. |
void addServiceRequest (WifiP2pManager.Channel c, WifiP2pServiceRequest req, WifiP2pManager.ActionListener listener)
添加服务发现请求。
函数调用在向框架发送添加服务发现请求的请求之后立即返回。 通过监听器回调onSuccess()或onFailure(int)通知应用程序成功或失败以添加服务。
添加服务发现请求后,您可以通过 discoverServices(WifiP2pManager.Channel, WifiP2pManager.ActionListener)启动服务发现。
通过拨打 removeServiceRequest(Channel, WifiP2pServiceRequest, ActionListener)或 clearServiceRequests(Channel, ActionListener)可以清除添加的服务请求。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
req |
WifiP2pServiceRequest: is the service discovery request. |
listener |
WifiP2pManager.ActionListener: for callbacks on success or failure. Can be null. |
void cancelConnect (WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
取消任何正在进行的p2p组协商
函数调用在向框架发送连接取消请求后立即返回。 通过监听器回调onSuccess()或onFailure(int)通知应用成功或失败以启动取消。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
listener |
WifiP2pManager.ActionListener: for callbacks on success or failure. Can be null. |
void clearLocalServices (WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
清除所有已注册的服务发现本地服务。
函数调用在发送请求清除框架的所有本地服务后立即返回。 通过监听器回调onSuccess()或onFailure(int)来通知应用程序成功或失败以添加服务。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
listener |
WifiP2pManager.ActionListener: for callbacks on success or failure. Can be null. |
void clearServiceRequests (WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
清除所有注册的服务发现请求。
函数调用在发送请求以清除所有服务发现请求到框架后立即返回。 通过监听器回调onSuccess()或onFailure(int)来通知应用程序成功或失败以添加服务。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
listener |
WifiP2pManager.ActionListener: for callbacks on success or failure. Can be null. |
void connect (WifiP2pManager.Channel c, WifiP2pConfig config, WifiP2pManager.ActionListener listener)
使用指定的配置启动到设备的p2p连接。
函数调用在向框架发送连接请求后立即返回。 通过监听器回调onSuccess()或onFailure(int)启动连接的成功或失败通知应用程序。
注册 WIFI_P2P_CONNECTION_CHANGED_ACTION意图确定框架何时通知连通性的变化。
如果当前设备不是p2p组的一部分,则连接请求将启动与对等方的组协商。
如果当前设备是现有p2p组的一部分,或者已使用 createGroup(WifiP2pManager.Channel, WifiP2pManager.ActionListener)创建了p2p组, createGroup(WifiP2pManager.Channel, WifiP2pManager.ActionListener)加入该组的邀请将发送到对等设备。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
config |
WifiP2pConfig: options as described in WifiP2pConfig class |
listener |
WifiP2pManager.ActionListener: for callbacks on success or failure. Can be null. |
void createGroup (WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
使用当前设备创建一个p2p组作为组所有者。 这实质上创建了一个接入点,可以接受来自旧客户端以及其他p2p设备的连接。
注意:除非当前设备需要与传统客户端形成p2p连接,否则通常不会使用此功能
函数调用在向框架发送组创建请求后立即返回。 通过监听器回调onSuccess()或onFailure(int)启动组创建的成功或失败通知应用程序。
应用程序可以通过 requestGroupInfo(WifiP2pManager.Channel, WifiP2pManager.GroupInfoListener)请求组详细信息。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
listener |
WifiP2pManager.ActionListener: for callbacks on success or failure. Can be null. |
void discoverPeers (WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
启动对等发现。 发现过程涉及为建立连接而扫描可用的Wi-Fi对等点。
函数调用在向框架发送发现请求之后立即返回。 通过侦听器回调onSuccess()或onFailure(int)通知应用程序成功或失败以启动发现。
该发现在启动连接或形成p2p组之前保持活动状态。 注册WIFI_P2P_PEERS_CHANGED_ACTION意图确定框架在发现对等点时何时通知更改。
收到 WIFI_P2P_PEERS_CHANGED_ACTION意图后,应用程序可以使用 requestPeers(WifiP2pManager.Channel, WifiP2pManager.PeerListListener)请求对等列表。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
listener |
WifiP2pManager.ActionListener: for callbacks on success or failure. Can be null. |
void discoverServices (WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
启动服务发现。 发现过程涉及扫描所请求的服务,以建立与支持可用服务的对等方的连接。
在向框架发送服务发现请求之后,函数调用立即返回。 通过监听器回调onSuccess()或onFailure(int)通知应用程序成功或失败以启动发现。
通过拨打 addServiceRequest(WifiP2pManager.Channel, WifiP2pServiceRequest, WifiP2pManager.ActionListener)来指定要发现的服务。
通过由 setServiceResponseListener(WifiP2pManager.Channel, WifiP2pManager.ServiceResponseListener)或 setDnsSdResponseListeners(WifiP2pManager.Channel, WifiP2pManager.DnsSdServiceResponseListener, WifiP2pManager.DnsSdTxtRecordListener)或 setUpnpServiceResponseListener(WifiP2pManager.Channel, WifiP2pManager.UpnpServiceResponseListener)注册的侦听器回调通知应用程序针对服务发现请求的响应。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
listener |
WifiP2pManager.ActionListener: for callbacks on success or failure. Can be null. |
WifiP2pManager.Channel initialize (Context srcContext, Looper srcLooper, WifiP2pManager.ChannelListener listener)
使用Wi-Fi框架注册应用程序。 在执行任何p2p操作之前,此函数必须是第一个要调用的函数。
| 参数(Parameters) | |
|---|---|
srcContext |
Context: is the context of the source |
srcLooper |
Looper: is the Looper on which the callbacks are receivied |
listener |
WifiP2pManager.ChannelListener: for callback at loss of framework communication. Can be null. |
| 返回(Returns) | |
|---|---|
WifiP2pManager.Channel |
Channel instance that is necessary for performing any further p2p operations |
void removeGroup (WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
删除当前的p2p组。
函数调用在将组删除请求发送到框架后立即返回。 通过听众回拨onSuccess()或onFailure(int)通知应用程序成功或失败以启动组删除。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
listener |
WifiP2pManager.ActionListener: for callbacks on success or failure. Can be null. |
void removeLocalService (WifiP2pManager.Channel c, WifiP2pServiceInfo servInfo, WifiP2pManager.ActionListener listener)
删除已添加的注册本地服务 addLocalService(WifiP2pManager.Channel, WifiP2pServiceInfo, WifiP2pManager.ActionListener)
函数调用在发送请求以将本地服务移除到框架后立即返回。 通过监听器回调onSuccess()或onFailure(int)来向应用程序通知添加服务的成功或失败。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
servInfo |
WifiP2pServiceInfo: is the local service information. |
listener |
WifiP2pManager.ActionListener: for callbacks on success or failure. Can be null. |
void removeServiceRequest (WifiP2pManager.Channel c, WifiP2pServiceRequest req, WifiP2pManager.ActionListener listener)
删除使用 addServiceRequest(WifiP2pManager.Channel, WifiP2pServiceRequest, WifiP2pManager.ActionListener)添加的指定服务发现请求
函数调用在向服务发送请求删除服务发现请求之后立即返回。 通过监听器回调onSuccess()或onFailure(int)通知应用程序成功或失败以添加服务。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
req |
WifiP2pServiceRequest: is the service discovery request. |
listener |
WifiP2pManager.ActionListener: for callbacks on success or failure. Can be null. |
void requestConnectionInfo (WifiP2pManager.Channel c, WifiP2pManager.ConnectionInfoListener listener)
请求设备连接信息。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
listener |
WifiP2pManager.ConnectionInfoListener: for callback when connection info is available. Can be null. |
void requestGroupInfo (WifiP2pManager.Channel c, WifiP2pManager.GroupInfoListener listener)
请求p2p组信息。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
listener |
WifiP2pManager.GroupInfoListener: for callback when group info is available. Can be null. |
void requestPeers (WifiP2pManager.Channel c, WifiP2pManager.PeerListListener listener)
请求当前的同伴列表。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
listener |
WifiP2pManager.PeerListListener: for callback when peer list is available. Can be null. |
void setDnsSdResponseListeners (WifiP2pManager.Channel c, WifiP2pManager.DnsSdServiceResponseListener servListener, WifiP2pManager.DnsSdTxtRecordListener txtListener)
注册要在接收Bonjour服务发现响应时调用的回调。
细节见 discoverServices(WifiP2pManager.Channel, WifiP2pManager.ActionListener) 。
| 参数(Parameters) | |
|---|---|
servListener |
WifiP2pManager.DnsSdServiceResponseListener: is for listening to a Bonjour service response |
txtListener |
WifiP2pManager.DnsSdTxtRecordListener: is for listening to a Bonjour TXT record response |
void setServiceResponseListener (WifiP2pManager.Channel c, WifiP2pManager.ServiceResponseListener listener)
注册要在接收服务发现响应时调用的回调。 现在只用于供应商特定的协议。 对于Bonjour或Upnp,分别使用setDnsSdResponseListeners(WifiP2pManager.Channel, WifiP2pManager.DnsSdServiceResponseListener, WifiP2pManager.DnsSdTxtRecordListener)或setUpnpServiceResponseListener(WifiP2pManager.Channel, WifiP2pManager.UpnpServiceResponseListener) 。
详情请参阅 discoverServices(WifiP2pManager.Channel, WifiP2pManager.ActionListener) 。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
listener |
WifiP2pManager.ServiceResponseListener: for callbacks on receiving service discovery response. |
void setUpnpServiceResponseListener (WifiP2pManager.Channel c, WifiP2pManager.UpnpServiceResponseListener listener)
注册要在接收upnp服务发现响应时调用的回调。
详细请参见 discoverServices(WifiP2pManager.Channel, WifiP2pManager.ActionListener) 。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
listener |
WifiP2pManager.UpnpServiceResponseListener: for callbacks on receiving service discovery response. |
void stopPeerDiscovery (WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
停止正在进行的对等发现
函数调用在向框架发送停止请求后立即返回。 通过监听回调onSuccess()或onFailure(int)来通知应用成功或失败。
| 参数(Parameters) | |
|---|---|
c |
WifiP2pManager.Channel: is the channel created at initialize(Context, Looper, WifiP2pManager.ChannelListener) |
listener |
WifiP2pManager.ActionListener: for callbacks on success or failure. Can be null. |