Course Content

Course Content

Description

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;

pairedDevices=BA.getBondedDevices();

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().

FAQs

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

Code Scan or Download the app
Google Play Store
297K+ Downloads
4.5 Rating
10K+ Reviews
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere