Package ej.bluetooth.listeners.impl

## Class DefaultConnectionListener

- java.lang.Object
- - ej.bluetooth.listeners.impl.DefaultConnectionListener

- All Implemented Interfaces:
    `ConnectionListener`

      public class DefaultConnectionListener
      extends Object
      implements ConnectionListener

  The `DefaultConnectionListener` class provides a default implementation of the `ConnectionListener` interface.

  The implementation of the `onConnected()` method discovers all services. The implementation of the `onPairRequest()` method rejects the pair request. The implementation of the `onPasskeyRequest()` method rejects the passkey request. The implementation of each of the other methods does nothing.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DefaultConnectionListener()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `onAdvertisementCompleted()` | Called when an ongoing advertisement is completed.
    `void` | `onConnected​(BluetoothConnection connection)` | Called when a connection attempt is successful or when a remote device connects to the adapter.
    `void` | `onConnectFailed​(BluetoothAddress address)` | Called when a connection attempt fails.
    `void` | `onDisconnected​(BluetoothConnection connection)` | Called when the connection with a device is closed.
    `void` | `onDiscoveryCompleted​(BluetoothConnection connection)` | Called when a service discovery is completed.
    `void` | `onDiscoveryResult​(BluetoothConnection connection, BluetoothService service)` | Called when a service provided by a device has been discovered.
    `void` | `onPairCompleted​(BluetoothConnection connection, boolean success)` | Called when the pairing procedure with a device is completed.
    `void` | `onPairRequest​(BluetoothConnection connection)` | Called when a pairing request from a device is received.
    `void` | `onPasskeyGenerated​(BluetoothConnection connection, int passkey)` | Called when a passkey is generated to be displayed to the user.
    `void` | `onPasskeyRequest​(BluetoothConnection connection)` | Called when a passkey request from a device is received.
    `void` | `onScanCompleted()` | Called when an ongoing scan is completed.
    `void` | `onScanResult​(BluetoothAddress address, byte[] advertisementData, int rssi)` | Called when a advertisement or a scan response is received.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultConnectionListener

          public DefaultConnectionListener()

  - ### Method Detail

    - #### onAdvertisementCompleted

          public void onAdvertisementCompleted()

      Description copied from interface: `ConnectionListener`
      Called when an ongoing advertisement is completed.
      Specified by:
        `onAdvertisementCompleted` in interface `ConnectionListener`
      See Also:
        `BluetoothAdapter.startAdvertising(byte[])`, `BluetoothAdapter.stopAdvertising()`

    - #### onScanCompleted

          public void onScanCompleted()

      Description copied from interface: `ConnectionListener`
      Called when an ongoing scan is completed.
      Specified by:
        `onScanCompleted` in interface `ConnectionListener`
      See Also:
        `BluetoothAdapter.startScanning(ej.bluetooth.BluetoothScanFilter)`, `BluetoothAdapter.stopScanning()`

    - #### onScanResult

          public void onScanResult​(BluetoothAddress address,
                                   byte[] advertisementData,
                                   int rssi)

      Description copied from interface: `ConnectionListener`
      Called when a advertisement or a scan response is received.
      Specified by:
        `onScanResult` in interface `ConnectionListener`
      Parameters:
        `address` - the address of the device which has sent the advertisement.
        `advertisementData` - the advertisement data.
        `rssi` - the RSSI measurement.
      See Also:
        `BluetoothAdapter.startScanning(ej.bluetooth.BluetoothScanFilter)`, `BluetoothAdapter.stopScanning()`

    - #### onConnectFailed

          public void onConnectFailed​(BluetoothAddress address)

      Description copied from interface: `ConnectionListener`
      Called when a connection attempt fails.
      Specified by:
        `onConnectFailed` in interface `ConnectionListener`
      Parameters:
        `address` - the address of the device to which the connection has failed.
      See Also:
        `BluetoothAdapter.connect(BluetoothAddress)`

    - #### onConnected

          public void onConnected​(BluetoothConnection connection)

      Description copied from interface: `ConnectionListener`
      Called when a connection attempt is successful or when a remote device connects to the adapter.
      Specified by:
        `onConnected` in interface `ConnectionListener`
      Parameters:
        `connection` - the connection which was established.
      See Also:
        `BluetoothAdapter.connect(BluetoothAddress)`, `BluetoothAdapter.startAdvertising(byte[])`

    - #### onDisconnected

          public void onDisconnected​(BluetoothConnection connection)

      Description copied from interface: `ConnectionListener`
      Called when the connection with a device is closed.
      Specified by:
        `onDisconnected` in interface `ConnectionListener`
      Parameters:
        `connection` - the connection which was closed.
      See Also:
        `BluetoothConnection.disconnect()`

    - #### onPairRequest

          public void onPairRequest​(BluetoothConnection connection)

      Description copied from interface: `ConnectionListener`
      Called when a pairing request from a device is received.
      Specified by:
        `onPairRequest` in interface `ConnectionListener`
      Parameters:
        `connection` - the connection with the device from which the pairing request was received.
      See Also:
        `BluetoothConnection.sendPairResponse(boolean)`

    - #### onPairCompleted

          public void onPairCompleted​(BluetoothConnection connection,
                                      boolean success)

      Description copied from interface: `ConnectionListener`
      Called when the pairing procedure with a device is completed.
      Specified by:
        `onPairCompleted` in interface `ConnectionListener`
      Parameters:
        `connection` - the connection with the device with which the pairing procedure was completed.
        `success` - true if the pairing procedure was successful, false otherwise.
      See Also:
        `BluetoothConnection.sendPairRequest()`, `BluetoothConnection.sendPairResponse(boolean)`

    - #### onPasskeyRequest

          public void onPasskeyRequest​(BluetoothConnection connection)

      Description copied from interface: `ConnectionListener`
      Called when a passkey request from a device is received.
      Specified by:
        `onPasskeyRequest` in interface `ConnectionListener`
      Parameters:
        `connection` - the connection with the device from which the passkey request was received.
      See Also:
        `BluetoothConnection.sendPasskeyResponse(boolean, int)`

    - #### onPasskeyGenerated

          public void onPasskeyGenerated​(BluetoothConnection connection,
                                         int passkey)

      Description copied from interface: `ConnectionListener`
      Called when a passkey is generated to be displayed to the user.
      Specified by:
        `onPasskeyGenerated` in interface `ConnectionListener`
      Parameters:
        `connection` - the connection with the device to which the passkey request was sent.
        `passkey` - the passkey which was generated.
      See Also:
        `BluetoothConnection.sendPasskeyResponse(boolean, int)`

    - #### onDiscoveryResult

          public void onDiscoveryResult​(BluetoothConnection connection,
                                        BluetoothService service)

      Description copied from interface: `ConnectionListener`
      Called when a service provided by a device has been discovered.
      Specified by:
        `onDiscoveryResult` in interface `ConnectionListener`
      Parameters:
        `connection` - the connection with the device which provides the service.
        `service` - the service which has been discovered.
      See Also:
        `BluetoothConnection.discoverServices()`, `BluetoothConnection.discoverService(ej.bluetooth.BluetoothUuid)`

    - #### onDiscoveryCompleted

          public void onDiscoveryCompleted​(BluetoothConnection connection)

      Description copied from interface: `ConnectionListener`
      Called when a service discovery is completed.
      Specified by:
        `onDiscoveryCompleted` in interface `ConnectionListener`
      Parameters:
        `connection` - the connection with the device with which the discovery was initiated.
      See Also:
        `BluetoothConnection.discoverServices()`, `BluetoothConnection.discoverService(ej.bluetooth.BluetoothUuid)`