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
6device supports Wi-Fi Direct, then communicate over a speedy connection across distances much longer
7than a Bluetooth connection. The primary class you need to work with is {@link
8android.net.wifi.p2p.WifiP2pManager}, which you can acquire by calling {@link
9android.app.Activity#getSystemService getSystemService(WIFI_P2P_SERVICE)}. The {@link
10android.net.wifi.p2p.WifiP2pManager} includes APIs that allow you to:</p>
11<ul>
12<li>Initialize your application for P2P connections by calling {@link
13android.net.wifi.p2p.WifiP2pManager#initialize initialize()}</li>
14
15<li>Discover nearby devices by calling {@link android.net.wifi.p2p.WifiP2pManager#discoverPeers
16discoverPeers()}</li>
17
18<li>Start a P2P connection by calling {@link android.net.wifi.p2p.WifiP2pManager#connect
19connect()}</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
26callbacks 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
29information about discovered peers. The callback provides a {@link
30android.net.wifi.p2p.WifiP2pDeviceList}, from which you can retrieve a {@link
31android.net.wifi.p2p.WifiP2pDevice} object for each device within range and get information such as
32the 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
35receive information about a P2P group. The callback provides a {@link
36android.net.wifi.p2p.WifiP2pGroup} object, which provides group information such as the owner, the
37network name, and passphrase.</li>
38
39<li>{@link android.net.wifi.p2p.WifiP2pManager.ConnectionInfoListener} interface allows you to
40receive information about the current connection. The callback provides a {@link
41android.net.wifi.p2p.WifiP2pInfo} object, which has information such as whether a group has been
42formed 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 doesnât technically connect
50to the Internet, communicating to Wi-Fi Direct peers with standard java sockets requires Internet
51permission).</li>
52</ul>
53
54<p>For example code, see the <a href="{@docRoot}resources/samples/WiFiDirectDemo/index.html">Wi-Fi
55Direct Demo</a> sample application.</p>
56
57<p class="note"><strong>Note:</strong> Not all Android-powered devices support Wi-Fi
58Direct. If your application uses Wi-Fi Direct, declare so with a <a
59href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
60element in the manifest file:</p>
61<pre>
62&lt;manifest ...>
63    &lt;uses-feature android:name="android.hardware.wifi.direct" />
64    ...
65&lt;/manifest>
66</pre>
67</BODY>
68</HTML>
69