Friday, November 5, 2010

Make Android connection

Update: Actually, both of the following code would work on my S7 and Ally. The headset I tried has only one profile implemented. That's the reason it can not be found by S7.

mmSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
mmSocket.connect();

The following code is suggested.


private static String address = "00:19:7F:1F:20:DF";
private BluetoothSocket btSocket = null;

mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);

Method m = null;
m = device.getClass().getMethod("createRfcommSocket", new Class[]{int.class});
btSocket = (BluetoothSocket)m.invoke(device, Integer.valueOf(1));
btSocket.connect();

No comments:

Post a Comment