BluetoothSocketException


public class BluetoothSocketException
extends IOException

java.lang.Object
   ↳ java.lang.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 BluetoothSocket.connect() operation.

Summary

Constants

int BLUETOOTH_OFF_FAILURE

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

int L2CAP_ACL_FAILURE

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

int L2CAP_CLIENT_SECURITY_FAILURE

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

int L2CAP_INSUFFICIENT_AUTHENTICATION

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

int L2CAP_INSUFFICIENT_AUTHORIZATION

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

int L2CAP_INSUFFICIENT_ENCRYPTION

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

int L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE

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

int L2CAP_INVALID_PARAMETERS

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

int L2CAP_INVALID_SOURCE_CID

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

int L2CAP_NO_PSM_AVAILABLE

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

int L2CAP_NO_RESOURCES

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

int L2CAP_SOURCE_CID_ALREADY_ALLOCATED

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

int L2CAP_TIMEOUT

Error code during connect when L2CAP connection timeout.

int L2CAP_UNACCEPTABLE_PARAMETERS

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

int L2CAP_UNKNOWN

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

int NULL_DEVICE

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

int RPC_FAILURE

Error code during connect when a Runtime RPC exception occurs.

int SOCKET_CLOSED

Error code during connect when socket is closed.

int SOCKET_CONNECTION_FAILURE

Error code during connect for generic socket connection failures.

int SOCKET_MANAGER_FAILURE

Error code during connect when socket manager is not available.

int UNIX_FILE_SOCKET_CREATION_FAILURE

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

int UNSPECIFIED

Error code representing a failure during BluetoothSocket.

Public constructors

BluetoothSocketException(int code, String msg)

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

BluetoothSocketException(int code)

Create a BluetoothSocketException with an error code.

Public methods

int getErrorCode()

Returns the error code associated to this failure.

Inherited methods

Constants

BLUETOOTH_OFF_FAILURE

Added in API level 34
public static final int BLUETOOTH_OFF_FAILURE

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

Constant Value: 15 (0x0000000f)

L2CAP_ACL_FAILURE

Added in API level 34
public static final int L2CAP_ACL_FAILURE

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

Constant Value: 2 (0x00000002)

L2CAP_CLIENT_SECURITY_FAILURE

Added in API level 34
public static final int L2CAP_CLIENT_SECURITY_FAILURE

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

Constant Value: 3 (0x00000003)

L2CAP_INSUFFICIENT_AUTHENTICATION

Added in API level 34
public static final int L2CAP_INSUFFICIENT_AUTHENTICATION

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

Constant Value: 4 (0x00000004)

L2CAP_INSUFFICIENT_AUTHORIZATION

Added in API level 34
public static final int L2CAP_INSUFFICIENT_AUTHORIZATION

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

Constant Value: 5 (0x00000005)

L2CAP_INSUFFICIENT_ENCRYPTION

Added in API level 34
public static final int L2CAP_INSUFFICIENT_ENCRYPTION

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

Constant Value: 7 (0x00000007)

L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE

Added in API level 34
public static final int L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE

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

Constant Value: 6 (0x00000006)

L2CAP_INVALID_PARAMETERS

Added in API level 34
public static final int L2CAP_INVALID_PARAMETERS

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

Constant Value: 11 (0x0000000b)

L2CAP_INVALID_SOURCE_CID

Added in API level 34
public static final int L2CAP_INVALID_SOURCE_CID

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

Constant Value: 8 (0x00000008)

L2CAP_NO_PSM_AVAILABLE

Added in API level 34
public static final int L2CAP_NO_PSM_AVAILABLE

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

Constant Value: 13 (0x0000000d)

L2CAP_NO_RESOURCES

Added in API level 34
public static final int L2CAP_NO_RESOURCES

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

Constant Value: 12 (0x0000000c)

L2CAP_SOURCE_CID_ALREADY_ALLOCATED

Added in API level 34
public static final int L2CAP_SOURCE_CID_ALREADY_ALLOCATED

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

Constant Value: 9 (0x00000009)

