Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
package

android.net.wifi.p2p

Provides classes to create peer-to-peer (P2P) connections with Wi-Fi Direct.

Using these APIs, you can discover and connect to other devices when each device supports Wi-Fi Direct, then communicate over a speedy connection across distances much longer than a Bluetooth connection. The primary class you need to work with is WifiP2pManager , which you can acquire by calling getSystemService(WIFI_P2P_SERVICE) . The WifiP2pManager includes APIs that allow you to:

Several other interfaces and classes are necessary as well, such as:

In order to use the Wi-Fi P2P APIs, your app must request the following user permissions:

For example code, see the Wi-Fi Direct Demo sample application.

Note: Not all Android-powered devices support Wi-Fi Direct. If your application uses Wi-Fi Direct, declare so with a <uses-feature> element in the manifest file:

       <manifest ...>
    <uses-feature android:name="android.hardware.wifi.direct" />
    ...
</manifest>
      

Interfaces

WifiP2pManager.ActionListener Interface for callback invocation on an application action  
WifiP2pManager.ChannelListener Interface for callback invocation when framework channel is lost  
WifiP2pManager.ConnectionInfoListener Interface for callback invocation when connection info is available  
WifiP2pManager.DnsSdServiceResponseListener Interface for callback invocation when Bonjour service discovery response is received  
WifiP2pManager.DnsSdTxtRecordListener Interface for callback invocation when Bonjour TXT record is available for a service  
WifiP2pManager.GroupInfoListener Interface for callback invocation when group info is available  
WifiP2pManager.PeerListListener Interface for callback invocation when peer list is available  
WifiP2pManager.ServiceResponseListener Interface for callback invocation when service discovery response other than Upnp or Bonjour is received  
WifiP2pManager.UpnpServiceResponseListener Interface for callback invocation when upnp service discovery response is received  

Classes

WifiP2pConfig A class representing a Wi-Fi P2p configuration for setting up a connection  
WifiP2pDevice A class representing a Wi-Fi p2p device Note that the operations are not thread safe  
WifiP2pDeviceList A class representing a Wi-Fi P2p device list. 
WifiP2pGroup A class representing a Wi-Fi P2p group. 
WifiP2pInfo A class representing connection information about a Wi-Fi p2p group  
WifiP2pManager This class provides the API for managing Wi-Fi peer-to-peer connectivity. 
WifiP2pManager.Channel A channel that connects the application to the Wifi p2p framework.