Skip to content

Instantly share code, notes, and snippets.

@janosgyerik
Last active December 18, 2015 13:09
Show Gist options
  • Save janosgyerik/5787576 to your computer and use it in GitHub Desktop.
Save janosgyerik/5787576 to your computer and use it in GitHub Desktop.
Connect to a Bluetooth device from Android
// connect to a Bluetooth device from Android
Socket socket = null;
try {
device.createRfcommSocketToServiceRecord(MY_UUID);
Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
socket = (BluetoothSocket) m.invoke(device, 1);
} catch (IOException e) {
Log.e(TAG, "create() failed", e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment