1*90c8c64dSAndroid Build Coastguard Worker<p>This is a demo application highlighting how to make peer to peer network connections with 2*90c8c64dSAndroid Build Coastguard Workerthe Wi-Fi Direct APIs. The application allows you to transfer jpeg images from the gallery after a succesful connection.</p> 3*90c8c64dSAndroid Build Coastguard Worker 4*90c8c64dSAndroid Build Coastguard Worker<p>The source code for this demo app shows how to accomplish three key things 5*90c8c64dSAndroid Build Coastguard Workerwith Wi-Fi Direct APIs: Discovering peers, connecting using Wi-Fi Direct APIs, and finding group details post connection, so that a 6*90c8c64dSAndroid Build Coastguard WorkerTCP socket can be opened to transfer files.</p> 7*90c8c64dSAndroid Build Coastguard Worker 8*90c8c64dSAndroid Build Coastguard Worker<p>The application includes:<p> 9*90c8c64dSAndroid Build Coastguard Worker<ul> <li><a 10*90c8c64dSAndroid Build Coastguard Worker href="src/com/example/android/wifidirect/WiFiDirectActivity.html"><code>WiFiDirectActivity</code></a> 11*90c8c64dSAndroid Build Coastguard Worker — 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*90c8c64dSAndroid Build Coastguard Worker href="src/com/example/android/wifidirect/WiFiDirectBroadcastReceiver.html"><code> 13*90c8c64dSAndroid Build Coastguard Worker WiFiDirectBroadcastReceiver</code></a> — a <code>BroadcastReceiver</code> 14*90c8c64dSAndroid Build Coastguard Worker that listens for Wi-Fi Direct related events and passes them to 15*90c8c64dSAndroid Build Coastguard Worker <code>WiFiDirectActivity</code> and it's fragments for neccesary action.</li> <li><a 16*90c8c64dSAndroid Build Coastguard Worker href="src/com/example/android/wifidirect/DeviceListFragment.html"><code>DeviceListFragment</code></a> 17*90c8c64dSAndroid Build Coastguard Worker — a <code>ListFragment</code> that displays available peers and their status. </li> 18*90c8c64dSAndroid Build Coastguard Worker<li><a href="src/com/example/android/wifidirect/DeviceDetailFragment.html"><code>DeviceDetailFragment</code></a> 19*90c8c64dSAndroid Build Coastguard Worker — 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*90c8c64dSAndroid Build Coastguard Worker<li><a href="src/com/example/android/wifidirect/FileTransferService.html"><code>FileTransferService</code></a> 21*90c8c64dSAndroid Build Coastguard Worker — an <code>IntentService</code> that services file transfer requests from the application by using TCP sockets. </li> </ul> 22*90c8c64dSAndroid Build Coastguard Worker<p>If you are developing an application that uses the Wi-Fi Direct APIs, remember that the 23*90c8c64dSAndroid Build Coastguard Workerfeature is supported only on Android 4.0 (API level 14) and higher versions of 24*90c8c64dSAndroid Build Coastguard Workerthe platform. To ensure that your application can only 25*90c8c64dSAndroid Build Coastguard Workerbe installed on devices that are capable of supporting Wi-Fi Direct mode, remember to add the 26*90c8c64dSAndroid Build Coastguard Workerfollowing to the application's manifest before publishing to Google Play:</p> 27*90c8c64dSAndroid Build Coastguard Worker<ul> <li><code><uses-sdk android:minSdkVersion="14" /></code>, which 28*90c8c64dSAndroid Build Coastguard Worker indicates to Google Play and the platform that your application requires 29*90c8c64dSAndroid Build Coastguard Worker Android 4.0 or higher. For more information, see <a 30*90c8c64dSAndroid Build Coastguard Worker href="../../../guide/appendix/api-levels.html">API Levels</a> and the 31*90c8c64dSAndroid Build Coastguard Worker documentation for the <a 32*90c8c64dSAndroid Build Coastguard Worker href="../../../guide/topics/manifest/uses-sdk-element.html"><code><uses-sdk></code></a> 33*90c8c64dSAndroid Build Coastguard Worker element.</li> </ul> <p>To control how Google Play filters your application 34*90c8c64dSAndroid Build Coastguard Workerfrom devices that do not support Wi-Fi Direct mode, remember to add the following to the 35*90c8c64dSAndroid Build Coastguard Workerapplication's manifest <ul> <li><code><uses-feature 36*90c8c64dSAndroid Build Coastguard Worker android:name="android.hardware.wifi.direct" /></code>, which tells Google 37*90c8c64dSAndroid Build Coastguard Worker Play that your application uses the Wi-Fi Direct API. The declaration should include 38*90c8c64dSAndroid Build Coastguard Worker an <code>android:required</code> attribute that indicates whether you want 39*90c8c64dSAndroid Build Coastguard Worker 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 40*90c8c64dSAndroid Build Coastguard Worker needed, depending on your implementation. For more information, see the 41*90c8c64dSAndroid Build Coastguard Worker documentation for the <a 42*90c8c64dSAndroid Build Coastguard Worker href="../../../guide/topics/manifest/uses-feature-element.html"><code><uses-feature></code></a> 43*90c8c64dSAndroid Build Coastguard Worker element.</li> </ul> 44*90c8c64dSAndroid Build Coastguard Worker<p>For more information about using the Wi-Fi Direct API, see the <a 45*90c8c64dSAndroid Build Coastguard Worker href="../../../reference/android/net/wifi/p2p/package-summary.html"><code>android.net.wifi.p2p </a></code> 46*90c8c64dSAndroid Build Coastguard Workerdocumentation. </p> 47*90c8c64dSAndroid Build Coastguard Worker 48*90c8c64dSAndroid Build Coastguard Worker<img alt="" src="../images/WifiDirect.png" /> 49*90c8c64dSAndroid Build Coastguard Worker 50