Bluez implementation in android

2020-07-30 03:29发布

问题:

Can anyone please provide us any source code for bluez implementation in android. Actually we are trying to make an application with GATT profile. This android application should connect with other device by Bluetooth connection. Please suggest me what should be the best way to send data to a non android device.

回答1:

Look at Bluetooth chat example by Google, you also can use the same method to connect to a non android device. Specifically you will need this api

device.createRfcommSocketToServiceRecord(SerialPortServiceClass_UUID);

EDIT: You can also try using reflection to access another method like this

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