OK - I'm an idiot. I rebooted the Galaxy Tab 2 and re-paired the scanner and now all works fine with either the secure or insecure socket.
Thanks for the reply. Steve Sharrock Architecture/Design/Programming www.sharkcode.com -----Original Message----- From: Jonathan Pryor [mailto:j...@xamarin.com] Sent: Tuesday, October 16, 2012 6:54 AM To: st...@sharkcode.com; Discussions related to Mono for Android Subject: Re: [mono-android] Bluetooth Connect NullPointerException On Oct 16, 2012, at 9:38 AM, Steve Sharrock <st...@sharkcode.com> wrote: > I've been testing with different Barcode Scanners and RFID Readers and most of them work fine, except one scanner paired with a Galaxy Tab 2. A Google search revealed that the Galaxy Tab 2 does have some Bluetooth issues, and the recommended work-around is to use an Insecure Socket. > > IntPtr createInsecureRfcommSocket = JNIEnv.GetMethodID( > device.Class.Handle, "createInsecureRfcommSocket", > "(I)Landroid/bluetooth/BluetoothSocket;" ); IntPtr socketHandle = > JNIEnv.CallObjectMethod( device.Handle, createInsecureRfcommSocket, > new JValue( 1 ) ); Is socketHandle IntPtr.Zero? > s = Java.Lang.Object.GetObject<BluetoothSocket>( socketHandle, > JniHandleOwnership.TransferLocalRef ); This doesn't work for me either and throws the NullPointerException when I try Socket.Connect(). Is my syntax correct in the Insecure code snippet? What's the full stack trace that you get? Java.Lang.Object.GetObject<T>() should return null if the handle is IntPtr.Zero. - Jon _______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid