android.bluetooth
Class BluetoothDevice

java.lang.Object
  extended by android.bluetooth.BluetoothDevice
All Implemented Interfaces:
Parcelable

public final class BluetoothDevice
extends java.lang.Object
implements Parcelable

Represents a remote Bluetooth device.

Use BluetoothAdapter.getRemoteDevice(java.lang.String) to create a BluetoothDevice.

This class is really just a thin wrapper for a Bluetooth hardware address. Objects of this class are immutable. Operations on this class are performed on the remote Bluetooth hardware address, using the BluetoothAdapter that was used to create this BluetoothDevice.


Nested Class Summary
 
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.Creator<T>
 
Field Summary
static java.lang.String ACTION_ACL_CONNECTED
          Broadcast Action: Indicates a low level (ACL) connection has been established with a remote device.
static java.lang.String ACTION_ACL_DISCONNECT_REQUESTED
          Broadcast Action: Indicates that a low level (ACL) disconnection has been requested for a remote device, and it will soon be disconnected.
static java.lang.String ACTION_ACL_DISCONNECTED
          Broadcast Action: Indicates a low level (ACL) disconnection from a remote device.
static java.lang.String ACTION_BOND_STATE_CHANGED
          Broadcast Action: Indicates a change in the bond state of a remote device.
static java.lang.String ACTION_CLASS_CHANGED
          Broadcast Action: Bluetooth class of a remote device has changed.
static java.lang.String ACTION_DISAPPEARED
          Broadcast Action: Remote device disappeared.
static java.lang.String ACTION_FOUND
          Broadcast Action: Remote device discovered.
static java.lang.String ACTION_NAME_CHANGED
          Broadcast Action: Indicates the friendly name of a remote device has been retrieved for the first time, or changed since the last retrieval.
static java.lang.String ACTION_NAME_FAILED
          Broadcast Action: Indicates a failure to retrieve the name of a remote device.
static java.lang.String ACTION_PAIRING_CANCEL
           
static java.lang.String ACTION_PAIRING_REQUEST
           
static java.lang.String ACTION_UUID
          Broadcast Action: This intent is used to broadcast the UUID wrapped as a ParcelUuid of the remote device after it has been fetched.
static int BOND_BONDED
          Indicates the remote device is bonded (paired).
static int BOND_BONDING
          Indicates bonding (pairing) is in progress with the remote device.
static int BOND_NONE
          Indicates the remote device is not bonded (paired).
static int BOND_SUCCESS
          A bond attempt succeeded
static Parcelable.Creator<BluetoothDevice> CREATOR
           
static int ERROR
          Sentinel error value for this class.
static java.lang.String EXTRA_BOND_STATE
          Used as an int extra field in ACTION_BOND_STATE_CHANGED intents.
static java.lang.String EXTRA_CLASS
          Used as an Parcelable BluetoothClass extra field in ACTION_FOUND and ACTION_CLASS_CHANGED intents.
static java.lang.String EXTRA_DEVICE
          Used as a Parcelable BluetoothDevice extra field in every intent broadcast by this class.
static java.lang.String EXTRA_NAME
          Used as a String extra field in ACTION_NAME_CHANGED and ACTION_FOUND intents.
static java.lang.String EXTRA_PAIRING_VARIANT
           
static java.lang.String EXTRA_PASSKEY
           
static java.lang.String EXTRA_PREVIOUS_BOND_STATE
          Used as an int extra field in ACTION_BOND_STATE_CHANGED intents.
static java.lang.String EXTRA_REASON
           
static java.lang.String EXTRA_RSSI
          Used as an optional short extra field in ACTION_FOUND intents.
static java.lang.String EXTRA_UUID
          Used as an extra field in ACTION_UUID intents, Contains the ParcelUuids of the remote device which is a parcelable version of UUID.
static int PAIRING_VARIANT_CONSENT
          The user will be prompted to accept or deny the incoming pairing request
static int PAIRING_VARIANT_DISPLAY_PASSKEY
          The user will be prompted to enter the passkey displayed on remote device
static int PAIRING_VARIANT_PASSKEY
          The user will be prompted to enter a passkey
static int PAIRING_VARIANT_PASSKEY_CONFIRMATION
          The user will be prompted to confirm the passkey displayed on the screen
