title: Which correct flag of autoConnect in connectGatt of BLE?
body: <p>My goal is to make an auto connection between Bluetooth Low Energy device and phone. I followed the sample code and I found the line</p>
  <pre><code>// We want to directly connect to the device, so we are setting the autoConnect parameter to false.
  mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
  </code></pre>
  <p>The above code means that <code>false</code> uses to autoconnection. However, I found the API at <a href="https://developer.android.com/reference/android/bluetooth/BluetoothDevice.html" rel="noreferrer">here</a>, it said that</p>
  <blockquote>
  <p>BluetoothGatt  connectGatt(Context context, boolean autoConnect, BluetoothGattCallback callback, int transport)
  Connect to GATT Server hosted by this device.</p>
  </blockquote>
  <p>And I also tried two flags: <code>true</code> and <code>false</code>, and only <code>true</code> works. I am using version &gt;= Android 5.0. Has something inconsistent between code and API? Which flag is correct? Do I need note something if I want to make the auto connection?</p>
  <p>This is my code</p>
  <pre><code>public boolean connect(final String address) {
      if (mBluetoothAdapter == null || address == null) {
          Log.w(TAG, &quot;BluetoothAdapter not initialized or unspecified address.&quot;);
          return false;
      }
  
      // Previously connected device.  Try to reconnect.
      if (mBluetoothDeviceAddress != null &amp;&amp; address.equals(mBluetoothDeviceAddress)
              &amp;&amp; mBluetoothGatt != null) {
          Log.d(TAG, &quot;Trying to use an existing mBluetoothGatt for connection.&quot;);
          if (mBluetoothGatt.connect()) {
              mConnectionState = STATE_CONNECTING;
              return true;
          } else {
              return false;
          }
      }
  
      final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
      if (device == null) {
          Log.w(TAG, &quot;Device not found.  Unable to connect.&quot;);
          return false;
      }
      // We want to directly connect to the device, so we are setting the autoConnect
      // parameter to false.
      mBluetoothGatt = device.connectGatt(this, true, mGattCallback);
      Log.d(TAG, &quot;Trying to create a new connection.&quot;);
      mBluetoothDeviceAddress = address;
      mConnectionState = STATE_CONNECTING;
      return true;
  }
  </code></pre>