This is odd. I am trying to configure Bluetooth SPP on a Droid X Android 2.3.4. I have included several different methods, trying to open rfcomm socket, one of which is a reflection (necessary to support certain phones).
However, a strange thing happens with the Droid X. When I first connect to a Bluetooth device, my application opens and first tries to run SPP:
Method m = mmDevice.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
mmSocket = (BluetoothSocket) m.invoke(mmDevice, Integer.valueOf(1));
And if he cannot find the method, he tries to execute normal
mmSocket = mmDevice.createRfcommSocketToServiceRecord(SerialPortServiceClass_UUID);
This works correctly for the first time. But if I close my program and then open it again, the reflection method will actually find the method, connection attempts will not have any errors, but in fact they do not connect.
If I close the application, turn on the Bluetooth adapter on the phone and try again, it will work correctly.
I do not understand what is happening, so any help would be very appreciated.
Joeyg source
share