1

I have an Android device (HTC Incredible) and I would like to setup bluetooth communication between the android phone and a MacBook Pro. I have got bluecove to start on the Mac and I have done coding using Sockets in Android, but I can not get a connection working. Here is my andriod code

BluetoothDevice device = reciever.getDevice("00:25:00:XX:XX:XX"); //my bluetooth address
UUID generalUuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
socket = device.createRfcommSocketToServiceRecord(generalUuid);
socket.connect();
writer = new OutputStreamWriter(socket.getOutputStream());
reader = new InputStreamReader(socket.getInputStream());

on the Mac

String serverUUID = "btspp://localhost:0000110100001000800000805F9B34FB;name=matt";
StreamConnectionNotifier notifier = (StreamConnectionNotifier) Connector.open(serverUUID);
StreamConnection connection = notifier.acceptAndOpen();
// prepare to send/receive data
byte buffer[] = new byte[100];
String msg = "hello there, client";
InputStream is = connection.openInputStream();
OutputStream os = connection.openOutputStream();

Any help or examples would be helpful.

Milhous
  • 14,473
  • 16
  • 63
  • 82
  • Did you ever find a solution to this? I am having a similar issue except that I'm trying to connect to either BlueCove/Windows or PyBlueZ/Linux...neither connection is working with Android (but they work with each other fine). – Matt Mar 28 '12 at 03:29
  • @Matt No I never did succeed. – Milhous Apr 06 '12 at 18:02
  • @Milhous Have you implemented Bluecove in android?If so let me guide to implement the saame.I'm facing a lot of problems here to. – Senthil Mg Jun 25 '12 at 10:35

2 Answers2

0

You change the line of code

socket = device.createRfcommSocketToServiceRecord (generalUuid);

by

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

tmp = (BluetoothSocket) m.invoke (device, 1);

mmSocket = tmp;

mmSocket.connect ();

in Android

Hussain
  • 5,552
  • 4
  • 40
  • 50
  • I believe that code is the hack version of connecting, when android did not offically support bluetooth. – Milhous Jul 19 '11 at 01:08
0

you can use bluecove for android. add the bluecove library and the bluecove-android to your build path and the work should be easier.