I am trying to connect devices through my app installed in Nexus 5.I want to make an app like rainbow contacts in android. In my app I aim to connect to another device throu
Within the try
("//try the fallback") use this:
socket =(BluetoothSocket) device.getClass().getMethod("createRfcommSocket", new Class[] {int.class}).invoke(device,1);
socket.connect();
Another tip may be to use a different UUID, it may solve the problem.
I don't know if you tryed it yet, but similarly to what has been done in the bluetooth chat example, just before creating your ConnectThread, call this function:
public synchronized void connect(BluetoothDevice device) {
// Cancel any thread attempting to make a connection
if (mState == STATE_CONNECTING) {
if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}
}
// Cancel any thread currently running a connection
if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}
// Start the thread to connect with the given device
mConnectThread = new ConnectThread(device);
mConnectThread.start();
setState(STATE_CONNECTING);
}