L2CAP_TIMEOUT

Added in API level 34
public static final int L2CAP_TIMEOUT

Error code during connect when L2CAP connection timeout.

Constant Value: 14 (0x0000000e)

L2CAP_UNACCEPTABLE_PARAMETERS

Added in API level 34
public static final int L2CAP_UNACCEPTABLE_PARAMETERS

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

Constant Value: 10 (0x0000000a)

L2CAP_UNKNOWN

Added in API level 34
public static final int L2CAP_UNKNOWN

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

Constant Value: 1 (0x00000001)

NULL_DEVICE

Added in API level 34
public static final int NULL_DEVICE

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

Constant Value: 19 (0x00000013)

RPC_FAILURE

Added in API level 34
public static final int RPC_FAILURE

Error code during connect when a Runtime RPC exception occurs.

Constant Value: 20 (0x00000014)

SOCKET_CLOSED

Added in API level 34
public static final int SOCKET_CLOSED

Error code during connect when socket is closed.

Constant Value: 17 (0x00000011)

SOCKET_CONNECTION_FAILURE

Added in API level 34
public static final int SOCKET_CONNECTION_FAILURE

Error code during connect for generic socket connection failures.

Constant Value: 18 (0x00000012)

SOCKET_MANAGER_FAILURE

Added in API level 34
public static final int SOCKET_MANAGER_FAILURE

Error code during connect when socket manager is not available.

Constant Value: 16 (0x00000010)

UNIX_FILE_SOCKET_CREATION_FAILURE

Added in API level 35
public static final int UNIX_FILE_SOCKET_CREATION_FAILURE

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

Constant Value: 21 (0x00000015)

UNSPECIFIED

Added in API level 34
public static final int UNSPECIFIED

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

Constant Value: 0 (0x00000000)

Public constructors

BluetoothSocketException

Added in API level 34
public BluetoothSocketException (int code, 
                String msg)

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

Parameters
code int: : error code representing the reason for failure. Value is UNSPECIFIED, L2CAP_UNKNOWN, L2CAP_ACL_FAILURE, L2CAP_CLIENT_SECURITY_FAILURE, L2CAP_INSUFFICIENT_AUTHENTICATION, L2CAP_INSUFFICIENT_AUTHORIZATION, L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE, L2CAP_INSUFFICIENT_ENCRYPTION, L2CAP_INVALID_SOURCE_CID, L2CAP_SOURCE_CID_ALREADY_ALLOCATED, L2CAP_UNACCEPTABLE_PARAMETERS, L2CAP_INVALID_PARAMETERS, L2CAP_NO_RESOURCES, L2CAP_NO_PSM_AVAILABLE, L2CAP_TIMEOUT, BLUETOOTH_OFF_FAILURE, SOCKET_MANAGER_FAILURE, SOCKET_CLOSED, SOCKET_CONNECTION_FAILURE, NULL_DEVICE, RPC_FAILURE, or 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
public BluetoothSocketException (int code)

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 UNSPECIFIED, L2CAP_UNKNOWN, L2CAP_ACL_FAILURE, L2CAP_CLIENT_SECURITY_FAILURE, L2CAP_INSUFFICIENT_AUTHENTICATION, L2CAP_INSUFFICIENT_AUTHORIZATION, L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE, L2CAP_INSUFFICIENT_ENCRYPTION, L2CAP_INVALID_SOURCE_CID, L2CAP_SOURCE_CID_ALREADY_ALLOCATED, L2CAP_UNACCEPTABLE_PARAMETERS, L2CAP_INVALID_PARAMETERS, L2CAP_NO_RESOURCES, L2CAP_NO_PSM_AVAILABLE, L2CAP_TIMEOUT, BLUETOOTH_OFF_FAILURE, SOCKET_MANAGER_FAILURE, SOCKET_CLOSED, SOCKET_CONNECTION_FAILURE, NULL_DEVICE, RPC_FAILURE, or UNIX_FILE_SOCKET_CREATION_FAILURE

Public methods