我尝试使用以下方式创建服务:

LocalDevice localDevice = LocalDevice.getLocalDevice();
localDevice.setDiscoverable(DiscoveryAgent.GIAC);
String url = "btl2cap://localhost:"+uuid.toString()+";name="+name+";authorize=true;authenticate=true;encrypt=true";
L2CAPConnectionNotifier notifier = (L2CAPConnectionNotifier)Connector.open(url);
ServiceRecord = localDevice.getRecord(notifier);
// Set some attributes
// ...       
conn = notifier.acceptAndOpen();
//...

我在诺基亚5800和诺基亚2760上运行此代码,使用5800我可以看到2760,但反之亦然,我不知道有什么问题,我认为安全问题...

有任何想法吗?

谢谢!

有帮助吗?

解决方案

问题是在搜索中,该设备抛出了“忙”的BluetoothstateException。我发现的解决方案是在DevicesEarch和ServicesErch erearch之间引入延迟。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top