static int PAIRING_VARIANT_PIN
          The user will be prompted to enter a pin
static int UNBOND_REASON_AUTH_CANCELED
          A bond attempt failed because we canceled the bonding process
static int UNBOND_REASON_AUTH_FAILED
          A bond attempt failed because pins did not match, or remote device did not respond to pin request in time
static int UNBOND_REASON_AUTH_REJECTED
          A bond attempt failed because the other side explicilty rejected bonding
static int UNBOND_REASON_AUTH_TIMEOUT
          A bond attempt failed because of authentication timeout
static int UNBOND_REASON_DISCOVERY_IN_PROGRESS
          A bond attempt failed because a discovery is in progress
static int UNBOND_REASON_REMOTE_AUTH_CANCELED
          A bond attempt failed because we received an Authentication Cancel by remote end
static int UNBOND_REASON_REMOTE_DEVICE_DOWN
          A bond attempt failed because we could not contact the remote device
static int UNBOND_REASON_REMOVED
          An existing bond was explicitly revoked
static int UNBOND_REASON_REPEATED_ATTEMPTS
          A bond attempt failed because of repeated attempts
 
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
 
Method Summary
 boolean cancelBondProcess()
          Cancel an in-progress bonding request started with createBond().
 boolean cancelPairingUserInput()
           
static byte[] convertPinToBytes(java.lang.String pin)
          Check that a pin is valid and convert to byte array.
 boolean createBond()
          Start the bonding (pairing) process with the remote device.
 BluetoothSocket createInsecureRfcommSocket(int port)
          Construct an insecure RFCOMM socket ready to start an outgoing connection.
 BluetoothSocket createRfcommSocket(int channel)
          Create an RFCOMM BluetoothSocket ready to start a secure outgoing connection to this remote device on given channel.
 BluetoothSocket createRfcommSocketToServiceRecord(java.util.UUID uuid)
          Create an RFCOMM BluetoothSocket ready to start a secure outgoing connection to this remote device using SDP lookup of uuid.
 BluetoothSocket createScoSocket()
          Construct a SCO socket ready to start an outgoing connection.
 int describeContents()
          Describe the kinds of special objects contained in this Parcelable's marshalled representation.
 boolean equals(java.lang.Object o)
           
 boolean fetchUuidsWithSdp()
          Perform a SDP query on the remote device to get the UUIDs supported.
 java.lang.String getAddress()
          Returns the hardware address of this BluetoothDevice.
 BluetoothClass getBluetoothClass()
          Get the Bluetooth class of the remote device.
 int getBondState()
          Get the bond state of the remote device.
 java.lang.String getName()
          Get the friendly Bluetooth name of the remote device.
 int getServiceChannel(ParcelUuid uuid)
           
 boolean getTrustState()
          Get trust state of a remote device.
 ParcelUuid[] getUuids()
           
 int hashCode()
           
 boolean removeBond()
          Remove bond (pairing) with the remote device.
 boolean setPairingConfirmation(boolean confirm)
           
 boolean setPasskey(int passkey)
           
 boolean setPin(byte[] pin)
           
 boolean setTrust(boolean value)
          Set trust state for a remote device.
 java.lang.String toString()
          Returns a string representation of this BluetoothDevice.
 void writeToParcel(Parcel out, int flags)
          Flatten this object in to a Parcel.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ERROR

public static final int ERROR
Sentinel error value for this class. Guaranteed to not equal any other integer constant in this class. Provided as a convenience for functions that require a sentinel error value, for example:

Intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.ERROR)

See Also:
Constant Field Values

ACTION_FOUND

public static final java.lang.String ACTION_FOUND
Broadcast Action: Remote device discovered.

Sent when a remote device is found during discovery.

Always contains the extra fields EXTRA_DEVICE and EXTRA_CLASS. Can contain the extra fields EXTRA_NAME and/or EXTRA_RSSI if they are available.

Requires android.Manifest.permission#BLUETOOTH to receive.

See Also:
Constant Field Values

ACTION_DISAPPEARED

public static final java.lang.String ACTION_DISAPPEARED
Broadcast Action: Remote device disappeared.

Sent when a remote device that was found in the last discovery is not found in the current discovery.

