- "Introduction to Bluetooth Low Energy" by Adafruit.
- "Android Lollipop: Bluetooth LE Matures" (video).
- "Bluetooth (LE) with Dave (devunwired) Smith" (podcast).
- "State of BLE on Android in 2022" (slides, video).
- NordicSemiconductor/Android-BLE-Library - Contains production-ready implementations of many of the important components (queues, managers, etc.) for working with BLE on Android. Consider using this library as-is or browsing the source code as inspiration if building your own implementation.
- Polidea/RxAndroidBle - For using RxJava with BLE.
- Beepiz/BleGattCoroutines - For using Kotlin's coroutines to sidestep BLE callback hell.
- HubbellCorp/SweetBlue.
- douglasjunior/AndroidBluetoothLibrary.
- JuulLabs/kable - Coroutines-based Kotlin Multiplatform library.
- ErikHellman/android-blex.
Resources relevant to building Bluetooth Low Energy Android applications from scratch.
- "Bluetooth Low Energy on Android: Top Tips For The Tricky Bits" (slides, video) by Stuart Kent - My own talk, but now several years old.
- "The Ultimate Guide to Android Bluetooth Low Energy" by PunchThrough - A very modern (2020) comprehensive guide.
- "Bluetooth LE for modern Android Development" series (part 1, part 2, part 3) by Erik Hellman - Articles with advice that's particularly relevant in 2022.
- Android BLE Issues - A fairly complete list of symptoms you are likely to encounter while working with Android's BLE stack. Some apply to pre-Lollipop only, but many still exist and occur.
- PunchThrough/ble-starter-android - Source code accompanying the PunchThrough guide listed above.
- NordicSemiconductor/Android-nRF-Blinky - Source code for an Android app that uses Nordic Semiconductor's Android-BLE-Library.
- android/connectivity-samples (BluetoothLeGatt) - A compact
Service
and broadcast based example.
- Locations within the AOSP source code where GATT success and error codes are defined:
Useful users, questions, answers, and comments from Stack Overflow's Q&A.
- Emil - A user who consistently provides high-quality and detailed information regarding BLE on Android. Worth browsing their answers!
- "Android 4.3 Bluetooth Low Energy unstable" - In particular, this answer is a great overview and includes a hint regarding Wi-Fi/BLE interactions that I haven't seen elsewhere.
- "How to detect Bluetooth state change using a broadcast receiver?"
- "Difference between close() and disconnect() in Android Bluetooth API?"
- "Android - Could not connect to bluetooth device on Lollipop" - This answer provides some tips regarding the transport type flag passed to
BluetoothDevice.connectGatt
. - "Android Bluetooth LE: Not discovering services after connection" - This comment indicates that one should delay calls to
BluetoothGatt.close
until either (1) disconnection completes, or (2) a predefined period of time elapses. - "How to programmatically force bluetooth low energy service discovery on Android without using cache" - This answer formed the basis of my refined service cache-clearing method.
- "Android 4.3: How to connect to multiple Bluetooth Low Energy devices" - This answer discusses the serial nature of the Bluetooth APIs and indicates that things work the same for web and iOS.
- "Android BLE API: GATT Notification not received"
- "RxAndroidBle keeping a persistant connection + Write/Notification handling" - This answer confirms that RxAndroidBle was not designed to accommodate persistent connections. UPDATE: apparently this is possible; see author's tweet here.
- "Location requirement to scan for BLE devices" - This answer provides some context regarding the location permission requirement for scanning.
- "Is the native Android BLE implementation synchronous in nature?" - This answer confirms (from a Samsung perspective) that BLE operations should be performed serially.
- "clientIf field in Android BluetoothGatt class" - Some information on the
clientIf
value that's logged with almost all Android BLE calls. - "Why does setCharacteristicNotification() not actually enable notifications?"
- "Android Bluetooth Low Energy Characteristic notification count limit: does this vary by device?" - Clarification that the stack's 15 characteristic notifications limit is a limit per peripheral/server rather than per central/client/mobile device.
(You must sign in with a Google account to access these.)
- "Android 4.3: Bluetooth LE pretty instable"
- "NullPointerException in BluetoothGatt.java when disconnecting and closing" - Includes discussion regarding exactly when
BluetoothGatt.disconnect
andBluetoothGatt.close
should be called. - "Emulator and Bluetooth" - Requests the addition of Bluetooth support to Android emulators (via host device Bluetooth).
- "Bluetooth permission request dialog" - Bug report related to weird window pop-up while programmatically prompting user to enable Bluetooth.
- "Get BLE scan result using 'BluetoothLeScanner.startScan' must open Location Service in Android 6.0" - Long thread related to location permissions and services requirements.
- "[BLE] Android does not discover services if device supports Service Changed" - Thread related to service caching and how to skip the cache.
When I scan for BLE peripherals without any filter, I see my custom peripheral, but the moment I add a scan filter like the following, I don't see it anymore:
And yet in nrfConnect, I can see the following advertisement data for my BLE peripheral:
Click for image
And of course, the MY_SERVICE_UUID constant matches the service UUID in the screenshot.
Plus, I'm working now on the Android port of an iOS application that scans for BLE devices with the same kind of filters and it works.
How do scan filters work exactly? What is the requirement for a peripheral to be accepted by such a filter?