Difference between close() and disconnect()?

android, bluetooth, bluetooth-lowenergy

Solution

With `disconnect()` you can later call `connect()` and continue with that cycle.

Once you call `close()` you are done. If you want to connect again you will have to call `connectGatt()` on the `BluetoothDevice` again; `close()` will release any resources held by `BluetoothGatt`.

Problem

Android Bluetooth Low Energy API implements 1 method to connect to the device `connectGatt()` but 2 methods to close the connection `disconnect()` and `close()`. Documentation says: `disconnect()`: Disconnects an established connection, or cancels a connection attempt currently in progress. `close()`: Application should call this method as early as possible after it is done with this GATT client. The source code of BluetoothGatt.java shows that close() unregisters the application and disconnect() disconnect the client. However it does not say what that actually means. I mean, if there is only 1 way to connect to the client, why there are 2 ways to close/disconnect the connection?

Original source