Hi, I have an app that is trying to connect to another device that is
not running Android, I have code written in C# to connect to it but I
do not know how to get around this UUID parameter. I cannot access
this device, nor do I know of a PIN so I cannot pair with it through
the Bluetooth Settings. I read somewhere that Android needs to be
paired with the device before it can connect, is this true?
Currently my app discovers all Bluetooth devices and I select which to
connect to. I've tried many different UUIDs from what I've found
online, the most common being "00001101-0000-1000-8000-00805F9B34FB".
So far nothing has allowed me to connect. Below is a snippet of my
connect method. Is there anyway I can work around this UUID issue?
private int connect(BluetoothDevice device)
{
dev = device;
BluetoothSocket tmp = null;
try
{
tmp = dev.createRfcommSocketToServiceRecord(MY_UUID);
} // try
catch (IOException e)
{
Log.e("", "create() failed" , e);
} // catch
sock = tmp;
ba.cancelDiscovery();
Log.d("BT", "Starting connect");
try
{
sock.connect();
Log.d("BT", "CONNECTED!");
if(createStreams() < 0)
return(-1);
} // try
catch (IOException e)
{
Log.e("BT", "Failed to connect");
// make toast
Context con = getApplicationContext();
CharSequence text = "Bluetooth socket connect failed";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(con, text, duration);
toast.show();
try
{
sock.close();
} // try
catch (IOException e2)
{
Log.e("BT", "Unable to close() socket during connection
failure", e2);
} // catch
return(-1);
} // catch
...
} // connect
Thanks all help is appreciated,
cbudz
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en