Wednesday, June 2, 2010

[android-developers] Re: Bluetooth socket to non Android device

I got it working, the problem was that I needed to pair with the
device first (for some reason it kept an incorrect PIN and wouldn't
pair). Here is a snippet

BluetoothDevice device;
BluetoothSocket tmpsock = null;
int port = 1;
...
try
{
Method m = device.getClass().getMethod("createRfcommSocket", new
Class[] { int.class });
tmpsock = (BluetoothSocket)m.invoke(device, port);
Log.d(TAG, "CONNECTING...");
tmpsock.connect();
...
}
catch (Exception e)
{
Log.e(TAG, "Failed to connect", e);
...
}

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate