示例项目展示了如何将蓝牙数据从计算机发送到 Android 手机
我们正在尝试进行的项目的一部分涉及通过蓝牙从计算机向 Android 手机发送消息。我想知道是否有人已经做过类似的事情,谁可以与我们分享一些示例代码。
谢谢 费尔南多
One part of the project we are trying to undertake involves sending a message over bluetooth from a computer to an android phone. I was wondering if anyone has done something like this already who might be able to share some example code with us.
Thanks
Fernando
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我强烈建议您查看以下示例:BluetoothChat @developer.android.com
几个月前,我做了一个项目,我们设计了一个随身佩戴的无线传感器板,可以通过蓝牙将读数发送到 Android 手机,这个例子让我开始了。我很抱歉,但我目前无法分享我的确切代码。
该示例允许两部 Android 手机通过蓝牙相互聊天并将消息打印到屏幕上。通过对此示例进行一些更改,您可以发送所需的原始数据而不是用户输入。该示例中的BluetoothChatService类(在这里看到)为你处理所有丑陋的事情(监听连接、连接等)。
祝你好运!
I would highly recommend checking out the following example: BluetoothChat @ developer.android.com
I did a project a few months back where we designed a body-worn, wireless sensor board that would send readings to an Android phone over Bluetooth, and this example got me started. I apologize, but I cannot share my exact code at the moment.
The example allows two Android phones to chat with one another over Bluetooth and prints the messages to the screen. With a few changes to this example, you can send the raw data you need instead of user input. The BluetoothChatService class in that example (seen here) handles all the ugly stuff (listening for connections, connecting, etc) for you.
Good luck!