You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
3.7 KiB
50 lines
3.7 KiB
<p>This is a demo application highlighting how to make peer to peer network connections with
|
|
the Wi-Fi Direct APIs. The application allows you to transfer jpeg images from the gallery after a succesful connection.</p>
|
|
|
|
<p>The source code for this demo app shows how to accomplish three key things
|
|
with Wi-Fi Direct APIs: Discovering peers, connecting using Wi-Fi Direct APIs, and finding group details post connection, so that a
|
|
TCP socket can be opened to transfer files.</p>
|
|
|
|
<p>The application includes:<p>
|
|
<ul> <li><a
|
|
href="src/com/example/android/wifidirect/WiFiDirectActivity.html"><code>WiFiDirectActivity</code></a>
|
|
— 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
|
|
href="src/com/example/android/wifidirect/WiFiDirectBroadcastReceiver.html"><code>
|
|
WiFiDirectBroadcastReceiver</code></a> — a <code>BroadcastReceiver</code>
|
|
that listens for Wi-Fi Direct related events and passes them to
|
|
<code>WiFiDirectActivity</code> and it's fragments for neccesary action.</li> <li><a
|
|
href="src/com/example/android/wifidirect/DeviceListFragment.html"><code>DeviceListFragment</code></a>
|
|
— a <code>ListFragment</code> that displays available peers and their status. </li>
|
|
<li><a href="src/com/example/android/wifidirect/DeviceDetailFragment.html"><code>DeviceDetailFragment</code></a>
|
|
— 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>
|
|
<li><a href="src/com/example/android/wifidirect/FileTransferService.html"><code>FileTransferService</code></a>
|
|
— an <code>IntentService</code> that services file transfer requests from the application by using TCP sockets. </li> </ul>
|
|
<p>If you are developing an application that uses the Wi-Fi Direct APIs, remember that the
|
|
feature is supported only on Android 4.0 (API level 14) and higher versions of
|
|
the platform. To ensure that your application can only
|
|
be installed on devices that are capable of supporting Wi-Fi Direct mode, remember to add the
|
|
following to the application's manifest before publishing to Google Play:</p>
|
|
<ul> <li><code><uses-sdk android:minSdkVersion="14" /></code>, which
|
|
indicates to Google Play and the platform that your application requires
|
|
Android 4.0 or higher. For more information, see <a
|
|
href="../../../guide/appendix/api-levels.html">API Levels</a> and the
|
|
documentation for the <a
|
|
href="../../../guide/topics/manifest/uses-sdk-element.html"><code><uses-sdk></code></a>
|
|
element.</li> </ul> <p>To control how Google Play filters your application
|
|
from devices that do not support Wi-Fi Direct mode, remember to add the following to the
|
|
application's manifest <ul> <li><code><uses-feature
|
|
android:name="android.hardware.wifi.direct" /></code>, which tells Google
|
|
Play that your application uses the Wi-Fi Direct API. The declaration should include
|
|
an <code>android:required</code> attribute that indicates whether you want
|
|
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
|
|
needed, depending on your implementation. For more information, see the
|
|
documentation for the <a
|
|
href="../../../guide/topics/manifest/uses-feature-element.html"><code><uses-feature></code></a>
|
|
element.</li> </ul>
|
|
<p>For more information about using the Wi-Fi Direct API, see the <a
|
|
href="../../../reference/android/net/wifi/p2p/package-summary.html"><code>android.net.wifi.p2p </a></code>
|
|
documentation. </p>
|
|
|
|
<img alt="" src="../images/WifiDirect.png" />
|
|
|