Reputation: 1325
I am working on a bluetooth application which involves connection of my android bluetooth application with a server running on computer. The server is also a bluetooth application made using blue-cove api.
The problem i am facing now that i am unable to make connection between my mobile app and that computer server application.
here is my code for android app:
try {
// Connect the device through the socket. This will block
// until it succeeds or throws an exception
mySocket = myDevice.createRfcommSocketToServiceRecord(MY_UUID);
mySocket.connect();
toast = Toast.makeText(context, "Connection established", thisClass.duration);
toast.show();
} catch (IOException connectException) {
// Unable to connect; close the socket and get out
try {
mySocket.close();
toast = Toast.makeText(context, "Connection not established", thisClass.duration);
toast.show();
} catch (IOException closeException) { }
return;
}
Where is the problem or what possibly i am missing in it. And also i am having ambiguity in the understanding of socket.connect() method. Kindly help me in this regard.
Upvotes: 4
Views: 12085
Reputation: 446
I just finished working on a similar application and had problems connecting. It would help to see a bit more of your code but the excerpt above looks like the example I was following. I would start by checking that the MY_UUID exists on the PC that you are trying to connect to.
I have posted my example, both the client and server, on my blog at http://digitalhacksblog.blogspot.com/2012/05/android-example-bluetooth-simple-spp.html.
Hope this helps.
Upvotes: 5