title: onServicesDiscovered never called while connecting to GATT Server
body: <p>I have a bluetooth headset which is paired with my Nexus 5X (running Android 7.1) and I would like to connect to a GATT Server of the headset. I tried it with the following code:</p>
  
  <pre><code>private BluetoothGattCallback btleGattCallback = new BluetoothGattCallback() {
      @Override
      public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
          Log.d(TAG, "onConnectionStateChange: " + status + ", " + newState);
  
          if(newState == STATE_CONNECTED) {
              Log.d(TAG, "Device connected");
              boolean ans = gatt.discoverServices();
              Log.d(TAG, "Discover Services started: " + ans);
          }
      }
  
      @Override
      public void onServicesDiscovered(BluetoothGatt gatt, int status) {
              Log.d(TAG, "Number of Services: " + gatt.getServices().size());
      }
  };
  
  public void onDeviceClicked(BluetoothDevice device) {
      BluetoothGatt gatt = device.connectGatt(this, false, btleGattCallback);
      Log.d(TAG, "Connected to GATT: " + gatt.connect());
  }
  </code></pre>
  
  <p>If I click on the headset in my UI <code>onDeviceClicked</code> is called and it comes to this Log output:</p>
  
  <pre><code>&lt;!-- language: lang-none --&gt;
  Connected to GATT: true
  onConnectionStateChange: 0, 2    // GATT_SUCCESS, STATE_CONNECTED
  Device connected
  Discover Services started: true
  </code></pre>
  
  <p>As you can see <code>onServicesDiscovered</code> is never fired. I tried to call <code>connectGatt</code> with <code>TRANSPORT_LE</code> (<a href="https://stackoverflow.com/a/31369286/2047987">ref</a>) but then I get a <code>onConnectionStateChange: 133, 0</code>. I also found <a href="https://stackoverflow.com/questions/25848764/onservicesdiscoveredbluetoothgatt-gatt-int-status-is-never-called">this question</a> which is why I added the <code>gatt.connect()</code> method as mentioned in answer two.</p>
  
  <p>Do you have any ideas why I don't get the <code>onServicesDiscovered</code> callback?</p>