本文介绍了如何使用蓝牙配对没有发送和接收的Andr​​oid编程的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid编程,并有java的概念,我想知道,我怎么能发送和接收使用蓝牙数据,而无需配对或任何密码(只有两个设备已经安装了我的应用程序),任何建议?

I am new to Android programming, and have java concept, I want to know that how can I send and receive data using bluetooth without pairing or any password (Only if both device has my app installed), any suggestion?

推荐答案

据我知道这是不可能送的的接收通过RFCOMM插座数据,而无需配对。我试过这个广泛的与我开发的应用程序。我的结果是:

As far as I know it's impossible to send or receive data over RFCOMM sockets without pairing. I've tried this extensively with an application that I'm developing. My results are:

  • 如果两个设备配对,并发现,双向通信是可能
  • 如果两个设备配对,但服务器的设备(一个Android设备正在尝试连接到)设置为没有的发现,那么双向通信仍然是可能的
  • 如果两个设备没有配对,但服务器设备的的发现,则配对请求仍然需要之前的双向通信是可能的。这意味着,RFCOMM的客户的插座(即那些从Android的)要求进行配对的设备。运行Android 2.2这是测试的三星Captivate的。我觉得这很奇怪,因为我能理解,需要配对允许RFCOMM的服务器插槽,但需要对配对的客户的插座是有点苛刻了。
  • If the two devices are paired and discoverable, bi-directional communication is possible
  • If the two devices are paired, but the "server" device (the one the android device is trying to connect to) is set to be not discoverable, then bi-directional communication is still possible
  • If the two devices are not paired, but the "server" device is discoverable, then a pairing request is still required before bi-directional communication is possible. This means that RFCOMM client sockets (i.e., those from Android) require the devices to be paired. This was tested on a Samsung Captivate running Android 2.2. I find this very strange, as I can understand requiring pairing before allowing RFCOMM server sockets, but requiring pairing for client sockets is a bit stringent.

由于@ethrbunny提到你也可以只用无线网络,设置并行服务器/客户端线程每个设备上,和发送任何你想要的。要在本地网络中,您可以选择使用零配置上发现服务。

As @ethrbunny mentioned you can also just use WiFi, setup parallel server/client threads on each device, and send whatever you want. To discover services on a local network you can optionally use zeroconf.

这篇关于如何使用蓝牙配对没有发送和接收的Andr​​oid编程的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 17:19