On Sep 19, 2012, at 3:01 PM, "Steve Sharrock" <[email protected]> wrote:
> I'm trying to add support for a bluetooth device in one of our applications
> based on the code from the latest Bluetooth Chat example on GitHub. On every
> attempt to perform socket.Connect() I get the Java.IO.IOException "Service
> discovery failed".
I see you found the advice to call CancelDiscovery():
http://stackoverflow.com/a/8752294/83444
Now you probably need to try the "hack" solution:
http://stackoverflow.com/a/3397739/83444
> Method m = device.getClass().getMethod("createRfcommSocket", new Class[]
> {int.class});
> socket = (BluetoothSocket) m.invoke(device, 1);
Unfortunately that solution relies on Java reflection, which we don't currently
expose. It thus needs to be translated to JNI:
IntPtr createRfcommSocket = JNIEnv.GetMethodID(device.Class.Handle,
"createRfcommSocket", "(I)Landroid/bluetooth/BluetoothSocket;");
IntPtr _socket = JNIEnv.CallObjectMethod(device.Handle,
createRfcommSocket, new Android.Runtime.JValue(1));
socket = Java.Lang.Object.GetObject<BluetoothSocket>(_socket,
JniHandleOwnership.TransferLocalRef);
- Jon
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid