AutoConnect
Connection using Auto Connect feature.
The option to passively scan and finalize the connection when the remote device is in range and available. It does not allow to set a connection timeout and will not retry on failure.
A peripheral that is not bonded is first connected directly, for up to 10 seconds. Such a device may use a Resolvable Private Address (RPA), which the system cannot use with auto connect: Android 13+ returns an error (UnsupportedAddress), and older versions accept the request, but never connect. If the direct connection fails, the peripheral uses auto connect. After the link of such a connection is lost, the peripheral uses auto connect as well, which fails for a device with an RPA that is still not bonded.
A bonded peripheral uses auto connect only.
Android terminates the link when bonding fails or when the bond information is removed. Such a peripheral is not reconnected, and is reported as disconnected, even if it was connected with auto connect. This applies to a bond removed using Peripheral.removeBond as well. If the user removes the bond in system settings ("Forget") while the peripheral is connected, the library may learn about it only after the link was lost, and starts auto connect. A peripheral that uses an RPA cannot be matched without the bond information then: Android 13+ reports UnsupportedAddress, and older versions keep the peripheral in Connecting state.
In general, the first ever connection to a device should be direct and subsequent connections to known devices should be invoked with this option.
Parameters
If true, the manager will automatically request the highest MTU supported by the remote device immediately after establishing the connection.
Opportunistic connection is available from Android 17 onwards. An opportunistic GATT client does not hold a GATT connection. It automatically disconnects when no other GATT connections are active for the remote device.