public interface ConnectionCallbacks
ConnectionCallbacks
interface provides callbacks related to the connection with a device.
When connecting to a device
or when starting
to advertise
, the application should give the connection callbacks in order to be notified of the events related to
the connection with the device.
This library provides a default implementation of this interface: DefaultConnectionCallbacks
.
Modifier and Type | Method and Description |
---|---|
void |
onConnected(BluetoothDevice device)
Called when a connection attempt is successful or when a remote device connects to the adapter.
|
void |
onConnectFailed(BluetoothDevice device)
Called when a connection attempt fails.
|
void |
onDisconnected(BluetoothDevice device)
Called when the connection with a device is closed.
|
void |
onPairCompleted(BluetoothDevice device,
boolean success)
Called when the pairing procedure with a device is completed.
|
void |
onPairRequest(BluetoothDevice device)
Called when a pairing request from a device is received.
|
void |
onPasskeyGenerated(BluetoothDevice device,
int passkey)
Called when a passkey is generated to be displayed to the user.
|
void |
onPasskeyRequest(BluetoothDevice device)
Called when a passkey request from a device is received.
|
void |
onServicesDiscovered(BluetoothDevice device)
Called when the services of the device are discovered.
|
void onConnectFailed(BluetoothDevice device)
device
- the device to which the connection has failed.BluetoothDevice.connect(ConnectionCallbacks)
void onConnected(BluetoothDevice device)
device
- the device to which the connection was established.BluetoothDevice.connect(ConnectionCallbacks)
,
BluetoothAdapter.startAdvertising(AdvertisementCallbacks, ConnectionCallbacks, byte[])
void onDisconnected(BluetoothDevice device)
device
- the device to which the connection was closed.BluetoothDevice.disconnect()
void onPairRequest(BluetoothDevice device)
device
- the device from which the pairing request was received.BluetoothDevice.pairReply(boolean)
void onPairCompleted(BluetoothDevice device, boolean success)
device
- the device with which the pairing procedure was completed.success
- true if the pairing procedure was successful, false otherwise.BluetoothDevice.pair()
,
BluetoothDevice.pairReply(boolean)
void onPasskeyRequest(BluetoothDevice device)
device
- the device from which the passkey request was received.BluetoothDevice.passkeyReply(boolean, int)
void onPasskeyGenerated(BluetoothDevice device, int passkey)
device
- the device to which the passkey request was sent.passkey
- the passkey which was generated.BluetoothDevice.passkeyReply(boolean, int)
void onServicesDiscovered(BluetoothDevice device)
device
- the device of which the services were discovered.BluetoothDevice.discoverServices()