Added in API level 34

BluetoothSocketException


open class BluetoothSocketException : IOException
kotlin.Any
   ↳ kotlin.Throwable
   ↳ java.lang.Exception
   ↳ java.io.IOException
   ↳ android.bluetooth.BluetoothSocketException

Thrown when an error occurs during a Bluetooth Socket related exception.

This is currently only intended to be thrown for a failure during android.bluetooth.BluetoothSocket#connect() operation.

Summary

Constants
static Int

Error code during connect when Bluetooth is off and socket connection is triggered.

static Int

Error code during connect when there is an ACL connection failure.

static Int

Error code during connect when security clearance fails on the client during L2CAP connection.

static Int

Error code during connect when authentication fails on the peer device during L2CAP connection.

static Int

Error code during connect when authorization fails on the peer device during L2CAP connection.

static Int

Error code during connect for insufficient encryption from the peer device during L2CAP connection.

static Int

Error code during connect indicating insufficient encryption key size on the peer device during L2CAP connection.

static Int

Error code during connect for invalid parameters from the peer device during L2CAP connection.

static Int

Error code during connect for invalid Channel ID from the peer device during L2CAP connection.

static Int

Error code during connect when no PSM is available for L2CAP connection.

static Int

Error code during connect when no resources are available for L2CAP connection.

static Int

Error code during connect for already allocated Channel ID from the peer device during L2CAP connection.

static Int

Error code during connect when L2CAP connection timeout.

static Int

Error code during connect for unacceptable Parameters from the peer device during L2CAP connection.

static Int

Error code during connect when socket connection fails for unknown reason during L2CAP connection.

static Int

Error code during connect when null device attempts to do socket connection.

static Int

Error code during connect when a Runtime RPC exception occurs.

static Int

Error code during connect when socket is closed.

static Int

Error code during connect for generic socket connection failures.

static Int

Error code during connect when socket manager is not available.

static Int

Error code during connect when the UNIX socket connection creation fails.

static Int

Error code representing a failure during BluetoothSocket.

Public constructors

Create a BluetoothSocketException with an error code and custom error message.

Create a BluetoothSocketException with an error code.

Public methods
open Int

Returns the error code associated to this failure.

Constants

BLUETOOTH_OFF_FAILURE

Added in API level 34
static val BLUETOOTH_OFF_FAILURE: Int

Error code during connect when Bluetooth is off and socket connection is triggered.

Value: 15

L2CAP_ACL_FAILURE

Added in API level 34
static val L2CAP_ACL_FAILURE: Int

Error code during connect when there is an ACL connection failure.

Value: 2

L2CAP_CLIENT_SECURITY_FAILURE

Added in API level 34
static val L2CAP_CLIENT_SECURITY_FAILURE: Int

Error code during connect when security clearance fails on the client during L2CAP connection.

Value: 3

L2CAP_INSUFFICIENT_AUTHENTICATION

Added in API level 34
static val L2CAP_INSUFFICIENT_AUTHENTICATION: Int

Error code during connect when authentication fails on the peer device during L2CAP connection.

Value: 4

L2CAP_INSUFFICIENT_AUTHORIZATION

Added in API level 34
static val L2CAP_INSUFFICIENT_AUTHORIZATION: Int

Error code during connect when authorization fails on the peer device during L2CAP connection.

Value: 5

L2CAP_INSUFFICIENT_ENCRYPTION

Added in API level 34
static val L2CAP_INSUFFICIENT_ENCRYPTION: Int

Error code during connect for insufficient encryption from the peer device during L2CAP connection.

Value: 7

L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE

Added in API level 34
static val L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE: Int

Error code during connect indicating insufficient encryption key size on the peer device during L2CAP connection.

Value: 6

L2CAP_INVALID_PARAMETERS

Added in API level 34
static val L2CAP_INVALID_PARAMETERS: Int

Error code during connect for invalid parameters from the peer device during L2CAP connection.

Value: 11

L2CAP_INVALID_SOURCE_CID

Added in API level 34
static val L2CAP_INVALID_SOURCE_CID: Int

Error code during connect for invalid Channel ID from the peer device during L2CAP connection.

