例如在Mac上连接Android和Bluecove [英] Example connecting Android and Bluecove on a Mac

查看:594
本文介绍了例如在Mac上连接Android和Bluecove的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android设备(HTC不可思议的),我想在Android手机和MacBook Pro的之间建立蓝牙通信。我有bluecove开始在Mac上和我已经做了在Android中使用套接字编码,但我不能获得工作的连接。这里是我的Andr​​iod code

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());

在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.

推荐答案

您可以使用bluecove为Android。
在bluecove库和bluecove-机器人添加到您的构建路径和工作应该更容易。

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

这篇关于例如在Mac上连接Android和Bluecove的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