Advanced Android Course


How To Provide an Option To Bond Device Before Connecting To Device?

How To Programmatically Pair or Unpair Android Bluetooth Device?

Multiple Pairing/Bonding Possible In Slave Mode?

Refer A Friend

Have a friend to whom you would want to share this course? Refer now and earn credits

Refer Now !
Advanced Android Course Course Topics keyboard_arrow_down


Bonding with Bluetooth devices in Android


In today's video our topic is Bonding with Bluetooth Devices in Android.

Once you enable the Bluetooth, you can get a list of paired device by calling getBondedDevices() method. It returns a set of bluetooth devices

Syntax :

private Set<BluetoothDevice>pairedDevices;


There are different methods of bluetooth adaptor class like enable(), isEnabled(),

disable(), getName(),

setName(String name), getState(), startDiscovery() etc...

We need to use one Client Server Mechanism to transfer files from one bluetooth to another.

The server and client are considered connected to each other when they each have a connected Bluetooth Socket on the same RFCOMM channel. At this point each device can obtain input and output streams and data transfer can begin.

The service device and the client device each obtain the required Bluetooth socket in different ways. The server will receive it when an incoming connection is accepted. The client will receive it when it opens an RFCOMM channel to the server.

The purpose of the server socket is to listen for incoming connection requests and when one is accepted, provide a connected BluetoothSocket. If you over data communication task then disconnect it.

The steps for connecting Server Socket are as follows :

  1. Get a BluetoothServerSocket by calling the listenUsingRfcommWithServiceRecord(String,UUID).
  2. Start listening for connection requests by calling accept().
  3. Unless you want to accept additional connections, call close().
Student Testimonials
Download The App
  • Learn anywhere on the go
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed.