Android How to - Checks if the bluetooth adapter is on and ready








Question

We would like to know how to check if the bluetooth adapter is on and ready.

Answer

We can get the status of the blue tooth from the BluetoothAdapter.

/*from  w  w w .jav  a 2 s . c  om*/
import android.bluetooth.BluetoothAdapter;
public class Main {
  
  /**
   * Checks if the bluetooth adapter is on and ready.
   */
  public static boolean isBluetoothAvailable() {
    BluetoothAdapter tempBtAdapter = BluetoothAdapter.getDefaultAdapter();
    return tempBtAdapter != null && tempBtAdapter.isEnabled();
  }
}