raspberry-piandroid-thingshc-05

Bluetooth not working in Android things for Rasberry Pi


When I try to enable BluetoothAdapter I get the following error.

 08-30 11:53:34.310 1492-1492/com.example.androidthings.gattserver D/GattServerActivity: Bluetooth is currently disabled...enabling 
 08-30 11:53:34.314 1492-1492/com.example.androidthings.gattserver D/GattServerActivity: Bluetooth is currently disabled...enabling 
 08-30 11:53:34.585 1492-1492/com.example.androidthings.gattserver D/vndksupport: Loading /vendor/lib/hw/android.hardware.graphics.mapper@2.0-impl.so from current namespace instead of sphal namespace. 
 08-30 11:53:34.787 1492-1505/com.example.androidthings.gattserver D/BluetoothAdapter: onBluetoothServiceUp: android.bluetooth.IBluetooth$Stub$Proxy@c8a1daa
 08-30 11:53:46.854 1492-1506/com.example.androidthings.gattserver D/BluetoothAdapter: onBluetoothServiceDown: android.bluetooth.IBluetooth$Stub$Proxy@c8a1daa

Can someone help me to understand and fix this error?


Solution

  • When enabling Bluetooth in Android Things, do it programatically with:

    adapter.enable()
    

    The REQUEST_ENABLE_INTENT may not work since your Raspberry might not be connected to a screen and won't show the permission dialog. Remember that you will also need the BLUETOOTH_ADMIN permission.