I am doing an Android App and where I have the MAC of another device as a string (17 characters long) and need to use that one in order to connect to that device (thread tha
If I understand correctly, you have a MAC address as a string, and you want to connect to the device, right? This should work:
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
BluetoothSocket tmp = null;
BluetoothSocket mmSocket = null;
// Get a BluetoothSocket for a connection with the
// given BluetoothDevice
try {
tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
tmp = (BluetoothSocket) m.invoke(device, 1);
} catch (IOException e) {
Log.e(TAG, "create() failed", e);
}
mmSocket = tmp;
This is an excerpt from the source code of this simple open-source Android App: https://github.com/janosgyerik/bluetoothviewer
The app is a simple tool for debugging Bluetooth connections and raw protocol data. (For now only in ascii, I plan to add features to debug hexadecimal as well.)