Search code examples
androidandroid-bluetoothandroid-ble

Why is onCharacteristicChanged never called when it should be?


I'm working with Bluetooth (BLE) in an Android app.

There is a characteristic that should be triggering callbacks to onCharacteristicChanged, but the callbacks never happen. Other functions of the device which don't rely on these callbacks work fine. I did setCharacteristicNotification(true) for the characteristic.

I've tried issuing readCharacteristic to explicity read it, but that doesn't do anything.

I know the device works because I have an iOS app that uses the same device and it receives these callbacks fine. I also have access to a debug log on the device itself and I can see that it is trying to send the data I'm expecting.

Does anyone know what would cause Android to fail to call onCharacteristicChanged even though notifications are set? I read somewhere that there is a limit of 15 active notifications, but I only have one so that can't be it.

Thanks.


Solution

  • Setting characteristic callback is not enough. You need to write a proper descriptor value to activate notifications. See https://stackoverflow.com/a/39492068