Anirudh Dewani | 1263449 | 2011-09-20 21:16:55 +0530 | [diff] [blame] | 1 | <p>This is a demo application highlighting how to make peer to peer network connections with |
| 2 | the 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 |
| 5 | with Wi-Fi Direct APIs: Discovering peers, connecting using Wi-Fi Direct APIs, and finding group details post connection, so that a |
| 6 | TCP 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 | — 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> — 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 | — 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 | — 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 | — 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 |
| 23 | feature is supported only on Android 4.0 (API level 14) and higher versions of |
| 24 | the platform. To ensure that your application can only |
| 25 | be installed on devices that are capable of supporting Wi-Fi Direct mode, remember to add the |
Dirk Dougherty | 9ba4ba7 | 2012-02-13 20:44:55 -0800 | [diff] [blame] | 26 | following to the application's manifest before publishing to Google Play:</p> |
Anirudh Dewani | 1263449 | 2011-09-20 21:16:55 +0530 | [diff] [blame] | 27 | <ul> <li><code><uses-sdk android:minSdkVersion="14" /></code>, which |
Dirk Dougherty | 9ba4ba7 | 2012-02-13 20:44:55 -0800 | [diff] [blame] | 28 | indicates to Google Play and the platform that your application requires |
Anirudh Dewani | 1263449 | 2011-09-20 21:16:55 +0530 | [diff] [blame] | 29 | 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><uses-sdk></code></a> |
Dirk Dougherty | 9ba4ba7 | 2012-02-13 20:44:55 -0800 | [diff] [blame] | 33 | element.</li> </ul> <p>To control how Google Play filters your application |
Anirudh Dewani | 1263449 | 2011-09-20 21:16:55 +0530 | [diff] [blame] | 34 | from devices that do not support Wi-Fi Direct mode, remember to add the following to the |
| 35 | application's manifest <ul> <li><code><uses-feature |
Dirk Dougherty | 9ba4ba7 | 2012-02-13 20:44:55 -0800 | [diff] [blame] | 36 | android:name="android.hardware.wifi.direct" /></code>, which tells Google |
| 37 | Play that your application uses the Wi-Fi Direct API. The declaration should include |
Anirudh Dewani | 1263449 | 2011-09-20 21:16:55 +0530 | [diff] [blame] | 38 | an <code>android:required</code> attribute that indicates whether you want |
Dirk Dougherty | 9ba4ba7 | 2012-02-13 20:44:55 -0800 | [diff] [blame] | 39 | Google Play to filter the application from devices that do not offer Wi-Fi Direct support. Other <code><uses-feature></code> declarations may also be |
Anirudh Dewani | 1263449 | 2011-09-20 21:16:55 +0530 | [diff] [blame] | 40 | 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><uses-feature></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> |
| 46 | documentation. </p> |
| 47 | |
| 48 | <img alt="" src="../images/WifiDirect.png" /> |
| 49 | |