Android Bluetooth Tutorial - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
Android Bluetooth Tutorial

Android Bluetooth Tutorial

Android Bluetooth Tutorial

Bluetooth is a way to exchange data with other devices wirelessly. Android provides Bluetooth API to perform several tasks such as:
  • scan Bluetooth devices
  • connect and transfer data from and to other devices
  • manage multiple connections etc.

Android Bluetooth API

The android.bluetooth package provides a lot of interfaces classes to work with Bluetooth such as:
  • BluetoothAdapter
  • BluetoothDevice
  • BluetoothSocket
  • BluetoothServerSocket
  • BluetoothClass
  • BluetoothProfile
  • BluetoothProfile.ServiceListener
  • BluetoothHeadset
  • BluetoothA2dp
  • BluetoothHealth
  • BluetoothHealthCallback
  • BluetoothHealthAppConfiguration

android-preferences-example

BluetoothAdapter class

By the help of BluetoothAdapter class, we can perform fundamental tasks such as initiate device discovery, query a list of paired (bonded) devices, create a BluetoothServerSocket instance to listen for connection requests etc.

Constants of BluetoothAdapter class

BluetoothAdapter class provides many constants. Some of them are as follows:
  • String ACTION_REQUEST_ENABLE
  • String ACTION_REQUEST_DISCOVERABLE
  • String ACTION_DISCOVERY_STARTED
  • String ACTION_DISCOVERY_FINISHED

Methods of BluetoothAdapter class

Commonly used methods of BluetoothAdapter class are as follows:
  • static synchronized BluetoothAdapter getDefaultAdapter() returns the instance of BluetoothAdapter.
  • boolean enable() enables the Bluetooth adapter if it is disabled.
  • boolean isEnabled() returns true if the Bluetooth adapter is enabled.
  • boolean disable() disables the Bluetooth adapter if it is enabled.
  • String getName() returns the name of the Bluetooth adapter.
  • boolean setName(String name) changes the Bluetooth name.
  • int getState() returns the current state of the local Bluetooth adapter.
  • Set<BluetoothDevice> getBondedDevices() returns a set of paired (bonded) BluetoothDevice objects.
  • boolean startDiscovery() starts the discovery process.

About Mariano

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.