public class WifiP2pManager extends Object
The API is asynchronous and responses to requests from an application are on listener
callbacks provided by the application. The application needs to do an initialization with
initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
before doing any p2p operation.
Most application calls need a WifiP2pManager.ActionListener
instance for receiving callbacks
WifiP2pManager.ActionListener.onSuccess()
or WifiP2pManager.ActionListener.onFailure(int)
. Action callbacks
indicate whether the initiation of the action was a success or a failure.
Upon failure, the reason of failure can be one of ERROR
, P2P_UNSUPPORTED
or BUSY
.
An application can initiate discovery of peers with discoverPeers(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
. An initiated
discovery request from an application stays active until the device starts connecting to a peer
,forms a p2p group or there is an explicit stopPeerDiscovery(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
.
Applications can listen to WIFI_P2P_DISCOVERY_CHANGED_ACTION
to know if a peer-to-peer
discovery is running or stopped. Additionally, WIFI_P2P_PEERS_CHANGED_ACTION
indicates
if the peer list has changed.
When an application needs to fetch the current list of peers, it can request the list
of peers with requestPeers(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.PeerListListener)
. When the peer list is available
WifiP2pManager.PeerListListener.onPeersAvailable(android.net.wifi.p2p.WifiP2pDeviceList)
is called with the device list.
An application can initiate a connection request to a peer through connect(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pConfig, android.net.wifi.p2p.WifiP2pManager.ActionListener)
. See
WifiP2pConfig
for details on setting up the configuration. For communication with legacy
Wi-Fi devices that do not support p2p, an app can create a group using createGroup(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
which creates an access point whose details can be fetched with requestGroupInfo(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.GroupInfoListener)
.
After a successful group formation through createGroup(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
or through connect(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pConfig, android.net.wifi.p2p.WifiP2pManager.ActionListener)
,
use requestConnectionInfo(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ConnectionInfoListener)
to fetch the connection details. The connection info
WifiP2pInfo
contains the address of the group owner
WifiP2pInfo.groupOwnerAddress
and a flag WifiP2pInfo.isGroupOwner
to indicate
if the current device is a p2p group owner. A p2p client can thus communicate with
the p2p group owner through a socket connection.
With peer discovery using discoverPeers(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
, an application discovers the neighboring
peers, but has no good way to figure out which peer to establish a connection with. For example,
if a game application is interested in finding all the neighboring peers that are also running
the same game, it has no way to find out until after the connection is setup. Pre-association
service discovery is meant to address this issue of filtering the peers based on the running
services.
With pre-association service discovery, an application can advertise a service for a application on a peer device prior to a connection setup between the devices. Currently, DNS based service discovery (Bonjour) and Upnp are the higher layer protocols supported. Get Bonjour resources at dns-sd.org and Upnp resources at upnp.org As an example, a video application can discover a Upnp capable media renderer prior to setting up a Wi-fi p2p connection with the device.
An application can advertise a Upnp or a Bonjour service with a call to
addLocalService(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.nsd.WifiP2pServiceInfo, android.net.wifi.p2p.WifiP2pManager.ActionListener)
. After a local service is added,
the framework automatically responds to a peer application discovering the service prior
to establishing a p2p connection. A call to removeLocalService(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.nsd.WifiP2pServiceInfo, android.net.wifi.p2p.WifiP2pManager.ActionListener)
removes a local
service and clearLocalServices(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
can be used to clear all local services.
An application that is looking for peer devices that support certain services
can do so with a call to discoverServices(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
. Prior to initiating the discovery,
application can add service discovery request with a call to addServiceRequest(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.nsd.WifiP2pServiceRequest, android.net.wifi.p2p.WifiP2pManager.ActionListener)
,
remove a service discovery request with a call to removeServiceRequest(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.nsd.WifiP2pServiceRequest, android.net.wifi.p2p.WifiP2pManager.ActionListener)
or clear
all requests with a call to clearServiceRequests(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
. When no service requests remain,
a previously running service discovery will stop.
The application is notified of a result of service discovery request through listener callbacks
set through setDnsSdResponseListeners(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.DnsSdServiceResponseListener, android.net.wifi.p2p.WifiP2pManager.DnsSdTxtRecordListener)
for Bonjour or
setUpnpServiceResponseListener(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.UpnpServiceResponseListener)
for Upnp.
Note:
Registering an application handler with initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
requires the permissions
android.Manifest.permission#ACCESS_WIFI_STATE
and
android.Manifest.permission#CHANGE_WIFI_STATE
to perform any further peer-to-peer
operations.
Get an instance of this class by calling Context.getSystemService(Context.WIFI_P2P_SERVICE)
.
WifiP2pConfig
WifiP2pInfo
WifiP2pGroup
WifiP2pDevice
WifiP2pDeviceList
WpsInfo
Modifier and Type | Class and Description |
---|---|
static interface |
WifiP2pManager.ActionListener
Interface for callback invocation on an application action
|
static class |
WifiP2pManager.Channel
A channel that connects the application to the Wifi p2p framework.
|
static interface |
WifiP2pManager.ChannelListener
Interface for callback invocation when framework channel is lost
|
static interface |
WifiP2pManager.ConnectionInfoListener
Interface for callback invocation when connection info is available
|
static interface |
WifiP2pManager.DnsSdServiceResponseListener
Interface for callback invocation when Bonjour service discovery response
is received
|
static interface |
WifiP2pManager.DnsSdTxtRecordListener
Interface for callback invocation when Bonjour TXT record is available
for a service
|
static interface |
WifiP2pManager.GroupInfoListener
Interface for callback invocation when group info is available
|
static interface |
WifiP2pManager.HandoverMessageListener
Interface for callback invocation when Handover Request or Select Message is available
|
static interface |
WifiP2pManager.PeerListListener
Interface for callback invocation when peer list is available
|
static interface |
WifiP2pManager.PersistentGroupInfoListener
Interface for callback invocation when stored group info list is available
|
static interface |
WifiP2pManager.ServiceResponseListener
Interface for callback invocation when service discovery response other than
Upnp or Bonjour is received
|
static interface |
WifiP2pManager.UpnpServiceResponseListener
Interface for callback invocation when upnp service discovery response
is received
|
Constructor and Description |
---|
WifiP2pManager(IWifiP2pManager service)
Create a new WifiP2pManager instance.
|
public static final String WIFI_P2P_STATE_CHANGED_ACTION
EXTRA_WIFI_STATE
provides the state information as int.EXTRA_WIFI_STATE
,
Constant Field Valuespublic static final String EXTRA_WIFI_STATE
Intent.getIntExtra(String,int)
.public static final int WIFI_P2P_STATE_DISABLED
public static final int WIFI_P2P_STATE_ENABLED
public static final String WIFI_P2P_CONNECTION_CHANGED_ACTION
EXTRA_WIFI_P2P_INFO
provides the p2p connection info in
the form of a WifiP2pInfo
object. Another extra EXTRA_NETWORK_INFO
provides
the network info in the form of a NetworkInfo
. A third extra provides
the details of the group.public static final String EXTRA_WIFI_P2P_INFO
WifiP2pInfo
object
Retrieve with Intent.getParcelableExtra(String)
.public static final String EXTRA_NETWORK_INFO
NetworkInfo
object associated with the
p2p network. Retrieve with
Intent.getParcelableExtra(String)
.public static final String EXTRA_WIFI_P2P_GROUP
WifiP2pGroup
object
associated with the p2p network. Retrieve with
Intent.getParcelableExtra(String)
.public static final String WIFI_P2P_PEERS_CHANGED_ACTION
An extra EXTRA_P2P_DEVICE_LIST
provides the full list of
current peers. The full list of peers can also be obtained any time with
requestPeers(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.PeerListListener)
.
EXTRA_P2P_DEVICE_LIST
,
Constant Field Valuespublic static final String EXTRA_P2P_DEVICE_LIST
WifiP2pDeviceList
object representing
the new peer list when WIFI_P2P_PEERS_CHANGED_ACTION
broadcast is sent.
Retrieve with Intent.getParcelableExtra(String)
.
public static final String WIFI_P2P_DISCOVERY_CHANGED_ACTION
EXTRA_DISCOVERY_STATE
indicates whether discovery has started
or stopped.
Note that discovery will be stopped during a connection setup. If the application tries to re-initiate discovery during this time, it can fail.
public static final String EXTRA_DISCOVERY_STATE
Intent.getIntExtra(String,int)
.public static final int WIFI_P2P_DISCOVERY_STOPPED
public static final int WIFI_P2P_DISCOVERY_STARTED
public static final String WIFI_P2P_THIS_DEVICE_CHANGED_ACTION
public static final String EXTRA_WIFI_P2P_DEVICE
WifiP2pDevice
object
Retrieve with Intent.getParcelableExtra(String)
.public static final String WIFI_P2P_PERSISTENT_GROUPS_CHANGED_ACTION
public static final String EXTRA_HANDOVER_MESSAGE
public static final int DISCOVER_PEERS
public static final int DISCOVER_PEERS_FAILED
public static final int DISCOVER_PEERS_SUCCEEDED
public static final int STOP_DISCOVERY
public static final int STOP_DISCOVERY_FAILED
public static final int STOP_DISCOVERY_SUCCEEDED
public static final int CONNECT
public static final int CONNECT_FAILED
public static final int CONNECT_SUCCEEDED
public static final int CANCEL_CONNECT
public static final int CANCEL_CONNECT_FAILED
public static final int CANCEL_CONNECT_SUCCEEDED
public static final int CREATE_GROUP
public static final int CREATE_GROUP_FAILED
public static final int CREATE_GROUP_SUCCEEDED
public static final int REMOVE_GROUP
public static final int REMOVE_GROUP_FAILED
public static final int REMOVE_GROUP_SUCCEEDED
public static final int REQUEST_PEERS
public static final int RESPONSE_PEERS
public static final int REQUEST_CONNECTION_INFO
public static final int RESPONSE_CONNECTION_INFO
public static final int REQUEST_GROUP_INFO
public static final int RESPONSE_GROUP_INFO
public static final int ADD_LOCAL_SERVICE
public static final int ADD_LOCAL_SERVICE_FAILED
public static final int ADD_LOCAL_SERVICE_SUCCEEDED
public static final int REMOVE_LOCAL_SERVICE
public static final int REMOVE_LOCAL_SERVICE_FAILED
public static final int REMOVE_LOCAL_SERVICE_SUCCEEDED
public static final int CLEAR_LOCAL_SERVICES
public static final int CLEAR_LOCAL_SERVICES_FAILED
public static final int CLEAR_LOCAL_SERVICES_SUCCEEDED
public static final int ADD_SERVICE_REQUEST
public static final int ADD_SERVICE_REQUEST_FAILED
public static final int ADD_SERVICE_REQUEST_SUCCEEDED
public static final int REMOVE_SERVICE_REQUEST
public static final int REMOVE_SERVICE_REQUEST_FAILED
public static final int REMOVE_SERVICE_REQUEST_SUCCEEDED
public static final int CLEAR_SERVICE_REQUESTS
public static final int CLEAR_SERVICE_REQUESTS_FAILED
public static final int CLEAR_SERVICE_REQUESTS_SUCCEEDED
public static final int DISCOVER_SERVICES
public static final int DISCOVER_SERVICES_FAILED
public static final int DISCOVER_SERVICES_SUCCEEDED
public static final int PING
public static final int RESPONSE_SERVICE
public static final int SET_DEVICE_NAME
public static final int SET_DEVICE_NAME_FAILED
public static final int SET_DEVICE_NAME_SUCCEEDED
public static final int DELETE_PERSISTENT_GROUP
public static final int DELETE_PERSISTENT_GROUP_FAILED
public static final int DELETE_PERSISTENT_GROUP_SUCCEEDED
public static final int REQUEST_PERSISTENT_GROUP_INFO
public static final int RESPONSE_PERSISTENT_GROUP_INFO
public static final int SET_WFD_INFO
public static final int SET_WFD_INFO_FAILED
public static final int SET_WFD_INFO_SUCCEEDED
public static final int START_WPS
public static final int START_WPS_FAILED
public static final int START_WPS_SUCCEEDED
public static final int START_LISTEN
public static final int START_LISTEN_FAILED
public static final int START_LISTEN_SUCCEEDED
public static final int STOP_LISTEN
public static final int STOP_LISTEN_FAILED
public static final int STOP_LISTEN_SUCCEEDED
public static final int SET_CHANNEL
public static final int SET_CHANNEL_FAILED
public static final int SET_CHANNEL_SUCCEEDED
public static final int GET_HANDOVER_REQUEST
public static final int GET_HANDOVER_SELECT
public static final int RESPONSE_GET_HANDOVER_MESSAGE
public static final int INITIATOR_REPORT_NFC_HANDOVER
public static final int RESPONDER_REPORT_NFC_HANDOVER
public static final int REPORT_NFC_HANDOVER_SUCCEEDED
public static final int REPORT_NFC_HANDOVER_FAILED
public static final int ERROR
WifiP2pManager.ActionListener.onFailure(int)
.
Indicates that the operation failed due to an internal error.public static final int P2P_UNSUPPORTED
WifiP2pManager.ActionListener.onFailure(int)
.
Indicates that the operation failed because p2p is unsupported on the device.public static final int BUSY
WifiP2pManager.ActionListener.onFailure(int)
.
Indicates that the operation failed because the framework is busy and
unable to service the requestpublic static final int NO_SERVICE_REQUESTS
WifiP2pManager.ActionListener.onFailure(int)
.
Indicates that the discoverServices(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
failed because no service
requests are added. Use addServiceRequest(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.nsd.WifiP2pServiceRequest, android.net.wifi.p2p.WifiP2pManager.ActionListener)
to add a service
request.public static final int MIRACAST_DISABLED
public static final int MIRACAST_SOURCE
public static final int MIRACAST_SINK
public WifiP2pManager(IWifiP2pManager service)
Context.getSystemService()
to retrieve
the standard Context.WIFI_P2P_SERVICE
.service
- the Binder interfacepublic WifiP2pManager.Channel initialize(Context srcContext, Looper srcLooper, WifiP2pManager.ChannelListener listener)
srcContext
- is the context of the sourcesrcLooper
- is the Looper on which the callbacks are receiviedlistener
- for callback at loss of framework communication. Can be null.public WifiP2pManager.Channel initializeInternal(Context srcContext, Looper srcLooper, WifiP2pManager.ChannelListener listener)
public void discoverPeers(WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
The function call immediately returns after sending a discovery request
to the framework. The application is notified of a success or failure to initiate
discovery through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
The discovery remains active until a connection is initiated or
a p2p group is formed. Register for WIFI_P2P_PEERS_CHANGED_ACTION
intent to
determine when the framework notifies of a change as peers are discovered.
Upon receiving a WIFI_P2P_PEERS_CHANGED_ACTION
intent, an application
can request for the list of peers using requestPeers(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.PeerListListener)
.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callbacks on success or failure. Can be null.public void stopPeerDiscovery(WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
The function call immediately returns after sending a stop request
to the framework. The application is notified of a success or failure to initiate
stop through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callbacks on success or failure. Can be null.public void connect(WifiP2pManager.Channel c, WifiP2pConfig config, WifiP2pManager.ActionListener listener)
The function call immediately returns after sending a connection request
to the framework. The application is notified of a success or failure to initiate
connect through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
Register for WIFI_P2P_CONNECTION_CHANGED_ACTION
intent to
determine when the framework notifies of a change in connectivity.
If the current device is not part of a p2p group, a connect request initiates a group negotiation with the peer.
If the current device is part of an existing p2p group or has created
a p2p group with createGroup(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
, an invitation to join the group is sent to
the peer device.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
config
- options as described in WifiP2pConfig
classlistener
- for callbacks on success or failure. Can be null.public void cancelConnect(WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
The function call immediately returns after sending a connection cancellation request
to the framework. The application is notified of a success or failure to initiate
cancellation through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callbacks on success or failure. Can be null.public void createGroup(WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
Note: This function would normally not be used unless the current device needs to form a p2p connection with a legacy client
The function call immediately returns after sending a group creation request
to the framework. The application is notified of a success or failure to initiate
group creation through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
Application can request for the group details with requestGroupInfo(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.GroupInfoListener)
.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callbacks on success or failure. Can be null.public void removeGroup(WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
The function call immediately returns after sending a group removal request
to the framework. The application is notified of a success or failure to initiate
group removal through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callbacks on success or failure. Can be null.public void listen(WifiP2pManager.Channel c, boolean enable, WifiP2pManager.ActionListener listener)
public void setWifiP2pChannels(WifiP2pManager.Channel c, int lc, int oc, WifiP2pManager.ActionListener listener)
public void startWps(WifiP2pManager.Channel c, WpsInfo wps, WifiP2pManager.ActionListener listener)
The function call immediately returns after sending a request to start a
WPS session. Currently, this is only valid if the current device is running
as a group owner to allow any new clients to join the group. The application
is notified of a success or failure to initiate WPS through listener callbacks
WifiP2pManager.ActionListener.onSuccess()
or WifiP2pManager.ActionListener.onFailure(int)
.
public void addLocalService(WifiP2pManager.Channel c, WifiP2pServiceInfo servInfo, WifiP2pManager.ActionListener listener)
The function call immediately returns after sending a request to add a local
service to the framework. The application is notified of a success or failure to
add service through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
The service information is set through WifiP2pServiceInfo
.
or its subclass calls WifiP2pUpnpServiceInfo.newInstance(java.lang.String, java.lang.String, java.util.List<java.lang.String>)
or
WifiP2pDnsSdServiceInfo.newInstance(java.lang.String, java.lang.String, java.util.Map<java.lang.String, java.lang.String>)
for a Upnp or Bonjour service
respectively
The service information can be cleared with calls to
removeLocalService(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.nsd.WifiP2pServiceInfo, android.net.wifi.p2p.WifiP2pManager.ActionListener)
or clearLocalServices(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
servInfo
- is a local service information.listener
- for callbacks on success or failure. Can be null.public void removeLocalService(WifiP2pManager.Channel c, WifiP2pServiceInfo servInfo, WifiP2pManager.ActionListener listener)
addLocalService(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.nsd.WifiP2pServiceInfo, android.net.wifi.p2p.WifiP2pManager.ActionListener)
The function call immediately returns after sending a request to remove a
local service to the framework. The application is notified of a success or failure to
add service through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
servInfo
- is the local service information.listener
- for callbacks on success or failure. Can be null.public void clearLocalServices(WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
The function call immediately returns after sending a request to clear all
local services to the framework. The application is notified of a success or failure to
add service through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callbacks on success or failure. Can be null.public void setServiceResponseListener(WifiP2pManager.Channel c, WifiP2pManager.ServiceResponseListener listener)
setDnsSdResponseListeners(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.DnsSdServiceResponseListener, android.net.wifi.p2p.WifiP2pManager.DnsSdTxtRecordListener)
or setUpnpServiceResponseListener(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.UpnpServiceResponseListener)
respectively.
see discoverServices(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
for the detail.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callbacks on receiving service discovery response.public void setDnsSdResponseListeners(WifiP2pManager.Channel c, WifiP2pManager.DnsSdServiceResponseListener servListener, WifiP2pManager.DnsSdTxtRecordListener txtListener)
see discoverServices(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
for the detail.
c
- servListener
- is for listening to a Bonjour service responsetxtListener
- is for listening to a Bonjour TXT record responsepublic void setUpnpServiceResponseListener(WifiP2pManager.Channel c, WifiP2pManager.UpnpServiceResponseListener listener)
see discoverServices(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
for the detail.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callbacks on receiving service discovery response.public void discoverServices(WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
The function call immediately returns after sending a request to start service
discovery to the framework. The application is notified of a success or failure to initiate
discovery through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
The services to be discovered are specified with calls to addServiceRequest(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.nsd.WifiP2pServiceRequest, android.net.wifi.p2p.WifiP2pManager.ActionListener)
.
The application is notified of the response against the service discovery request
through listener callbacks registered by setServiceResponseListener(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ServiceResponseListener)
or
setDnsSdResponseListeners(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.DnsSdServiceResponseListener, android.net.wifi.p2p.WifiP2pManager.DnsSdTxtRecordListener)
, or setUpnpServiceResponseListener(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.UpnpServiceResponseListener)
.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callbacks on success or failure. Can be null.public void addServiceRequest(WifiP2pManager.Channel c, WifiP2pServiceRequest req, WifiP2pManager.ActionListener listener)
The function call immediately returns after sending a request to add service
discovery request to the framework. The application is notified of a success or failure to
add service through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
After service discovery request is added, you can initiate service discovery by
discoverServices(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener)
.
The added service requests can be cleared with calls to
removeServiceRequest(Channel, WifiP2pServiceRequest, ActionListener)
or
clearServiceRequests(Channel, ActionListener)
.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
req
- is the service discovery request.listener
- for callbacks on success or failure. Can be null.public void removeServiceRequest(WifiP2pManager.Channel c, WifiP2pServiceRequest req, WifiP2pManager.ActionListener listener)
addServiceRequest(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.nsd.WifiP2pServiceRequest, android.net.wifi.p2p.WifiP2pManager.ActionListener)
The function call immediately returns after sending a request to remove service
discovery request to the framework. The application is notified of a success or failure to
add service through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
req
- is the service discovery request.listener
- for callbacks on success or failure. Can be null.public void clearServiceRequests(WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
The function call immediately returns after sending a request to clear all
service discovery requests to the framework. The application is notified of a success
or failure to add service through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callbacks on success or failure. Can be null.public void requestPeers(WifiP2pManager.Channel c, WifiP2pManager.PeerListListener listener)
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callback when peer list is available. Can be null.public void requestConnectionInfo(WifiP2pManager.Channel c, WifiP2pManager.ConnectionInfoListener listener)
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callback when connection info is available. Can be null.public void requestGroupInfo(WifiP2pManager.Channel c, WifiP2pManager.GroupInfoListener listener)
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callback when group info is available. Can be null.public void setDeviceName(WifiP2pManager.Channel c, String devName, WifiP2pManager.ActionListener listener)
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callback when group info is available. Can be null.public void setWFDInfo(WifiP2pManager.Channel c, WifiP2pWfdInfo wfdInfo, WifiP2pManager.ActionListener listener)
public void deletePersistentGroup(WifiP2pManager.Channel c, int netId, WifiP2pManager.ActionListener listener)
The function call immediately returns after sending a persistent group removal request
to the framework. The application is notified of a success or failure to initiate
group removal through listener callbacks WifiP2pManager.ActionListener.onSuccess()
or
WifiP2pManager.ActionListener.onFailure(int)
.
The persistent p2p group list stored in the system can be obtained by
requestPersistentGroupInfo(Channel, PersistentGroupInfoListener)
and
a network id can be obtained by WifiP2pGroup.getNetworkId()
.
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
netId
- he network id of the p2p group.listener
- for callbacks on success or failure. Can be null.public void requestPersistentGroupInfo(WifiP2pManager.Channel c, WifiP2pManager.PersistentGroupInfoListener listener)
c
- is the channel created at initialize(android.content.Context, android.os.Looper, android.net.wifi.p2p.WifiP2pManager.ChannelListener)
listener
- for callback when persistent group info list is available. Can be null.public void setMiracastMode(int mode)
public Messenger getMessenger()
public Messenger getP2pStateMachineMessenger()
public void getNfcHandoverRequest(WifiP2pManager.Channel c, WifiP2pManager.HandoverMessageListener listener)
public void getNfcHandoverSelect(WifiP2pManager.Channel c, WifiP2pManager.HandoverMessageListener listener)
public void initiatorReportNfcHandover(WifiP2pManager.Channel c, String handoverSelect, WifiP2pManager.ActionListener listener)
public void responderReportNfcHandover(WifiP2pManager.Channel c, String handoverRequest, WifiP2pManager.ActionListener listener)