title: Android BluetoothDevice connectGatt always fails with error 133 on certain devices
body: <p>My application has issues when it comes to connecting to BluetoothGatt on certain devices.</p>
  
  <p>All the BLE related code resides in an android <code>Service</code> and everything works fine except on <em>Huawei CAM-L03</em>. Some old Samsung Galaxy devices also have been reported to have issues.</p>
  
  <p>I have discovered recently, that on some devices all the BLE communications must be performed on the UI thread. I wrote a quick test application and the Huawei problems are gone when everything runs on the UI thread.</p>
  
  <p>I’ve tried creating a <code>Handler</code> in the <code>Service</code> with the main looper:</p>
  
  <pre><code>final Context context = getApplicationContext();
  Handler handler = new Handler(context.getMainLooper());
  handler.post(new Runnable(){
      @Override
      public void run() {
          BluetoothGatt gatt = device.connectGatt(context, false, callBackHandler);
          …
      } 
  });
  </code></pre>
  
  <p>But that still gives me GATT_ERROR 133 in the connection callback, which I kind of suspected since the context is the service, not the UI app.</p>
  
  <p>I only see two options here:</p>
  
  <ol>
  <li>List item Don’t support certain devices</li>
  <li>Move everything to the UI app to support all devices</li>
  </ol>
  
  <p>I’m not content with either of these. Are there other options that I don’t know about?</p>