Methods Summary |
---|
public boolean | cancelBondProcess(java.lang.String address)Cancel an in-progress bonding request started with createBond.
try {
return mService.cancelBondProcess(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public void | cancelDiscovery()
try {
mService.cancelDiscovery();
} catch (RemoteException e) {Log.e(TAG, "", e);}
|
public boolean | cancelPin(java.lang.String address)
try {
return mService.cancelPin(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public static boolean | checkBluetoothAddress(java.lang.String address)Sanity check a bluetooth address, such as "00:43:A8:23:10:F0"
if (address == null || address.length() != ADDRESS_LENGTH) {
return false;
}
for (int i = 0; i < ADDRESS_LENGTH; i++) {
char c = address.charAt(i);
switch (i % 3) {
case 0:
case 1:
if (Character.digit(c, 16) != -1) {
break; // hex character, OK
}
return false;
case 2:
if (c == ':") {
break; // OK
}
return false;
}
}
return true;
|
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.
if (pin == null) {
return null;
}
byte[] pinBytes;
try {
pinBytes = pin.getBytes("UTF8");
} catch (UnsupportedEncodingException uee) {
Log.e(TAG, "UTF8 not supported?!?"); // this should not happen
return null;
}
if (pinBytes.length <= 0 || pinBytes.length > 16) {
return null;
}
return pinBytes;
|
public boolean | createBond(java.lang.String address)Create a bonding with a remote bluetooth device.
This is an asynchronous call. The result of this bonding attempt can be
observed through BluetoothIntent.BOND_STATE_CHANGED_ACTION intents.
try {
return mService.createBond(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public boolean | disable()Disable the Bluetooth device.
This turns off the underlying hardware.
try {
return mService.disable(true);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public boolean | disconnectRemoteDeviceAcl(java.lang.String address)Perform a low level (ACL) disconnection of a remote device.
This forcably disconnects the ACL layer connection to a remote device,
which will cause all RFCOMM, SDP and L2CAP connections to this remote
device to close.
try {
return mService.disconnectRemoteDeviceAcl(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public boolean | enable()Enable the Bluetooth device.
Turn on the underlying hardware.
This is an asynchronous call,
BluetoothIntent.BLUETOOTH_STATE_CHANGED_ACTION can be used to check if
and when the device is sucessfully enabled.
try {
return mService.enable();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public java.lang.String | getAddress()
try {
return mService.getAddress();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public int | getBluetoothState()Get the current state of Bluetooth.
try {
return mService.getBluetoothState();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return BluetoothError.ERROR;
|
public int | getBondState(java.lang.String address)Get the bonding state of a remote device.
Result is one of:
BluetoothError.*
BOND_*
try {
return mService.getBondState(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return BluetoothError.ERROR_IPC;
|
public java.lang.String | getCompany()
try {
return mService.getCompany();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public int | getDiscoverableTimeout()
try {
return mService.getDiscoverableTimeout();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return -1;
|
public java.lang.String | getManufacturer()
try {
return mService.getManufacturer();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public java.lang.String | getName()Get the friendly Bluetooth name of this device.
This name is visible to remote Bluetooth devices. Currently it is only
possible to retrieve the Bluetooth name when Bluetooth is enabled.
try {
return mService.getName();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public int | getRemoteClass(java.lang.String address)Get the major, minor and servics classes of a remote device.
These classes are encoded as a 32-bit integer. See BluetoothClass.
try {
return mService.getRemoteClass(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return BluetoothClass.ERROR;
|
public java.lang.String | getRemoteCompany(java.lang.String address)
try {
return mService.getRemoteCompany(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public byte[] | getRemoteFeatures(java.lang.String address)
try {
return mService.getRemoteFeatures(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public java.lang.String | getRemoteManufacturer(java.lang.String address)
try {
return mService.getRemoteManufacturer(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public java.lang.String | getRemoteName(java.lang.String address)
try {
return mService.getRemoteName(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public java.lang.String | getRemoteRevision(java.lang.String address)
try {
return mService.getRemoteRevision(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public boolean | getRemoteServiceChannel(java.lang.String address, short uuid16, IBluetoothDeviceCallback callback)Returns the RFCOMM channel associated with the 16-byte UUID on
the remote Bluetooth address.
Performs a SDP ServiceSearchAttributeRequest transaction. The provided
uuid is verified in the returned record. If there was a problem, or the
specified uuid does not exist, -1 is returned.
try {
return mService.getRemoteServiceChannel(address, uuid16, callback);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public java.lang.String | getRemoteVersion(java.lang.String address)
try {
return mService.getRemoteVersion(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public java.lang.String | getRevision()
try {
return mService.getRevision();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public int | getScanMode()Get the current scan mode.
Used to determine if the local device is connectable and/or discoverable
try {
return mService.getScanMode();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return BluetoothError.ERROR_IPC;
|
public java.lang.String | getVersion()
try {
return mService.getVersion();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public boolean | isAclConnected(java.lang.String address)Check if a specified remote device has a low level (ACL) connection.
RFCOMM, SDP and L2CAP are all built on ACL connections. Devices can have
an ACL connection even when not paired - this is common for SDP queries
or for in-progress pairing requests.
In most cases you probably want to test if a higher level protocol is
connected, rather than testing ACL connections.
try {
return mService.isAclConnected(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public boolean | isDiscovering()
try {
return mService.isDiscovering();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public boolean | isEnabled()Is Bluetooth currently turned on.
try {
return mService.isEnabled();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public boolean | isPeriodicDiscovery()
try {
return mService.isPeriodicDiscovery();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public java.lang.String | lastSeen(java.lang.String address)
try {
return mService.lastSeen(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public java.lang.String | lastUsed(java.lang.String address)
try {
return mService.lastUsed(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public java.lang.String[] | listAclConnections()List remote devices that have a low level (ACL) connection.
RFCOMM, SDP and L2CAP are all built on ACL connections. Devices can have
an ACL connection even when not paired - this is common for SDP queries
or for in-progress pairing requests.
In most cases you probably want to test if a higher level protocol is
connected, rather than testing ACL connections.
try {
return mService.listAclConnections();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public java.lang.String[] | listBonds()List remote devices that are bonded (paired) to the local device.
Bonding (pairing) is the process by which the user enters a pin code for
the device, which generates a shared link key, allowing for
authentication and encryption of future connections. In Android we
require bonding before RFCOMM or SCO connections can be made to a remote
device.
This function lists which remote devices we have a link key for. It does
not cause any RF transmission, and does not check if the remote device
still has it's link key with us. If the other side no longer has its
link key then the RFCOMM or SCO connection attempt will result in an
error.
This function does not check if the remote device is in range.
Remote devices that have an in-progress bonding attempt are not
returned.
try {
return mService.listBonds();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public java.lang.String[] | listRemoteDevices()
try {
return mService.listRemoteDevices();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
|
public boolean | removeBond(java.lang.String address)Remove an already exisiting bonding (delete the link key).
try {
return mService.removeBond(address);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public void | setDiscoverableTimeout(int timeout)
try {
mService.setDiscoverableTimeout(timeout);
} catch (RemoteException e) {Log.e(TAG, "", e);}
|
public boolean | setName(java.lang.String name)Set the friendly Bluetooth name of this device.
This name is visible to remote Bluetooth devices. The Bluetooth Service
is responsible for persisting this name.
try {
return mService.setName(name);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public boolean | setPin(java.lang.String address, byte[] pin)
try {
return mService.setPin(address, pin);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public void | setScanMode(int scanMode)Set the current scan mode.
Used to make the local device connectable and/or discoverable
try {
mService.setScanMode(scanMode);
} catch (RemoteException e) {Log.e(TAG, "", e);}
|
public boolean | startDiscovery()
return startDiscovery(true);
|
public boolean | startDiscovery(boolean resolveNames)
try {
return mService.startDiscovery(resolveNames);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public boolean | startPeriodicDiscovery()
try {
return mService.startPeriodicDiscovery();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|
public boolean | stopPeriodicDiscovery()
try {
return mService.stopPeriodicDiscovery();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
|