From f5e0970c471d8bb3775febe4d1fb422a337c462c Mon Sep 17 00:00:00 2001
From: Scott Main You should also read
@@ -37,8 +37,8 @@ other machines on the same network.
This class describes the key APIs for finding and connecting to other devices from your application. Specifically, it describes the NSD API for discovering available services and the Wi-Fi -Direct™ API for doing peer-to-peer wireless connections. This class also -shows you how to use NSD and Wi-Fi Direct in +Peer-to-Peer (P2P) API for doing peer-to-peer wireless connections. This class also +shows you how to use NSD and Wi-Fi P2P in combination to detect the services offered by a device and connect to the device when neither device is connected to a network.
@@ -49,13 +49,13 @@ device when neither device is connected to a network.The first lesson in this class, Using Network Service Discovery, showed you how to discover services that are connected to a local network. However, using -Wi-Fi Direct&trad; Service Discovery allows you to discover the services of nearby devices directly, -without being connected to a network. You can also advertise the services +Wi-Fi Peer-to-Peer (P2P) Service Discovery allows you to discover the services of nearby devices +directly, without being connected to a network. You can also advertise the services running on your device. These capabilities help you communicate between apps, even when no local network or hotspot is available.
While this set of APIs is similar in purpose to the Network Service Discovery APIs outlined in a previous lesson, implementing them in code is very different. This lesson shows you how to discover services available from other devices, -using Wi-Fi Direct™. The lesson assumes that you're already familiar with the -Wi-Fi Direct API.
+using Wi-Fi P2P. The lesson assumes that you're already familiar with the +Wi-Fi P2P API.In order to use Wi-Fi Direct, add the {@link +
In order to use Wi-Fi P2P, add the {@link android.Manifest.permission#CHANGE_WIFI_STATE}, {@link android.Manifest.permission#ACCESS_WIFI_STATE}, and {@link android.Manifest.permission#INTERNET} -permissions to your manifest. Even though Wi-Fi Direct doesn't require an +permissions to your manifest. Even though Wi-Fi P2P doesn't require an Internet connection, it uses standard Java sockets, and using these in Android requires the requested permissions.
@@ -244,7 +244,7 @@ provided by the method hints at the problem. Here are the possible error values and what they meanThe Wi-Fi Direct™ APIs allow applications to connect to nearby devices without -needing to connect to a network or hotspot. This allows your application to quickly +
The Wi-Fi peer-to-peer (P2P) APIs allow applications to connect to nearby devices without +needing to connect to a network or hotspot (Android's Wi-Fi P2P framework complies with the Wi-Fi +Alliance's Wi-Fi Direct™ certification program). Wi-Fi P2P allows your application to quickly find and interact with nearby devices, at a range beyond the capabilities of Bluetooth.
-This lesson shows you how to find and connect to nearby devices using Wi-Fi Direct. +This lesson shows you how to find and connect to nearby devices using Wi-Fi P2P.
In order to use Wi-Fi Direct, add the {@link +
In order to use Wi-Fi P2P, add the {@link android.Manifest.permission#CHANGE_WIFI_STATE}, {@link android.Manifest.permission#ACCESS_WIFI_STATE}, and {@link android.Manifest.permission#INTERNET} -permissions to your manifest. Wi-Fi Direct doesn't require an internet connection, +permissions to your manifest. Wi-Fi P2P doesn't require an internet connection, but it does use standard Java sockets, which require the {@link android.Manifest.permission#INTERNET} permission. -So you need the following permissions to use Wi-Fi Direct.
+So you need the following permissions to use Wi-Fi P2P.<manifest xmlns:android="http://schemas.android.com/apk/res/android" @@ -59,13 +58,13 @@ So you need the following permissions to use Wi-Fi Direct.
To use Wi-Fi Direct, you need to listen for broadcast intents that tell your +
To use Wi-Fi P2P, you need to listen for broadcast intents that tell your application when certain events have occurred. In your application, instantiate an {@link android.content.IntentFilter} and set it to listen for the following:
@Override @@ -126,7 +125,7 @@ method, add a condition to handle each P2P state change listed above. public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) { - // Determine if Wifi Direct mode is enabled or not, alert + // Determine if Wifi P2P mode is enabled or not, alert // the Activity. int state = intent.getIntExtra(WifiP2pManager.EXTRA_WIFI_STATE, -1); if (state == WifiP2pManager.WIFI_P2P_STATE_ENABLED) { @@ -177,7 +176,7 @@ The best place to do this is the {@link android.app.Activity#onResume()} andInitiate Peer Discovery
-To start searching for nearby devices with Wi-Fi Direct, call {@link +
To start searching for nearby devices with Wi-Fi P2P, call {@link android.net.wifi.p2p.WifiP2pManager#discoverPeers(WifiP2pManager.Channel, WifiP2pManager.ActionListener) discoverPeers()}. This method takes the following arguments:
@@ -218,7 +217,7 @@ formed.Fetch the List of Peers
Now write the code that fetches and processes the list of peers. First implement the {@link android.net.wifi.p2p.WifiP2pManager.PeerListListener} -interface, which provides information about the peers that Wi-Fi Direct has +interface, which provides information about the peers that Wi-Fi P2P has detected. The following code snippet illustrates this.
diff --git a/docs/html/training/training_toc.cs b/docs/html/training/training_toc.cs index c99fc96..d44d7d4 100644 --- a/docs/html/training/training_toc.cs +++ b/docs/html/training/training_toc.cs @@ -405,7 +405,7 @@ include the action bar on devices running Android 2.1 or higher." Connecting Devices Wirelessly