I'm developing an application in which I need to listen to bluetooth connection/disconnection events.
The broadcasts are getting received most of the time, but not always.
My logs also support this.
I can see in my logs that sometimes I'm getting 2 or 3 ACL_CONNECTED events in a row (for the same device!) without getting ACL_DISCONNECTED in between, and vice versa.
Here's the declaration in the manifest:
<receiver android:name=".receivers.BluetoothBroadcastReceiver" >
<intent-filter android:priority="999">
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED"/>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED"/>
</intent-filter>
</receiver>
Is someone familiar with this issue?
Note (06/20/18):
Most of my tests are done with Samsung devices.
Samsung has its own battery optimisation mechanism, as can be seen in those posts:
Samsung "App optimisation" feature kills background applications after 3 days
How do I avoid that my App enters optimization on Samsung devices
It seems that the problem is somehow related to this Samsung thing.
According to my logs, it seems like that the inconsistent broadcasts problem, really starts to appear after 3 days
Thanks!