title: ACL_CONNECTED / ACL_DISCONNECTED doesn't always received
body: <p>I'm developing an application in which I need to listen to bluetooth connection/disconnection events.</p>
  
  <p>The broadcasts are getting received most of the time, but not always.</p>
  
  <p>My logs also support this.</p>
  
  <p>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.</p>
  
  <p>Here's the declaration in the manifest:</p>
  
  <pre><code>  &lt;receiver android:name=".receivers.BluetoothBroadcastReceiver" &gt;
          &lt;intent-filter android:priority="999"&gt;
              &lt;action android:name="android.bluetooth.device.action.ACL_DISCONNECTED"/&gt;
              &lt;action android:name="android.bluetooth.device.action.ACL_CONNECTED"/&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  </code></pre>
  
  <p>Is someone familiar with this issue?</p>
  
  <p><strong>Note (06/20/18):</strong></p>
  
  <p>Most of my tests are done with Samsung devices. </p>
  
  <p>Samsung has its own battery optimisation mechanism, as can be seen in those posts:</p>
  
  <p><a href="https://stackoverflow.com/questions/36850109/samsung-app-optimisation-feature-kills-background-applications-after-3-days">Samsung &quot;App optimisation&quot; feature kills background applications after 3 days</a></p>
  
  <p><a href="https://stackoverflow.com/questions/37205106/how-do-i-avoid-that-my-app-enters-optimization-on-samsung-devices">How do I avoid that my App enters optimization on Samsung devices</a></p>
  
  <p>It seems that the problem is somehow related to this Samsung thing.</p>
  
  <p>According to my logs, it seems like that the inconsistent broadcasts problem, really starts to appear after 3 days</p>
  
  <p>Thanks!</p>