Android-BLE-Library
Android-BLE-Library copied to clipboard
Can't receive data via BLE on Android 14
I have created Jetpack compose Android application which connects to a BLE device. BLE device updates its state and sends data to the app. Previously I have used Android 11 device and now I have updated my device to one that has Android 14.
I'm facing problem when trying to send data to app with Android 14. I'm using v2.9.0. On Android end, I receive characteristic changes like this:
private val dataReceiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
val action = intent!!.action
Log.i(tag, "This is the action $action")
try {
when (action) {
bluetoothManager.actionConnected -> {
}
bluetoothManager.actionDisconnected -> {
}
bluetoothManager.actionDataAvailable -> {
}
bluetoothManager.actionInfoAvailable -> {
}
bluetoothManager.actionError -> {
}
}
} catch (e: Exception) {
Log.e(tag, "onReceive ${e.stackTraceToString()}")
}
When using exactly same code (excluding BLE permissions), with Android 11, I receive data normally and in the Log I get "This is the action ACTION_DATA_AVAILABLE" as expected. With Android 14 I get status updates e.g. "This is the action CONNECTED" and "This is the action DISCONNECTED" but for some reason it doesn't register "This is the action ACTION_DATA_AVAILABLE". When changing back to phone with Android 11 everything works as expected. I have also verified that code works with Android 12. Problems occurs now only with Android 14.
What might cause this? Are there some sort of security things that I need to take into account etc.?