// Check if a bluetooth device is connected in Android fun isBluetoothHeadsetConnected(): Boolean { val mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter() return (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled && mBluetoothAdapter.getProfileConnectionState(BluetoothHeadset.HEADSET) == BluetoothHeadset.STATE_CONNECTED) }