Check Bluetooth is turned on or off on Android device programmatically [Java Code]

If you are looking for code to programmatically check if Bluetooth is turned on or off on the Android device, then here are examples for both Java and Kotlin,

Java Example: Check if bluetoon is turned on or off

package com.code2care.demobluetooth;


import android.bluetooth.BluetoothAdapter;
import android.content.IntentFilter;
import android.os.Bundle;
import android.widget.Toast;

public class CheckBluetoothActivity extends AppCompatActivity {

    protected void onCreate(Bundle savedInstanceState) {

        Toast toast = Toast.makeText(CheckBluetoothActivity.this, 
		"Bluetooth Enabled: "+ isBluetoothEnabled() , Toast.LENGTH_SHORT);;


    //This method checks if bluetooth is
    //enabled on the Android device or not
    public boolean isBluetoothEnabled(){
        BluetoothAdapter myBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
            return true;
        } else {
            return false;

Make sure you add the below permissions to access Bluetooth in your manifest XML file,

<uses-permission android:name="android.permission.BLUETOOTH" />|

If you don't add the above line you will get the below error,

   java.lang.RuntimeException: Unable to start activity 
java.lang.SecurityException: Need BLUETOOTH permission: 
Neither user 10123 nor current process has android.permission.BLUETOOTH.
     Caused by: java.lang.SecurityException: Need BLUETOOTH permission: 
   Neither user 10123 nor current process has android.permission.BLUETOOTH.
        at android.os.Parcel.readException(
        at android.os.Parcel.readException(
        at android.bluetooth.IBluetooth$Stub$Proxy.isEnabled(
        at android.bluetooth.BluetoothAdapter.isEnabled(
        at com.code2care.testing.MainActivity.isBluetoothEnabled(
        at com.code2care.testing.MainActivity.onCreate(
        at java.lang.reflect.Method.invoke(Native Method) 
Try Out Code2care Dev Tools:


Android Java Linux Microsoft Google Python macOS Notepad++ Microsoft Teams CSS PHP SharePoint Html Linux C Programs Bootstrap jQuery Sublime Android Studio Facebook Eclipse WhatsApp News MySQL Json HowTos JavaScript FTP S3


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Tutorials, Trouble-Shooting steps, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.
🎉 We are celebrating the 10th years of Code2care! Thank you for all your support! We hope we made a difference.
We strong support Gender Equality & Diversity.

We stand in solidarity with Ukraine - Make a donation to UNHCR -