Always contains the extra field EXTRA_DEVICE.

Requires android.Manifest.permission#BLUETOOTH to receive.

See Also:
Constant Field Values

ACTION_CLASS_CHANGED

public static final java.lang.String ACTION_CLASS_CHANGED
Broadcast Action: Bluetooth class of a remote device has changed.

Always contains the extra fields EXTRA_DEVICE and EXTRA_CLASS.

Requires android.Manifest.permission#BLUETOOTH to receive.

See Also:
BluetoothClass}, Constant Field Values

ACTION_ACL_CONNECTED

public static final java.lang.String ACTION_ACL_CONNECTED
Broadcast Action: Indicates a low level (ACL) connection has been established with a remote device.

Always contains the extra field EXTRA_DEVICE.

ACL connections are managed automatically by the Android Bluetooth stack.

Requires android.Manifest.permission#BLUETOOTH to receive.

See Also:
Constant Field Values

ACTION_ACL_DISCONNECT_REQUESTED

public static final java.lang.String ACTION_ACL_DISCONNECT_REQUESTED
Broadcast Action: Indicates that a low level (ACL) disconnection has been requested for a remote device, and it will soon be disconnected.

This is useful for graceful disconnection. Applications should use this intent as a hint to immediately terminate higher level connections (RFCOMM, L2CAP, or profile connections) to the remote device.

Always contains the extra field EXTRA_DEVICE.

Requires android.Manifest.permission#BLUETOOTH to receive.

See Also:
Constant Field Values

ACTION_ACL_DISCONNECTED

public static final java.lang.String ACTION_ACL_DISCONNECTED
Broadcast Action: Indicates a low level (ACL) disconnection from a remote device.

Always contains the extra field EXTRA_DEVICE.

ACL connections are managed automatically by the Android Bluetooth stack.

Requires android.Manifest.permission#BLUETOOTH to receive.

See Also:
Constant Field Values

ACTION_NAME_CHANGED

public static final java.lang.String ACTION_NAME_CHANGED
Broadcast Action: Indicates the friendly name of a remote device has been retrieved for the first time, or changed since the last retrieval.

Always contains the extra fields EXTRA_DEVICE and EXTRA_NAME.

Requires android.Manifest.permission#BLUETOOTH to receive.

See Also:
Constant Field Values

ACTION_BOND_STATE_CHANGED

public static final java.lang.String ACTION_BOND_STATE_CHANGED
Broadcast Action: Indicates a change in the bond state of a remote device. For example, if a device is bonded (paired).

Always contains the extra fields EXTRA_DEVICE, EXTRA_BOND_STATE and EXTRA_PREVIOUS_BOND_STATE.

Requires android.Manifest.permission#BLUETOOTH to receive.

See Also:
Constant Field Values

EXTRA_DEVICE

public static final java.lang.String EXTRA_DEVICE
Used as a Parcelable BluetoothDevice extra field in every intent broadcast by this class. It contains the BluetoothDevice that the intent applies to.

See Also:
Constant Field Values

EXTRA_NAME

public static final java.lang.String EXTRA_NAME
Used as a String extra field in ACTION_NAME_CHANGED and ACTION_FOUND intents. It contains the friendly Bluetooth name.

See Also:
Constant Field Values

EXTRA_RSSI

public static final java.lang.String EXTRA_RSSI
Used as an optional short extra field in ACTION_FOUND intents. Contains the RSSI value of the remote device as reported by the Bluetooth hardware.

See Also:
Constant Field Values

EXTRA_CLASS

public static final java.lang.String EXTRA_CLASS
Used as an Parcelable BluetoothClass extra field in ACTION_FOUND and ACTION_CLASS_CHANGED intents.

See Also:
Constant Field Values

EXTRA_BOND_STATE

public static final java.lang.String EXTRA_BOND_STATE
Used as an int extra field in ACTION_BOND_STATE_CHANGED intents. Contains the bond state of the remote device.

Possible values are: BOND_NONE, BOND_BONDING, BOND_BONDED.

See Also:
Constant Field Values

EXTRA_PREVIOUS_BOND_STATE

public static final java.lang.String EXTRA_PREVIOUS_BOND_STATE
Used as an int extra field in ACTION_BOND_STATE_CHANGED intents. Contains the previous bond state of the remote device.