Value: 8

L2CAP_NO_PSM_AVAILABLE

Added in API level 34
static val L2CAP_NO_PSM_AVAILABLE: Int

Error code during connect when no PSM is available for L2CAP connection.

Value: 13

L2CAP_NO_RESOURCES

Added in API level 34
static val L2CAP_NO_RESOURCES: Int

Error code during connect when no resources are available for L2CAP connection.

Value: 12

L2CAP_SOURCE_CID_ALREADY_ALLOCATED

Added in API level 34
static val L2CAP_SOURCE_CID_ALREADY_ALLOCATED: Int

Error code during connect for already allocated Channel ID from the peer device during L2CAP connection.

Value: 9

L2CAP_TIMEOUT

Added in API level 34
static val L2CAP_TIMEOUT: Int

Error code during connect when L2CAP connection timeout.

Value: 14

L2CAP_UNACCEPTABLE_PARAMETERS

Added in API level 34
static val L2CAP_UNACCEPTABLE_PARAMETERS: Int

Error code during connect for unacceptable Parameters from the peer device during L2CAP connection.

Value: 10

L2CAP_UNKNOWN

Added in API level 34
static val L2CAP_UNKNOWN: Int

Error code during connect when socket connection fails for unknown reason during L2CAP connection.

Value: 1

NULL_DEVICE

Added in API level 34
static val NULL_DEVICE: Int

Error code during connect when null device attempts to do socket connection.

Value: 19

RPC_FAILURE

Added in API level 34
static val RPC_FAILURE: Int

Error code during connect when a Runtime RPC exception occurs.

Value: 20

SOCKET_CLOSED

Added in API level 34
static val SOCKET_CLOSED: Int

Error code during connect when socket is closed.

Value: 17

SOCKET_CONNECTION_FAILURE

Added in API level 34
static val SOCKET_CONNECTION_FAILURE: Int

Error code during connect for generic socket connection failures.

Value: 18

SOCKET_MANAGER_FAILURE

Added in API level 34
static val SOCKET_MANAGER_FAILURE: Int

Error code during connect when socket manager is not available.

Value: 16

UNIX_FILE_SOCKET_CREATION_FAILURE

Added in API level 35
static val UNIX_FILE_SOCKET_CREATION_FAILURE: Int

Error code during connect when the UNIX socket connection creation fails.

Value: 21

UNSPECIFIED

Added in API level 34
static val UNSPECIFIED: Int

Error code representing a failure during BluetoothSocket. The reason for failure isn't specified.

Value: 0

Public constructors

BluetoothSocketException

Added in API level 34
BluetoothSocketException(
    code: Int,
    msg: String)

Create a BluetoothSocketException with an error code and custom error message.

Parameters
code Int: : error code representing the reason for failure. Value is android.bluetooth.BluetoothSocketException#UNSPECIFIED, android.bluetooth.BluetoothSocketException#L2CAP_UNKNOWN, android.bluetooth.BluetoothSocketException#L2CAP_ACL_FAILURE, android.bluetooth.BluetoothSocketException#L2CAP_CLIENT_SECURITY_FAILURE, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHENTICATION, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHORIZATION, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPTION, android.bluetooth.BluetoothSocketException#L2CAP_INVALID_SOURCE_CID, android.bluetooth.BluetoothSocketException#L2CAP_SOURCE_CID_ALREADY_ALLOCATED, android.bluetooth.BluetoothSocketException#L2CAP_UNACCEPTABLE_PARAMETERS, android.bluetooth.BluetoothSocketException#L2CAP_INVALID_PARAMETERS, android.bluetooth.BluetoothSocketException#L2CAP_NO_RESOURCES, android.bluetooth.BluetoothSocketException#L2CAP_NO_PSM_AVAILABLE, android.bluetooth.BluetoothSocketException#L2CAP_TIMEOUT, android.bluetooth.BluetoothSocketException#BLUETOOTH_OFF_FAILURE, android.bluetooth.BluetoothSocketException#SOCKET_MANAGER_FAILURE, android.bluetooth.BluetoothSocketException#SOCKET_CLOSED, android.bluetooth.BluetoothSocketException#SOCKET_CONNECTION_FAILURE, android.bluetooth.BluetoothSocketException#NULL_DEVICE, android.bluetooth.BluetoothSocketException#RPC_FAILURE, or android.bluetooth.BluetoothSocketException#UNIX_FILE_SOCKET_CREATION_FAILURE
msg String: : Custom error message associated to the failure. This value cannot be null.

