blob: 94d695fb3a20eae1a2d952f36899e0c44271503d [file] [log] [blame]
<p>Provides classes to create peer-to-peer (P2P) connections with Wi-Fi Direct.</p>
<p>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 {@link}, which you can acquire by calling {@link getSystemService(WIFI_P2P_SERVICE)}. The {@link} includes APIs that allow you to:</p>
<li>Initialize your application for P2P connections by calling {@link initialize()}</li>
<li>Discover nearby devices by calling {@link
<li>Start a P2P connection by calling {@link
<li>And more</li>
<p>Several other interfaces and classes are necessary as well, such as:</p>
<li>The {@link} interface allows you to receive
callbacks when an operation such as discovering peers or connecting to them succeeds or fails.</li>
<li>{@link} interface allows you to receive
information about discovered peers. The callback provides a {@link}, from which you can retrieve a {@link} object for each device within range and get information such as
the device name, address, device type, the WPS configurations the device supports, and more.</li>
<li>The {@link} interface allows you to
receive information about a P2P group. The callback provides a {@link} object, which provides group information such as the owner, the
network name, and passphrase.</li>
<li>{@link} interface allows you to
receive information about the current connection. The callback provides a {@link} object, which has information such as whether a group has been
formed and who is the group owner.</li>
<p>In order to use the Wi-Fi P2P APIs, your app must request the following user permissions:</p>
<li>{@link android.Manifest.permission#ACCESS_WIFI_STATE}</li>
<li>{@link android.Manifest.permission#CHANGE_WIFI_STATE}</li>
<li>{@link android.Manifest.permission#INTERNET} (although your app doesn’t technically connect
to the Internet, communicating to Wi-Fi Direct peers with standard java sockets requires Internet
<p>For example code, see the <a href="{@docRoot}resources/samples/WiFiDirectDemo/index.html">Wi-Fi
Direct Demo</a> sample application.</p>
<p class="note"><strong>Note:</strong> Not all Android-powered devices support Wi-Fi
Direct. If your application uses Wi-Fi Direct, declare so with a <a
href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
element in the manifest file:</p>
&lt;manifest ...>
&lt;uses-feature android:name="" />