How to enable or disable Bluetooth in android programmatically

In this post, we will see how to enable or disable Bluetooth in android programmatically.
It is very simple to enable or disable bluetooth from android code.
For enabling Bluetooth:
For disabling Bluetooth:
So you can enable or disable Bluetooth using BluetoothAdapter class.
You need to add extra permissions in AndroidManifest.xml to enable or disable Bluetooth.

Source code:


click to begin
20KB .zip

Step 1 :

Create an android application project named “EnableDisableBluetoothApp”.

💻 Awesome Tech Resources:
  • Looking for ⚒️ tech jobs? Go to our job portal.
  • Looking for tech events? Go to tech events 🗓️ Calendar.️

Step 2:

Add following permissions in AndoridManifest.xml.

Step 3 :

Change res ->layout -> activity_main.xml as below:

Step 4:

Change src/main/packageName/ as below:

Step 5:

Run the app
When you run the app, you will get below screen:

When you click on toggle button, you will get below screen:

Related Posts


Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.