BluetoothSocketException

Added in API level 34
BluetoothSocketException(code: Int)

Create a BluetoothSocketException with an error code. A generic error message is generated based on the code provided.

Parameters
code Int: : error code representing the reason for failure. Value is android.bluetooth.BluetoothSocketException#UNSPECIFIED, android.bluetooth.BluetoothSocketException#L2CAP_UNKNOWN, android.bluetooth.BluetoothSocketException#L2CAP_ACL_FAILURE, android.bluetooth.BluetoothSocketException#L2CAP_CLIENT_SECURITY_FAILURE, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHENTICATION, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHORIZATION, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPTION, android.bluetooth.BluetoothSocketException#L2CAP_INVALID_SOURCE_CID, android.bluetooth.BluetoothSocketException#L2CAP_SOURCE_CID_ALREADY_ALLOCATED, android.bluetooth.BluetoothSocketException#L2CAP_UNACCEPTABLE_PARAMETERS, android.bluetooth.BluetoothSocketException#L2CAP_INVALID_PARAMETERS, android.bluetooth.BluetoothSocketException#L2CAP_NO_RESOURCES, android.bluetooth.BluetoothSocketException#L2CAP_NO_PSM_AVAILABLE, android.bluetooth.BluetoothSocketException#L2CAP_TIMEOUT, android.bluetooth.BluetoothSocketException#BLUETOOTH_OFF_FAILURE, android.bluetooth.BluetoothSocketException#SOCKET_MANAGER_FAILURE, android.bluetooth.BluetoothSocketException#SOCKET_CLOSED, android.bluetooth.BluetoothSocketException#SOCKET_CONNECTION_FAILURE, android.bluetooth.BluetoothSocketException#NULL_DEVICE, android.bluetooth.BluetoothSocketException#RPC_FAILURE, or android.bluetooth.BluetoothSocketException#UNIX_FILE_SOCKET_CREATION_FAILURE

Public methods

getErrorCode

Added in API level 34
open fun getErrorCode(): Int

Returns the error code associated to this failure.

Return
Int Value is android.bluetooth.BluetoothSocketException#UNSPECIFIED, android.bluetooth.BluetoothSocketException#L2CAP_UNKNOWN, android.bluetooth.BluetoothSocketException#L2CAP_ACL_FAILURE, android.bluetooth.BluetoothSocketException#L2CAP_CLIENT_SECURITY_FAILURE, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHENTICATION, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHORIZATION, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPTION, android.bluetooth.BluetoothSocketException#L2CAP_INVALID_SOURCE_CID, android.bluetooth.BluetoothSocketException#L2CAP_SOURCE_CID_ALREADY_ALLOCATED, android.bluetooth.BluetoothSocketException#L2CAP_UNACCEPTABLE_PARAMETERS, android.bluetooth.BluetoothSocketException#L2CAP_INVALID_PARAMETERS, android.bluetooth.BluetoothSocketException#L2CAP_NO_RESOURCES, android.bluetooth.BluetoothSocketException#L2CAP_NO_PSM_AVAILABLE, android.bluetooth.BluetoothSocketException#L2CAP_TIMEOUT, android.bluetooth.BluetoothSocketException#BLUETOOTH_OFF_FAILURE, android.bluetooth.BluetoothSocketException#SOCKET_MANAGER_FAILURE, android.bluetooth.BluetoothSocketException#SOCKET_CLOSED, android.bluetooth.BluetoothSocketException#SOCKET_CONNECTION_FAILURE, android.bluetooth.BluetoothSocketException#NULL_DEVICE, android.bluetooth.BluetoothSocketException#RPC_FAILURE, or android.bluetooth.BluetoothSocketException#UNIX_FILE_SOCKET_CREATION_FAILURE