Android — Detect Bluetooth Pair

Vairavan Srinivasan
2 min readMar 20, 2019

Android Auto has a feature to launch automatically upon a connection to a pre-selected bluetooth device. This is meant to be used with auto’s bluetooth setup but can be customized to any of the previously paired bluetooth device.

This feature is based on discovery API of the SDK, BluetoothManager and BluetoothDevice. BluetoothManager provides BluetoothAdapter which in turn provides previously paired devices via getBondedDevices. Applications needs Bluetooth permission which is granted automatically at install time. These devices are listed in Android Auto’s AutoLaunch settings to select a preferred bluetooth device.

For the actual connection status, BluetoothDevice provides couple of broadcast intents ACTION_ACL_CONNECTED and ACTION_ACL_DISCONNECTED. These implicit intents can be registered in the manifest as they are exempted from implicit broadcast restrictions.

Framework sends ACTION_ACL_CONNECTED upon a connection with a paired bluetooth device. An application can use a similar manifest registered…

--

--