WHAT’S IN THIS CHAPTER?> Managing Bluetooth devices and discoverability mode> Discovering remote Bluetooth devices> Communicating over Bluetooth> Monitoring Internet connectivity> Monitoring Wi-Fi and network details> Configuring Wi-Fi and scanning for access points> Transferring data using Wi-Fi Direct> Scanning NFC tags> Transferring data using Android BeamThis chapter begins to explore Android’s hardware communications APIs by examining the Bluetooth, network, Wi-Fi, and Near Field Communication (NFC) packages.Android offers APIs to manage and monitor your Bluetooth settings: to control discoverability, to discover nearby Bluetooth devices, and to use Bluetooth as a proximity-based, peer-to-peer transport layer for your applications.A full network and Wi-Fi package is also available. Using these APIs, you can scan for hotspots, create and modify Wi-Fi configuration settings, monitor your Internet connectivity, and control and monitor Internet settings and preferences. The introduction of Wi-Fi Direct offers a peer-to-peer solution for communicating between devices using Wi-Fi.Android 2.3 (API level 9) introduced support for NFC, including the support for reading smart tags, and Android 4.0 (API level 14) added the ability to communicate with other NFC-enabled Android devices using Android Beam.USING BLUETOOTHBluetooth is a communications protocol designed for short-range, low-bandwidth peer-to-peer communications.Using the Bluetooth APIs, you can search for, and connect to, other Bluetooth devices within range. By initiating a communications link using Bluetooth Sockets, you can then transmit and receive streams of data between devices from within your applications.At the time of writing, only encrypted communication is supported between devices, meaning that you can form connections only between devices that have been paired.Managing the Local Bluetooth Device AdapterThe local Bluetooth device is controlled via the BluetoothAdapter class, which represents the host Android device on which your application is running.To access the default Bluetooth Adapter, call getDefaultAdapter, as shown in Listing 16-1. Some Android devices feature multiple Bluetooth adapters, though it is currently only possible to access the default device.
đang được dịch, vui lòng đợi..