Check Bluetooth Status Using Bluetooth Adapter

This example will explain how to check if Bluetooth is supported in running device and whether its ON or OFF.

In the example below we will call startActivityForResult() with Intent of BluetoothAdapter.ACTION_REQUEST_ENABLE, when user click button to enable it. Then we will re-check the status again in onActivityResult() when result returned.

Follow the steps below to create the code example:

Step1

Create a new android project in your android IDE and follow the steps of new project template. You will get some default code in main activity and main layout file. Replace the code of your main layout with the code below:

 

 

 

Step2

We will manage the the call to BluetoothAdapter intent in our main activity file. Write below code in your activity:

 

 

 

Step3

You must need the bluetooth access permission to access the status from you app. So add BlueTooth permission in manifest file as below:

 

 

 

OutPut

Run to check the output as below:

bluetooth1

bluetooth2

That’s it. Happy Coding 🙂

Leave a Comment: