Last active
December 18, 2015 13:09
-
-
Save janosgyerik/5787576 to your computer and use it in GitHub Desktop.
Connect to a Bluetooth device from Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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