+2  A: 

If I understand correctly, your app is unable to see any data from the device whatsoever?

One small thing: try your UUID without hiphens. In my RFCOMM apps I actually define the UUID as a long integer constant.

Also, the way your test() method is written leads me to believe the test() is making the connection, defining a thread, telling it to start and immediately returning. In other words, your thread is referencing a variable from outside of the thread which is part of the test() method but when test() dies, so does its variables.

In short, try your testing outside of a thread and get it working there first. One easy way to do this would be to use Thread.run() instead of thread.start(). .run() runs it in the foreground (and thus blocks test() so it doesn't return before the thread finished).

For a longer term solution you may wish to define your Bluetooth variables as gloibal/member variables so they don't go out of scope and are always available to your thread.

Brad Hein
Hi Brad! Thank you for your answer. I tried different UUID formats but found no difference between them :( As you can see I update first test app so it doesn't use threads anymore (I wanted to do it 'by the book' with threads ;) ).
Gilead
You should definitely use threads - but they can be quite difficult to troubleshoot so keep them simple and move code into the thread after you get it working outside of the thread. Your UUID is probably fine - your main issue was probably just the thread. Just remember that as soon as you start the thread the method that started the thread will continue to go about its business (and even return) as the thread starts up in the background. Define your bluetooth connection as a class variable so any method/thread can access it. Then use a thread for I/O which can block so the user doesn't notice
Brad Hein
I will do it as soon as I get the bloody thing working ;) Actually I think it may be just a bug in Android's Java->Bluez glue code. Can't think of any other explanation.
Gilead
Although that's possible, I have a couple apps (one on the market) working great with bluetooth for some time now. My next recommendation would be to attach buffered input and output streams to the socket. You may be experiencing flow control. Using buffered streams prevents this and increases your throughput dramatically (because the data can arrive and wait in the buffer until you read it, instead of being blocked until your code reads it). import java.io.BufferedInputStream;instream = new BufferedInputStream(mobdSock.getInputStream(),INPUT_BUFFER_SIZE);
Brad Hein
A: 

Try the well known UUID:00001101-0000-1000-8000-00805F9B34FB

android_junkie
Sadly, none of these work :( I tried quite a lot of different services but got service discovery error for all 'generic' ones. But fair point, that was one of my guesses that I'm just connecting to the wrong UUID (and Android's API is too stupid to understand MAC/service/port addressing).
Gilead
+2  A: 

Try to change your code for creating RfcommSocket:

sock = zee.createRfcommSocketToServiceRecord(
                      UUID.fromString("8e1f0cf7-508f-4875-b62c-fbb67fd34812"));

for this code:

Method m = zee.getClass().getMethod("createRfcommSocket", new Class[] { int.class });
sock = (BluetoothSocket) m.invoke(device, 1);

Also try to change argument value in range 1-3 in this m.invoke(device, 1); When connection will be Connected, but aborted when you try reading, call in some loop your method test() again. As simple:

for(int i=0;i<3;i++){  if(!testDone) test(); }
Denis L
A: 

Thank you! I never would've figured this out.

Jeremy Johnson
A: 

hi !! could you please post your hole application (link)... i just started developing with android and i have to develope an application able to send file with bluetooth... i don't know haw to statr..

thanks

sabrina
I'm sorry I can't post my hole as it's a part of a bigger whole. Seriously though, you've got an Activity there so what else you may need? As you can tell from the question above my app doesn't send/receive files over BT anyway.
Gilead
A: 

Huge question I have downloaded the android market place app designed for the zeemote, followed the instructions and takes all the way through until it says connect with zeemote JS1 then immediately displays failure to connect recheck the the bluetooth I double check bluetooth is on and nothing! soo lost please help the guys who provided the app are just as lost and continue to say it will not work with HTC sense UI, if this code is the trick how do I use it on my HTC Hero?

Manuel