【发布时间】:2009-12-10 09:17:40
【问题描述】:
我尝试创建一个提供公开可用服务的 MIDlet,但下面的代码还不够。服务已开启(无异常)但仍无法发现。
public StreamConnection waitForConnection() throws IOException {
if (this.notifier == null) {
// Create a server connection (a notifier)
this.notifier = (StreamConnectionNotifier) Connector.open(serviceURL);
}
return this.notifier.acceptAndOpen();
}
url构造如下
private final static String serviceURL = "btspp://localhost:" + servieceUUID +
";name=" + serviceName + ";authenticate=false;master=false;encrypt=false";
经过一番谷歌搜索后,我发现这样的代码会有所帮助:
final ServiceRecord sr = LocalDevice.getLocalDevice().getRecord(this.notifier);
//Public browse group UUID
final DataElement element = new DataElement(DataElement.DATSEQ);
element.addElement(new DataElement(DataElement.UUID, new UUID(0x1002)));
sr.setAttributeValue(0x0005, element);
LocalDevice.getLocalDevice().updateRecord(sr);
但首先它不能解决问题,其次我不知道它实际上做了什么。
我使用诺基亚 E70。
有什么想法吗?
提前致谢。
【问题讨论】:
-
您要创建什么类型的服务?什么在做发现?您是否编写了试图发现它的代码?