Skip to content

Commit 737c3dd

Browse files
scottamainAndroid (Google) Code Review
authored andcommitted
Merge "docs: add package description for wifi.p2p and update the one for wifi" into ics-mr0
2 parents aac4184 + 63fcb39 commit 737c3dd

File tree

2 files changed

+87
-2
lines changed

2 files changed

+87
-2
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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 doesn’t 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 &lt;uses-feature&gt;}</a>
60+
element 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>
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
11
<HTML>
22
<BODY>
3-
Provides classes to manage Wi-Fi functionality on the device.
3+
<p>Provides classes to manage Wi-Fi functionality on the device.</p>
44
<p>The Wi-Fi APIs provide a means by which applications can communicate
55
with the lower-level wireless stack that provides Wi-Fi network access. Almost all
66
information from the device supplicant is available, including the connected network's
77
link speed, IP address, negotiation state, and more, plus information about other
88
networks that are available. Some other API features include the ability to
99
scan, add, save, terminate and initiate Wi-Fi connections.</p>
10-
<p>Remember, not all Android devices are guaranteed to have Wi-Fi functionality.</p>
10+
11+
<p>Some APIs may require the following user permissions:</p>
12+
<ul>
13+
<li>{@link android.Manifest.permission#ACCESS_WIFI_STATE}</li>
14+
<li>{@link android.Manifest.permission#CHANGE_WIFI_STATE}</li>
15+
<li>{@link android.Manifest.permission#CHANGE_WIFI_MULTICAST_STATE}</li>
16+
</ul>
17+
18+
<p class="note"><strong>Note:</strong> Not all Android-powered devices provide Wi-Fi functionality.
19+
If your application uses Wi-Fi, declare so with a <a
20+
href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
21+
element in the manifest file:</p>
22+
<pre>
23+
&lt;manifest ...>
24+
&lt;uses-feature android:name="android.hardware.wifi" />
25+
...
26+
&lt;/manifest>
27+
</pre>
1128
</BODY>
1229
</HTML>

0 commit comments

Comments
 (0)