blob: 45b831d36a67efcdbd0d57fe832926c449dc67d2 [file] [log] [blame]
Anirudh Dewani12634492011-09-20 21:16:55 +05301<p>This is a demo application highlighting how to make peer to peer network connections with
2the Wi-Fi Direct APIs. The application allows you to transfer jpeg images from the gallery after a succesful connection.</p>
3
4<p>The source code for this demo app shows how to accomplish three key things
5with Wi-Fi Direct APIs: Discovering peers, connecting using Wi-Fi Direct APIs, and finding group details post connection, so that a
6TCP socket can be opened to transfer files.</p>
7
8<p>The application includes:<p>
9<ul> <li><a
10 href="src/com/example/android/wifidirect/WiFiDirectActivity.html"><code>WiFiDirectActivity</code></a>
11 &mdash; the main <code>Activity</code> that contains two fragments to handle app's UI and peer lifecycle. It also registers a broadcast receiver for Wi-Fi Direct related events.</li> <li><a
12 href="src/com/example/android/wifidirect/WiFiDirectBroadcastReceiver.html"><code>
13 WiFiDirectBroadcastReceiver</code></a> &mdash; a <code>BroadcastReceiver</code>
14 that listens for Wi-Fi Direct related events and passes them to
15 <code>WiFiDirectActivity</code> and it's fragments for neccesary action.</li> <li><a
16 href="src/com/example/android/wifidirect/DeviceListFragment.html"><code>DeviceListFragment</code></a>
17 &mdash; a <code>ListFragment</code> that displays available peers and their status. </li>
18<li><a href="src/com/example/android/wifidirect/DeviceDetailFragment.html"><code>DeviceDetailFragment</code></a>
19 &mdash; a <code>Fragment</code> that displays the details of the selected device and also drives the connection, disonnection and data transfer functionality of the demo. </li>
20<li><a href="src/com/example/android/wifidirect/FileTransferService.html"><code>FileTransferService</code></a>
21 &mdash; an <code>IntentService</code> that services file transfer requests from the application by using TCP sockets. </li> </ul>
22<p>If you are developing an application that uses the Wi-Fi Direct APIs, remember that the
23feature is supported only on Android 4.0 (API level 14) and higher versions of
24the platform. To ensure that your application can only
25be installed on devices that are capable of supporting Wi-Fi Direct mode, remember to add the
Dirk Dougherty9ba4ba72012-02-13 20:44:55 -080026following to the application's manifest before publishing to Google Play:</p>
Anirudh Dewani12634492011-09-20 21:16:55 +053027<ul> <li><code>&lt;uses-sdk android:minSdkVersion="14" /&gt;</code>, which
Dirk Dougherty9ba4ba72012-02-13 20:44:55 -080028 indicates to Google Play and the platform that your application requires
Anirudh Dewani12634492011-09-20 21:16:55 +053029 Android 4.0 or higher. For more information, see <a
30 href="../../../guide/appendix/api-levels.html">API Levels</a> and the
31 documentation for the <a
32 href="../../../guide/topics/manifest/uses-sdk-element.html"><code>&lt;uses-sdk&gt;</code></a>
Dirk Dougherty9ba4ba72012-02-13 20:44:55 -080033 element.</li> </ul> <p>To control how Google Play filters your application
Anirudh Dewani12634492011-09-20 21:16:55 +053034from devices that do not support Wi-Fi Direct mode, remember to add the following to the
35application's manifest <ul> <li><code>&lt;uses-feature
Dirk Dougherty9ba4ba72012-02-13 20:44:55 -080036 android:name="android.hardware.wifi.direct" /&gt;</code>, which tells Google
37 Play that your application uses the Wi-Fi Direct API. The declaration should include
Anirudh Dewani12634492011-09-20 21:16:55 +053038 an <code>android:required</code> attribute that indicates whether you want
Dirk Dougherty9ba4ba72012-02-13 20:44:55 -080039 Google Play to filter the application from devices that do not offer Wi-Fi Direct support. Other <code>&lt;uses-feature&gt;</code> declarations may also be
Anirudh Dewani12634492011-09-20 21:16:55 +053040 needed, depending on your implementation. For more information, see the
41 documentation for the <a
42 href="../../../guide/topics/manifest/uses-feature-element.html"><code>&lt;uses-feature&gt;</code></a>
43 element.</li> </ul>
44<p>For more information about using the Wi-Fi Direct API, see the <a
45 href="../../../reference/android/net/wifi/p2p/package-summary.html"><code>android.net.wifi.p2p </a></code>
46documentation. </p>
47
48<img alt="" src="../images/WifiDirect.png" />
49