Possible values are: BOND_NONE, BOND_BONDING, BOND_BONDED.

See Also:
Constant Field Values

BOND_NONE

public static final int BOND_NONE
Indicates the remote device is not bonded (paired).

There is no shared link key with the remote device, so communication (if it is allowed at all) will be unauthenticated and unencrypted.

See Also:
Constant Field Values

BOND_BONDING

public static final int BOND_BONDING
Indicates bonding (pairing) is in progress with the remote device.

See Also:
Constant Field Values

BOND_BONDED

public static final int BOND_BONDED
Indicates the remote device is bonded (paired).

A shared link keys exists locally for the remote device, so communication can be authenticated and encrypted.

Being bonded (paired) with a remote device does not necessarily mean the device is currently connected. It just means that the ponding procedure was compeleted at some earlier time, and the link key is still stored locally, ready to use on the next connection.

See Also:
Constant Field Values

EXTRA_REASON

public static final java.lang.String EXTRA_REASON
See Also:
Constant Field Values

EXTRA_PAIRING_VARIANT

public static final java.lang.String EXTRA_PAIRING_VARIANT
See Also:
Constant Field Values

EXTRA_PASSKEY

public static final java.lang.String EXTRA_PASSKEY
See Also:
Constant Field Values

ACTION_UUID

public static final java.lang.String ACTION_UUID
Broadcast Action: This intent is used to broadcast the UUID wrapped as a ParcelUuid of the remote device after it has been fetched. This intent is sent only when the UUIDs of the remote device are requested to be fetched using Service Discovery Protocol

Always contains the extra field EXTRA_DEVICE

Always contains the extra filed EXTRA_UUID

Requires android.Manifest.permission#BLUETOOTH to receive.

See Also:
Constant Field Values

ACTION_NAME_FAILED

public static final java.lang.String ACTION_NAME_FAILED
Broadcast Action: Indicates a failure to retrieve the name of a remote device.

Always contains the extra field EXTRA_DEVICE.

Requires android.Manifest.permission#BLUETOOTH to receive.

See Also:
Constant Field Values

ACTION_PAIRING_REQUEST

public static final java.lang.String ACTION_PAIRING_REQUEST
See Also:
Constant Field Values

ACTION_PAIRING_CANCEL

public static final java.lang.String ACTION_PAIRING_CANCEL
See Also:
Constant Field Values

BOND_SUCCESS

public static final int BOND_SUCCESS
A bond attempt succeeded

See Also:
Constant Field Values

UNBOND_REASON_AUTH_FAILED

public static final int UNBOND_REASON_AUTH_FAILED
A bond attempt failed because pins did not match, or remote device did not respond to pin request in time

See Also:
Constant Field Values

UNBOND_REASON_AUTH_REJECTED

public static final int UNBOND_REASON_AUTH_REJECTED
A bond attempt failed because the other side explicilty rejected bonding

See Also:
Constant Field Values

UNBOND_REASON_AUTH_CANCELED

public static final int UNBOND_REASON_AUTH_CANCELED
A bond attempt failed because we canceled the bonding process

See Also:
Constant Field Values

UNBOND_REASON_REMOTE_DEVICE_DOWN

public static final int UNBOND_REASON_REMOTE_DEVICE_DOWN
A bond attempt failed because we could not contact the remote device

See Also:
Constant Field Values

UNBOND_REASON_DISCOVERY_IN_PROGRESS

public static final int UNBOND_REASON_DISCOVERY_IN_PROGRESS
A bond attempt failed because a discovery is in progress

See Also:
Constant Field Values

UNBOND_REASON_AUTH_TIMEOUT

public static final int UNBOND_REASON_AUTH_TIMEOUT
A bond attempt failed because of authentication timeout

See Also:
Constant Field Values

UNBOND_REASON_REPEATED_ATTEMPTS

public static final int UNBOND_REASON_REPEATED_ATTEMPTS
A bond attempt failed because of repeated attempts

See Also:
Constant Field Values

UNBOND_REASON_REMOTE_AUTH_CANCELED

public static final int UNBOND_REASON_REMOTE_AUTH_CANCELED
A bond attempt failed because we received an Authentication Cancel by remote end

See Also:
Constant Field Values

UNBOND_REASON_REMOVED

public static final int UNBOND_REASON_REMOVED
An existing bond was explicitly revoked

See Also:
Constant Field Values

PAIRING_VARIANT_PIN

public static final int PAIRING_VARIANT_PIN
The user will be prompted to enter a pin

See Also:
Constant Field Values

PAIRING_VARIANT_PASSKEY

public static final int PAIRING_VARIANT_PASSKEY
The user will be prompted to enter a passkey

See Also:
Constant Field Values

PAIRING_VARIANT_PASSKEY_CONFIRMATION

public static final int PAIRING_VARIANT_PASSKEY_CONFIRMATION
The user will be prompted to confirm the passkey displayed on the screen

See Also:
Constant Field Values

PAIRING_VARIANT_CONSENT

public static final int PAIRING_VARIANT_CONSENT
The user will be prompted to accept or deny the incoming pairing request

See Also:
Constant Field Values

PAIRING_VARIANT_DISPLAY_PASSKEY

public static final int PAIRING_VARIANT_DISPLAY_PASSKEY
The user will be prompted to enter the passkey displayed on remote device

See Also:
Constant Field Values

EXTRA_UUID

public static final java.lang.String EXTRA_UUID
Used as an extra field in ACTION_UUID intents, Contains the ParcelUuids of the remote device which is a parcelable version of UUID.

See Also:
Constant Field Values

CREATOR

public static final Parcelable.Creator<BluetoothDevice> CREATOR
Method Detail

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation of this BluetoothDevice.

Currently this is the Bluetooth hardware address, for example "00:11:22:AA:BB:CC". However, you should always use getAddress() if you explicitly require the Bluetooth hardware address in case the toString() representation changes in the future.

Overrides:
toString in class java.lang.Object
Returns:
string representation of this BluetoothDevice

describeContents

public int describeContents()
Description copied from interface: Parcelable
Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Specified by:
describeContents in interface Parcelable
Returns:
a bitmask indicating the set of special object types marshalled by the Parcelable.

writeToParcel

public void writeToParcel(Parcel out,
                          int flags)
Description copied from interface: Parcelable
Flatten this object in to a Parcel.

Specified by:
writeToParcel in interface Parcelable
Parameters:
out - The Parcel in which the object should be written.
flags - Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.

getAddress

public java.lang.String getAddress()
Returns the hardware address of this BluetoothDevice.

For example, "00:11:22:AA:BB:CC".

Returns:
Bluetooth hardware address as string

getName

public java.lang.String getName()
Get the friendly Bluetooth name of the remote device.

The local adapter will automatically retrieve remote names when performing a device scan, and will cache them. This method just returns the name for this device from the cache.

Requires android.Manifest.permission#BLUETOOTH

Returns:
the Bluetooth name, or null if there was a problem.

createBond

public boolean createBond()
Start the bonding (pairing) process with the remote device.

This is an asynchronous call, it will return immediately. Register for ACTION_BOND_STATE_CHANGED intents to be notified when the bonding process completes, and its result.

Android system services will handle the necessary user interactions to confirm and complete the bonding process.

Requires android.Manifest.permission#BLUETOOTH_ADMIN.

Returns:
false on immediate error, true if bonding will begin

cancelBondProcess

public boolean cancelBondProcess()
Cancel an in-progress bonding request started with createBond().

Requires android.Manifest.permission#BLUETOOTH_ADMIN.

Returns:
true on sucess, false on error

removeBond

public boolean removeBond()
Remove bond (pairing) with the remote device.

Delete the link key associated with the remote device, and immediately terminate connections to that device that require authentication and encryption.

Requires android.Manifest.permission#BLUETOOTH_ADMIN.

Returns:
true on sucess, false on error

getBondState

public int getBondState()
Get the bond state of the remote device.

Possible values for the bond state are: BOND_NONE, BOND_BONDING, BOND_BONDED.

Requires android.Manifest.permission#BLUETOOTH.

Returns:
the bond state

getBluetoothClass

public BluetoothClass getBluetoothClass()
Get the Bluetooth class of the remote device.

Requires android.Manifest.permission#BLUETOOTH.

Returns:
Bluetooth class object, or null on error

