[mono-android] FW: Bluetooth Connect NullPointerException
Steve Sharrock
steve at sharkcode.com
Tue Oct 16 15:51:43 UTC 2012
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:jonp at xamarin.com]
Sent: Tuesday, October 16, 2012 6:54 AM
To: steve at 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 <steve at 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
More information about the Monodroid
mailing list