Bluetooth

Bluetooth from the IEEE standard 802.15.1 is an open, wireless protocol for exchanging data between devices over short distances. A common example is from a phone to a headset, but other applications can include proximity tracking. To communicate between devices using Bluetooth, four steps need to be performed:

1. Turn on Bluetooth for the device.

2. Find paired or available devices in a valid range.

3. Connect to devices.

4. Transfer data between devices.

To use the Bluetooth Service, the application needs to have BLUETOOTH permission to receive and transmit and bluetooth_admin permission to manipulate Bluetooth settings or initiate device discovery. These require the following lines in the AndroidManifest XML file:

<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

All the Bluetooth API functionality resides in the android.bluetooth package. There are five main classes that provide the features:

■ BluetoothAdapter—Represents the Bluetooth radio interface that is used to discover devices and instantiate Bluetooth connections

■ BluetoothClass—Describes the general characteristics of the Bluetooth device

■ BluetoothDevice—Represents a remote Bluetooth device

■ BluetoothSocket—Represents the socket or connection point for data exchange with another Bluetooth device

■ BluetoothServerSocket—Represents an open socket listening for incoming requests

These are discussed in detail in the following recipes.

Character Building Thought Power

Character Building Thought Power

Character-Building Thought Power by Ralph Waldo Trine. Ralph draws a distinct line between bad and good habits. In this book, every effort is made by the writer to explain what comprises good habits and why every one needs it early in life. It draws the conclusion that habits nurtured in early life concretize into impulses in future for the good or bad of the subject.

Get My Free Ebook


Post a comment