Methods Summary |
---|
public boolean | authenticate(java.lang.String address)Authenticates remote device.
if (isAuthenticated(address)) {
return true;
}
if (!isPaired(address)) {
String pin = getPasskey(address);
if (pin == null || !bond(address, pin)) {
return false;
}
}
return BluetoothStack.getInstance().authenticateSync(address);
|
public native boolean | authorize(java.lang.String address, int handle)Authorizes a Bluetooth connection.
|
public native boolean | bond(java.lang.String address, java.lang.String pin)Initiates pairing with a remote device.
|
public native boolean | confirmEnable()Asks user whether Bluetooth radio is allowed to be turned on.
|
public boolean | enableBluetooth()Enables Bluetooth radio and the Bluetooth protocol stack for use.
if (BluetoothStack.getInstance().isEnabled()) {
return true;
}
if (!confirmEnable()) {
return false;
}
return BluetoothStack.getInstance().enable();
|
public boolean | encrypt(java.lang.String address, boolean enable)Enables or disables encryption of data exchanges.
if (setEncryption(address, enable)) {
return BluetoothStack.getInstance().encryptSync(address, enable);
}
return false;
|
private native void | finalize()Releases native resources.
|
public int | getAccessCode()
return BluetoothStack.getInstance().getAccessCode();
|
public java.lang.String | getBluetoothAddress()Returns local Bluetooth address.
return BluetoothStack.getInstance().getLocalAddress();
|
public DeviceClass | getDeviceClass()
return new DeviceClass(BluetoothStack.getInstance().getDeviceClass());
|
public java.lang.String | getFriendlyName(java.lang.String address)Retrieves the user-friendly name for specified remote device.
return BluetoothStack.getInstance().askFriendlyNameSync(address);
|
public java.lang.String | getFriendlyName()Returns user-friendly name for the local device.
return BluetoothStack.getInstance().getLocalName();
|
public native java.lang.String | getPasskey(java.lang.String address)Retrieves PIN code to use for pairing with a remote device. If the
PIN code is not known, PIN entry dialog is displayed.
|
private native java.lang.String | getPreknown()Returns list of preknown devices in a packed string.
|
public java.util.Vector | getPreknownDevices()Returns list of preknown devices in a packed string.
return listDevices(getPreknown());
|
private native void | initialize()Allocates native resources.
|
public native boolean | isAuthenticated(java.lang.String address)Checks if a remote device was authenticated.
|
public boolean | isBluetoothEnabled()Queries the power state of the Bluetooth device.
return BluetoothStack.getInstance().isEnabled();
|
public native boolean | isConnectable()Determines if the local device is in connectable mode.
|
public native boolean | isConnected(java.lang.String address)Checks if there is a connection to the remote device.
|
public native boolean | isEncrypted(java.lang.String address)Checks if connections to a remote device are encrypted.
|
public native boolean | isPaired(java.lang.String address)Checks if the local device has a bond with a remote device.
|
public native boolean | isTrusted(java.lang.String address)Checks if a remote device is trusted (authorized for all services).
|
private java.util.Vector | listDevices(java.lang.String packed)Extracts Bluetooth addresses from a packed string.
In the packed string, each device entry is a Bluetooth device address
followed by ADDR_DELIMETER delimiter.
if (packed == null || packed.trim().length() == 0) {
return null;
}
Vector addrs = new Vector();
int index = 0;
while (index < packed.length()) {
int end = packed.indexOf(ADDR_DELIMETER, index);
if (end == -1) {
end = packed.length();
}
addrs.addElement(packed.substring(index, end));
index = end + 1;
}
return addrs;
|
public boolean | setAccessCode(int accessCode)
return BluetoothStack.getInstance().setAccessCode(accessCode);
|
public native boolean | setEncryption(java.lang.String address, boolean enable)Increases or decreases encryption request counter for a remote device.
|
public boolean | setServiceClasses(int classes)
return BluetoothStack.getInstance().setServiceClasses(classes);
|