Thursday 7 August 2014

Android Bluetooth Connection

Bluetooth:The Android platform supports Bluetooth connection, which allows exchanging data with other Bluetooth devices. The application framework provides access to the Bluetooth functionality through the Android Bluetooth APIs connect to other Bluetooth devices.
All of the Bluetooth APIs is available in the Android Bluetooth package. Here is a summary of the classes you will need to create as below.
BluetoothAdapter: Represents the local Bluetooth adapter (Bluetooth radio)
BluetoothDevice: Represents a remote Bluetooth device, query information such as its name, address, class, and bonding state.
BluetoothSocket: Represents the interface for a Bluetooth socket (similar to a TCP Socket).
BluetoothServerSocket: Represents an open server socket that listens for incoming requests (similar to a TCP ServerSocket).
BluetoothClass: Describes the general characteristics and capabilities of a Bluetooth device.
In our example we are going to create an application which get the information about the Bluetooth connections is activates and deactivates Bluetooth.

Final Output:
Please check the screenshots attached.
Bluetooth0 Bluetooth1 Bluetooth2
Step 1. First we need check Bluetooth connection. So Create new class named “Connections”.
Step 2. Now when we got the response from the Connections class in our Main Activity with BT in Off state we get dialog for On BT.
Then we create new method into main activity class for the setting up all the Bluetooth information into Text View.
For More Details visit following links.
I hope you enjoy this tutorial and it would be helpful to you.