public interface ConnectionObserver
| Modifier and Type | Field and Description |
|---|---|
static int |
REASON_LINK_LOSS
This reason will only be reported when
ConnectRequest.shouldAutoConnect() was called
and connection to the device was lost. |
static int |
REASON_NOT_SUPPORTED
The device does not hav required services.
|
static int |
REASON_SUCCESS
The disconnection was initiated by the user.
|
static int |
REASON_TERMINATE_LOCAL_HOST
The local device initiated disconnection.
|
static int |
REASON_TERMINATE_PEER_USER
The remote device initiated graceful disconnection.
|
static int |
REASON_TIMEOUT
The connection timed out.
|
static int |
REASON_UNKNOWN
The reason of disconnection is unknown.
|
| Modifier and Type | Method and Description |
|---|---|
void |
onDeviceConnected(android.bluetooth.BluetoothDevice device)
Called when the device has been connected.
|
void |
onDeviceConnecting(android.bluetooth.BluetoothDevice device)
Called when the Android device started connecting to given device.
|
void |
onDeviceDisconnected(android.bluetooth.BluetoothDevice device,
int reason)
Called when the device has disconnected (when the callback returned
BluetoothGattCallback.onConnectionStateChange(BluetoothGatt, int, int) with state
DISCONNECTED). |
void |
onDeviceDisconnecting(android.bluetooth.BluetoothDevice device)
Called when user initialized disconnection.
|
void |
onDeviceFailedToConnect(android.bluetooth.BluetoothDevice device,
int reason)
Called when the device failed to connect.
|
void |
onDeviceReady(android.bluetooth.BluetoothDevice device)
Method called when all initialization requests has been completed.
|
static final int REASON_UNKNOWN
static final int REASON_SUCCESS
static final int REASON_TERMINATE_LOCAL_HOST
static final int REASON_TERMINATE_PEER_USER
static final int REASON_LINK_LOSS
ConnectRequest.shouldAutoConnect() was called
and connection to the device was lost. Android will try to connect automatically.static final int REASON_NOT_SUPPORTED
static final int REASON_TIMEOUT
void onDeviceConnecting(@NonNull
android.bluetooth.BluetoothDevice device)
onDeviceConnected(BluetoothDevice) will be called when the device is connected,
or onDeviceFailedToConnect(BluetoothDevice, int) if connection will fail.device - the device that got connected.void onDeviceConnected(@NonNull
android.bluetooth.BluetoothDevice device)
device - the device that got connected.void onDeviceFailedToConnect(@NonNull
android.bluetooth.BluetoothDevice device,
int reason)
device - the device that failed to connect.reason - the reason of failure.void onDeviceReady(@NonNull
android.bluetooth.BluetoothDevice device)
device - the device that get ready.void onDeviceDisconnecting(@NonNull
android.bluetooth.BluetoothDevice device)
device - the device that gets disconnecting.void onDeviceDisconnected(@NonNull
android.bluetooth.BluetoothDevice device,
int reason)
BluetoothGattCallback.onConnectionStateChange(BluetoothGatt, int, int) with state
DISCONNECTED).device - the device that got disconnected.reason - reason of the disconnect (mapped from the status code reported by the GATT
callback to the library specific status codes).