1 <HTML> 2 <BODY> 3 <p>Provides classes to create peer-to-peer (P2P) connections with Wi-Fi Direct.</p> 4 5 <p>Using these APIs, you can discover and connect to other devices when each 6 device supports Wi-Fi Direct, then communicate over a speedy connection across distances much longer 7 than a Bluetooth connection. The primary class you need to work with is {@link 8 android.net.wifi.p2p.WifiP2pManager}, which you can acquire by calling {@link 9 android.app.Activity#getSystemService getSystemService(WIFI_P2P_SERVICE)}. The {@link 10 android.net.wifi.p2p.WifiP2pManager} includes APIs that allow you to:</p> 11 <ul> 12 <li>Initialize your application for P2P connections by calling {@link 13 android.net.wifi.p2p.WifiP2pManager#initialize initialize()}</li> 14 15 <li>Discover nearby devices by calling {@link android.net.wifi.p2p.WifiP2pManager#discoverPeers 16 discoverPeers()}</li> 17 18 <li>Start a P2P connection by calling {@link android.net.wifi.p2p.WifiP2pManager#connect 19 connect()}</li> 20 <li>And more</li> 21 </ul> 22 23 <p>Several other interfaces and classes are necessary as well, such as:</p> 24 <ul> 25 <li>The {@link android.net.wifi.p2p.WifiP2pManager.ActionListener} interface allows you to receive 26 callbacks when an operation such as discovering peers or connecting to them succeeds or fails.</li> 27 28 <li>{@link android.net.wifi.p2p.WifiP2pManager.PeerListListener} interface allows you to receive 29 information about discovered peers. The callback provides a {@link 30 android.net.wifi.p2p.WifiP2pDeviceList}, from which you can retrieve a {@link 31 android.net.wifi.p2p.WifiP2pDevice} object for each device within range and get information such as 32 the device name, address, device type, the WPS configurations the device supports, and more.</li> 33 34 <li>The {@link android.net.wifi.p2p.WifiP2pManager.GroupInfoListener} interface allows you to 35 receive information about a P2P group. The callback provides a {@link 36 android.net.wifi.p2p.WifiP2pGroup} object, which provides group information such as the owner, the 37 network name, and passphrase.</li> 38 39 <li>{@link android.net.wifi.p2p.WifiP2pManager.ConnectionInfoListener} interface allows you to 40 receive information about the current connection. The callback provides a {@link 41 android.net.wifi.p2p.WifiP2pInfo} object, which has information such as whether a group has been 42 formed and who is the group owner.</li> 43 </ul> 44 45 <p>In order to use the Wi-Fi P2P APIs, your app must request the following user permissions:</p> 46 <ul> 47 <li>{@link android.Manifest.permission#ACCESS_WIFI_STATE}</li> 48 <li>{@link android.Manifest.permission#CHANGE_WIFI_STATE}</li> 49 <li>{@link android.Manifest.permission#INTERNET} (although your app doesnt technically connect 50 to the Internet, communicating to Wi-Fi Direct peers with standard java sockets requires Internet 51 permission).</li> 52 </ul> 53 54 <p>For example code, see the <a href="{@docRoot}resources/samples/WiFiDirectDemo/index.html">Wi-Fi 55 Direct Demo</a> sample application.</p> 56 57 <p class="note"><strong>Note:</strong> Not all Android-powered devices support Wi-Fi 58 Direct. If your application uses Wi-Fi Direct, declare so with a <a 59 href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}</a> 60 element in the manifest file:</p> 61 <pre> 62 <manifest ...> 63 <uses-feature android:name="android.hardware.wifi.direct" /> 64 ... 65 </manifest> 66 </pre> 67 </BODY> 68 </HTML> 69