getTrustState

public boolean getTrustState()
Get trust state of a remote device.

Requires android.Manifest.permission#BLUETOOTH.


setTrust

public boolean setTrust(boolean value)
Set trust state for a remote device.

Requires android.Manifest.permission#BLUETOOTH_ADMIN.

Parameters:
value - the trust state value (true or false)

getUuids

public ParcelUuid[] getUuids()

fetchUuidsWithSdp

public boolean fetchUuidsWithSdp()
Perform a SDP query on the remote device to get the UUIDs supported. This API is asynchronous and an Intent is sent, with the UUIDs supported by the remote end. If there is an error in getting the SDP records or if the process takes a long time, an Intent is sent with the UUIDs that is currently present in the cache. Clients should use the getUuids to get UUIDs is SDP is not to be performed.

Returns:
False if the sanity check fails, True if the process of initiating an ACL connection to the remote device was started.

getServiceChannel

public int getServiceChannel(ParcelUuid uuid)

setPin

public boolean setPin(byte[] pin)

setPasskey

public boolean setPasskey(int passkey)

setPairingConfirmation

public boolean setPairingConfirmation(boolean confirm)

cancelPairingUserInput

public boolean cancelPairingUserInput()

createRfcommSocket

public BluetoothSocket createRfcommSocket(int channel)
                                   throws java.io.IOException
Create an RFCOMM BluetoothSocket ready to start a secure outgoing connection to this remote device on given channel.

The remote device will be authenticated and communication on this socket will be encrypted.

Use BluetoothSocket.connect() to intiate the outgoing connection.

Valid RFCOMM channels are in range 1 to 30.

Requires android.Manifest.permission#BLUETOOTH

Parameters:
channel - RFCOMM channel to connect to
Returns:
a RFCOMM BluetoothServerSocket ready for an outgoing connection
Throws:
java.io.IOException - on error, for example Bluetooth not available, or insufficient permissions

createRfcommSocketToServiceRecord

public BluetoothSocket createRfcommSocketToServiceRecord(java.util.UUID uuid)
                                                  throws java.io.IOException
Create an RFCOMM BluetoothSocket ready to start a secure outgoing connection to this remote device using SDP lookup of uuid.

This is designed to be used with BluetoothAdapter.listenUsingRfcommWithServiceRecord(java.lang.String, java.util.UUID) for peer-peer Bluetooth applications.

Use BluetoothSocket.connect() to intiate the outgoing connection. This will also perform an SDP lookup of the given uuid to determine which channel to connect to.

The remote device will be authenticated and communication on this socket will be encrypted.

Requires android.Manifest.permission#BLUETOOTH

Parameters:
uuid - service record uuid to lookup RFCOMM channel
Returns:
a RFCOMM BluetoothServerSocket ready for an outgoing connection
Throws:
java.io.IOException - on error, for example Bluetooth not available, or insufficient permissions

createInsecureRfcommSocket

public BluetoothSocket createInsecureRfcommSocket(int port)
                                           throws java.io.IOException
Construct an insecure RFCOMM socket ready to start an outgoing connection. Call #connect on the returned #BluetoothSocket to begin the connection. The remote device will not be authenticated and communication on this socket will not be encrypted.

Requires android.Manifest.permission#BLUETOOTH_ADMIN

Parameters:
port - remote port
Returns:
An RFCOMM BluetoothSocket
Throws:
java.io.IOException - On error, for example Bluetooth not available, or insufficient permissions.

createScoSocket

public BluetoothSocket createScoSocket()
                                throws java.io.IOException
Construct a SCO socket ready to start an outgoing connection. Call #connect on the returned #BluetoothSocket to begin the connection.

Requires android.Manifest.permission#BLUETOOTH_ADMIN

Returns:
a SCO BluetoothSocket
Throws:
java.io.IOException - on error, for example Bluetooth not available, or insufficient permissions.

convertPinToBytes

public static byte[] convertPinToBytes(java.lang.String pin)
Check that a pin is valid and convert to byte array. Bluetooth pin's are 1 to 16 bytes of UTF8 characters.

Parameters:
pin - pin as java String
Returns:
the pin code as a UTF8 byte array, or null if it is an invalid Bluetooth pin.