I am building a Bluetooth based application using Android. To debug
the application I am using these two devices:
-Nexus S
-LG P500
Following the Documentation on the Android Web Site:
http://developer.android.com/guide/topics/wireless/bluetooth.html
I have built a server and a client module.
When trying to connect to the devices I am using the following
routine:
Server:
mServerSocket = mBluetoothAdapter
.listenUsingRfcommWithServiceRecord("app", CTRLUUID);
mDeviceSocket = mServerSocket.accept();
Client:
mServerSocket = d.createRfcommSocketToServiceRecord(CTRLUUID);
mServerSocket.connect();
In certain cases I am able to interconnect the two devices. During
development in the past two weeks I repeatedly ran into the following
IOexception when connection from the client:
"Service discovery failed"
Although my Server side is accepting the connection.
I already found posts discussing similar problems although never in
the form of an "Android to Android" application.
What I noticed was the following behaviour:
If I start the server and wait a few seconds until I try to connect
with the client, chances are very high the connection is established.
I suspect, that if my continually tries to connect to an offline
server, the service discovery table somewhere caches the result and
does not really "look" for a new server the next time it tries to
connect. I tried to find a workaround for about a week now and am left
with adding a "Thread.sleep(10000)" before retrying to connect - which
is not really a solution.
Has anyone else been experiencing similar issues?
Thanks in advance!
Manuel
--
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